Skip to content

Commit dc48ca1

Browse files
Merge pull request #20 from prashanth-sams/env_var
[#7] Environment variable as testrail config
2 parents c298967 + 8e9b087 commit dc48ca1

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [x] Static status comments on all the scenarios
1212
- [x] Support for RSpec `shared examples`
1313
- [x] Disable `testrail-rspec` execution on-demand
14+
- [x] Support for environment variables to pass testrail config values
1415

1516
## Installation
1617

@@ -152,7 +153,7 @@ end
152153
```
153154
Set, `clean_testrun: false` if you don't want to clean the existing test runs; but this keyword is optional.
154155

155-
6. To skip specific test-runs from deletion, when `clean_testrun` is set `true`
156+
6. Skip specific test-runs from deletion: set `clean_testrun: true` & `skip_testrun_ids: value, ...`
156157
```yaml
157158
testrail:
158159
url: https://your_url.testrail.io/
@@ -165,7 +166,7 @@ end
165166
```
166167
Here, `skip_testrun_ids: value` is optional.
167168

168-
7. To disable `testrail-rspec` execution
169+
7. Disable `testrail-rspec` execution: set `allow: yes`
169170
```yaml
170171
testrail:
171172
url: https://your_url.testrail.io/
@@ -174,7 +175,20 @@ end
174175
run_id: 111
175176
allow: no
176177
```
177-
Here, `skip_testrun_ids: value` is optional.
178+
Here, `allow: yes` is optional.
179+
180+
8. Use Environment variables to pass testrail config values
181+
```yaml
182+
testrail:
183+
url: ENV['URL']
184+
user: ENV['TESTRAIL_USER']
185+
password: ENV['TESTRAIL_PASSWORD']
186+
run_id: ENV['RUN_ID']
187+
clean_testrun: false
188+
project_id: 10
189+
suite_id: 110
190+
```
191+
Example, `rake ./demo_spec.rb TESTRAIL_USER=your@email.com TESTRAIL_PASSWORD=****** RUN_ID=564 URL=https://your_url.testrail.io/`
178192

179193
#### Hooks
180194

lib/testrail-rspec/update-testrails.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ def initialize(scenario)
99

1010
if File.exist? './testrail_config.yml'
1111
@config = YAML.load_file("./testrail_config.yml")['testrail']
12+
13+
@config = @config.transform_values do |e|
14+
if e.class != Integer && e.to_s.include?('ENV[')
15+
eval(e)
16+
else
17+
e
18+
end
19+
end
1220
raise 'TestRail configuration file not loaded successfully' if @config.nil?
1321
else
1422
raise 'TestRail configuration file is required'

lib/testrail-rspec/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module TestrailRspec
2-
VERSION = '0.1.8'.freeze
2+
VERSION = '0.1.9'.freeze
33
end

0 commit comments

Comments
 (0)