Skip to content

Commit

Permalink
Merge pull request #20 from prashanth-sams/env_var
Browse files Browse the repository at this point in the history
[#7] Environment variable as testrail config
  • Loading branch information
prashanth-sams authored Mar 28, 2020
2 parents c298967 + 8e9b087 commit dc48ca1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [x] Static status comments on all the scenarios
- [x] Support for RSpec `shared examples`
- [x] Disable `testrail-rspec` execution on-demand
- [x] Support for environment variables to pass testrail config values

## Installation

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

6. To skip specific test-runs from deletion, when `clean_testrun` is set `true`
6. Skip specific test-runs from deletion: set `clean_testrun: true` & `skip_testrun_ids: value, ...`
```yaml
testrail:
url: https://your_url.testrail.io/
Expand All @@ -165,7 +166,7 @@ end
```
Here, `skip_testrun_ids: value` is optional.

7. To disable `testrail-rspec` execution
7. Disable `testrail-rspec` execution: set `allow: yes`
```yaml
testrail:
url: https://your_url.testrail.io/
Expand All @@ -174,7 +175,20 @@ end
run_id: 111
allow: no
```
Here, `skip_testrun_ids: value` is optional.
Here, `allow: yes` is optional.

8. Use Environment variables to pass testrail config values
```yaml
testrail:
url: ENV['URL']
user: ENV['TESTRAIL_USER']
password: ENV['TESTRAIL_PASSWORD']
run_id: ENV['RUN_ID']
clean_testrun: false
project_id: 10
suite_id: 110
```
Example, `rake ./demo_spec.rb TESTRAIL_USER=your@email.com TESTRAIL_PASSWORD=****** RUN_ID=564 URL=https://your_url.testrail.io/`

#### Hooks

Expand Down
8 changes: 8 additions & 0 deletions lib/testrail-rspec/update-testrails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ def initialize(scenario)

if File.exist? './testrail_config.yml'
@config = YAML.load_file("./testrail_config.yml")['testrail']

@config = @config.transform_values do |e|
if e.class != Integer && e.to_s.include?('ENV[')
eval(e)
else
e
end
end
raise 'TestRail configuration file not loaded successfully' if @config.nil?
else
raise 'TestRail configuration file is required'
Expand Down
2 changes: 1 addition & 1 deletion lib/testrail-rspec/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TestrailRspec
VERSION = '0.1.8'.freeze
VERSION = '0.1.9'.freeze
end

0 comments on commit dc48ca1

Please sign in to comment.