Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ config.after(:each) do |scenario|
end
```

**To use credentials from environment variables**
- configuration could be provided in the constructor
- values from the passed `config` hash will take precedence over configuration in `testrail_config.yml`
```
testrail_config = {
url: ENV['TESTRAIL_URL']
user: ENV['TESTRAIL_USER']
password: ENV['TESTRAIL_PASSWORD']
run_id: ENV['TESTRAIL_RUN_ID']
}

config.after(:each) do |scenario|
TestrailRSpec::UpdateTestRails.new(scenario, config: testrail_config).upload_result
end
```

**Is there a demo available for this gem?**

Yes, you can use this `capybara` demo as an example, https://github.com/prashanth-sams/testrail-rspec
Expand Down
12 changes: 9 additions & 3 deletions lib/testrail-rspec/update-testrails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ module TestrailRSpec
class UpdateTestRails
attr_accessor :client

def initialize(scenario)
def initialize(scenario, config: {})
@scenario = scenario

if File.exist? './testrail_config.yml'
@config = YAML.load_file("./testrail_config.yml")['testrail']
raise 'TestRail configuration file not loaded successfully' if @config.nil?
else
raise 'TestRail configuration file is required'
end

if !config.nil? && !config.empty?
@config = (@config || {}).merge(config)
end

if @config.nil? || @config.empty?
raise 'TestRail configuration file or hash is required'
end

setup_testrail_client
Expand Down