test_rail_integration 0.0.8.2 → 0.0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +2 -1
 - data/Gemfile.lock +11 -0
 - data/config/data/test_rail_data.yml +9 -9
 - data/lib/test_rail_integration/cli.rb +8 -4
 - data/lib/test_rail_integration/generator/connection.rb +1 -1
 - data/lib/test_rail_integration/generator/project/check.rb +3 -1
 - data/lib/test_rail_integration/generator/test_case_result.rb +12 -3
 - data/lib/test_rail_integration/version.rb +1 -1
 - data/spec/api_calls_spec.rb +4 -0
 - data/spec/check_test_run_spec.rb +9 -4
 - data/spec/cli_spec.rb +74 -0
 - data/spec/hooks_spec.rb +6 -3
 - data/spec/scenario_types_spec.rb +98 -0
 - data/spec/spec_helper.rb +12 -0
 - metadata +6 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f140aef8b78ccaef86afb9b9a76591fdb85f4681
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 507af599a9e2f715736a7398800e33fdc1d68707
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6a8874e5145e6f62023369d4e5e3c6b628a5f1c61fabf6d58c8157cc9d62942d9ba97f5d61f95280e13695eb789e5cf2ee86a10cbdeb67483f6e3188a5965108
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 026b0fd649a021e4fe749e2fd61a3f4393a6519c1dd6ec2d34721634410d0eef57315162bee7622b2ea6f60776d82bb278690a575a888f228416fa82712dd1dc
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,11 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            GEM
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                builder (3.2.2)
         
     | 
| 
      
 5 
     | 
    
         
            +
                cucumber (1.3.19)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  builder (>= 2.1.2)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  diff-lcs (>= 1.1.3)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  gherkin (~> 2.12)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  multi_json (>= 1.7.5, < 2.0)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  multi_test (>= 0.1.2)
         
     | 
| 
       4 
11 
     | 
    
         
             
                diff-lcs (1.2.5)
         
     | 
| 
       5 
12 
     | 
    
         
             
                docile (1.1.5)
         
     | 
| 
       6 
13 
     | 
    
         
             
                fileutils (0.7)
         
     | 
| 
       7 
14 
     | 
    
         
             
                  rmagick (>= 2.13.1)
         
     | 
| 
      
 15 
     | 
    
         
            +
                gherkin (2.12.2)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  multi_json (~> 1.3)
         
     | 
| 
       8 
17 
     | 
    
         
             
                multi_json (1.11.0)
         
     | 
| 
      
 18 
     | 
    
         
            +
                multi_test (0.1.2)
         
     | 
| 
       9 
19 
     | 
    
         
             
                rmagick (2.13.4)
         
     | 
| 
       10 
20 
     | 
    
         
             
                rspec (3.2.0)
         
     | 
| 
       11 
21 
     | 
    
         
             
                  rspec-core (~> 3.2.0)
         
     | 
| 
         @@ -33,6 +43,7 @@ PLATFORMS 
     | 
|
| 
       33 
43 
     | 
    
         
             
              ruby
         
     | 
| 
       34 
44 
     | 
    
         | 
| 
       35 
45 
     | 
    
         
             
            DEPENDENCIES
         
     | 
| 
      
 46 
     | 
    
         
            +
              cucumber
         
     | 
| 
       36 
47 
     | 
    
         
             
              fileutils
         
     | 
| 
       37 
48 
     | 
    
         
             
              rspec
         
     | 
| 
       38 
49 
     | 
    
         
             
              simplecov-teamcity-summary
         
     | 
| 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            :connection_data:
         
     | 
| 
       2 
     | 
    
         
            -
              :url:  
     | 
| 
       3 
     | 
    
         
            -
              :username:  
     | 
| 
       4 
     | 
    
         
            -
              :password:  
     | 
| 
      
 2 
     | 
    
         
            +
              :url: #put here url of your TestRail server
         
     | 
| 
      
 3 
     | 
    
         
            +
              :username: #TestRail username
         
     | 
| 
      
 4 
     | 
    
         
            +
              :password: #Password for TestRail user
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            :project:  
     | 
| 
       7 
     | 
    
         
            -
            :test_suite:  
     | 
| 
       8 
     | 
    
         
            -
            :assigned_to:  
     | 
| 
      
 6 
     | 
    
         
            +
            :project: # Test project id can be found in Test Rail
         
     | 
| 
      
 7 
     | 
    
         
            +
            :test_suite: # Test suite id can be found in Test Rail
         
     | 
| 
      
 8 
     | 
    
         
            +
            :assigned_to: # Id of person could be found in Test Rail
         
     | 
| 
       9 
9 
     | 
    
         
             
            :description_of_run: "Automatically generated report by auto tests."
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            :status_comment: 0
         
     | 
| 
         @@ -22,9 +22,9 @@ 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
            :in_progress: " (in progress)" #value for changing test run name for monitoring complete of test run
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
            :test_run_id:  
     | 
| 
      
 25 
     | 
    
         
            +
            :test_run_id: 0 #parametrized test run from "ruby run_test_run.rb <test run number>"
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
            :exec_command: "cucumber -p lazada.#{parameters.venture}.#{parameters.environment} TESTRAIL=1 -- 
     | 
| 
      
 27 
     | 
    
         
            +
            :exec_command: "cucumber -p lazada.#{parameters.venture}.#{parameters.environment} TESTRAIL=1 --color -f json -o cucumber.json -t  "
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            :types:  
     | 
| 
      
 29 
     | 
    
         
            +
            :types: #types for filtering from Test Rail
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
         @@ -4,17 +4,21 @@ require_relative 'generator/project/check' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class CLI < Thor
         
     | 
| 
       6 
6 
     | 
    
         
             
              include TestRail
         
     | 
| 
       7 
     | 
    
         
            -
              desc "perform", "Creates project for interaction with TestRail"
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
              desc "perform", "Creates project for interaction with TestRail"
         
     | 
| 
       9 
9 
     | 
    
         
             
              def perform
         
     | 
| 
       10 
10 
     | 
    
         
             
                TestRail::Generators::Project.copy_file('run_test_run.rb')
         
     | 
| 
       11 
11 
     | 
    
         
             
                TestRail::Generators::Project.copy_file("test_rail_data.yml", "config/data/")
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
              desc "check_test_run_and_update", "Check test run statuses and update"
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
              desc "check_test_run_and_update", "Check test run statuses and update. Set test run id through --test_run_id parameter"
         
     | 
| 
      
 15 
     | 
    
         
            +
              option :test_run_id
         
     | 
| 
       16 
16 
     | 
    
         
             
              def check_test_run_and_update
         
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
      
 17 
     | 
    
         
            +
                if options[:test_run_id]
         
     | 
| 
      
 18 
     | 
    
         
            +
                  TestRail::Check.check_test_run_statuses(options[:test_run_id])
         
     | 
| 
      
 19 
     | 
    
         
            +
                else
         
     | 
| 
      
 20 
     | 
    
         
            +
                  puts "You must set correct test run id through --test_run_id"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
       18 
22 
     | 
    
         
             
              end
         
     | 
| 
       19 
23 
     | 
    
         
             
            end
         
     | 
| 
       20 
24 
     | 
    
         | 
| 
         @@ -30,7 +30,7 @@ module TestRail 
     | 
|
| 
       30 
30 
     | 
    
         
             
                # client.send_post("add_result_for_case/12/3131", status_id: '1', comment: "Test passed" )
         
     | 
| 
       31 
31 
     | 
    
         
             
                #
         
     | 
| 
       32 
32 
     | 
    
         
             
                def self.commit_test_result(test_case_result)
         
     | 
| 
       33 
     | 
    
         
            -
                  client.send_post("add_result_for_case/#{ 
     | 
| 
      
 33 
     | 
    
         
            +
                  client.send_post("add_result_for_case/#{test_run_id}/#{test_case_result.test_case_id}", test_case_result.to_test_rail_api)
         
     | 
| 
       34 
34 
     | 
    
         
             
                end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                #
         
     | 
| 
         @@ -7,10 +7,12 @@ module TestRail 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              class Check
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                def self.check_test_run_statuses
         
     | 
| 
      
 10 
     | 
    
         
            +
                def self.check_test_run_statuses(test_run_id)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  start_time = Time.new
         
     | 
| 
       12 
12 
     | 
    
         
             
                  results = []
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
      
 14 
     | 
    
         
            +
                  TestRail::Connection.test_run_id=(test_run_id)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       14 
16 
     | 
    
         
             
                  test_cases_ids = Connection.cases_with_types
         
     | 
| 
       15 
17 
     | 
    
         
             
                  test_cases_ids.each do |test_case_id|
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative 'test_rail_data_load'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'cucumber'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            module TestRail
         
     | 
| 
       4 
5 
     | 
    
         
             
              class TestCaseResult
         
     | 
| 
         @@ -9,7 +10,8 @@ module TestRail 
     | 
|
| 
       9 
10 
     | 
    
         
             
                              :assign_to,
         
     | 
| 
       10 
11 
     | 
    
         
             
                              :previous_comment,
         
     | 
| 
       11 
12 
     | 
    
         
             
                              :scenario,
         
     | 
| 
       12 
     | 
    
         
            -
                              :test_results
         
     | 
| 
      
 13 
     | 
    
         
            +
                              :test_results,
         
     | 
| 
      
 14 
     | 
    
         
            +
                              :title
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
16 
     | 
    
         
             
                COMMENT_STATUS ||= TestRail::TestRailDataLoad.test_rail_data[:status_comment]
         
     | 
| 
       15 
17 
     | 
    
         
             
                PASS ||= TestRail::TestRailDataLoad.test_rail_data[:test_pass]
         
     | 
| 
         @@ -29,6 +31,13 @@ module TestRail 
     | 
|
| 
       29 
31 
     | 
    
         
             
                def initialize(scenario)
         
     | 
| 
       30 
32 
     | 
    
         
             
                  self.test_case_id = scenario.source_tag_names.find { |e| e.match(TEST_RAIL_ID_REGEX) }[2..-1]
         
     | 
| 
       31 
33 
     | 
    
         
             
                  self.scenario = scenario
         
     | 
| 
      
 34 
     | 
    
         
            +
                  if scenario.kind_of? Cucumber::Ast::OutlineTable::ExampleRow
         
     | 
| 
      
 35 
     | 
    
         
            +
                    self.title = scenario.scenario_outline.title
         
     | 
| 
      
 36 
     | 
    
         
            +
                    self.exception_message = scenario.scenario_exception unless defined?(scenario.scenario_exception).nil?
         
     | 
| 
      
 37 
     | 
    
         
            +
                  else
         
     | 
| 
      
 38 
     | 
    
         
            +
                    self.title = scenario.title
         
     | 
| 
      
 39 
     | 
    
         
            +
                    self.exception_message = scenario.steps.exception unless defined?(scenario.steps).nil?
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
       32 
41 
     | 
    
         
             
                  self.test_results = TestRail::Connection.get_test_results(self.test_case_id)
         
     | 
| 
       33 
42 
     | 
    
         
             
                  self.previous_comment = get_last_failed_comment unless get_indexes_of_fails.empty?
         
     | 
| 
       34 
43 
     | 
    
         
             
                end
         
     | 
| 
         @@ -94,7 +103,7 @@ module TestRail 
     | 
|
| 
       94 
103 
     | 
    
         | 
| 
       95 
104 
     | 
    
         
             
                  if failed?
         
     | 
| 
       96 
105 
     | 
    
         
             
                    self.comment ||= COMMENT[:fail]
         
     | 
| 
       97 
     | 
    
         
            -
                    self.exception_message =  
     | 
| 
      
 106 
     | 
    
         
            +
                    self.exception_message = self.exception_message rescue nil
         
     | 
| 
       98 
107 
     | 
    
         
             
                    self.assign_to = ASSIGN_TO
         
     | 
| 
       99 
108 
     | 
    
         
             
                  end
         
     | 
| 
       100 
109 
     | 
    
         | 
| 
         @@ -111,7 +120,7 @@ module TestRail 
     | 
|
| 
       111 
120 
     | 
    
         
             
                # {status_id: 1, comment: "Test passed"}
         
     | 
| 
       112 
121 
     | 
    
         
             
                #
         
     | 
| 
       113 
122 
     | 
    
         
             
                def to_test_rail_api
         
     | 
| 
       114 
     | 
    
         
            -
                  comment_message = "#{self.comment[:comment]} \"#{self. 
     | 
| 
      
 123 
     | 
    
         
            +
                  comment_message = "#{self.comment[:comment]} \"#{self.title}\""
         
     | 
| 
       115 
124 
     | 
    
         
             
                  comment_message = "**[#{Fixtures.instance['venture']}]** #{self.comment[:comment]} for \"#{self.title}\"" unless defined?(Fixtures.instance['venture']).nil?
         
     | 
| 
       116 
125 
     | 
    
         
             
                  comment_message += "\n Exception : #{self.exception_message}" unless self.exception_message.nil?
         
     | 
| 
       117 
126 
     | 
    
         
             
                  comment_message += "\n #{self.previous_comment}" if self.comment[:status] == COMMENT[:fail][:status] || self.comment[:status] == COMMENT[:unchanged_pass][:status]
         
     | 
    
        data/spec/api_calls_spec.rb
    CHANGED
    
    | 
         @@ -8,6 +8,10 @@ describe 'Api calls' do 
     | 
|
| 
       8 
8 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       9 
9 
     | 
    
         
             
                  allow(TestRail::Connection).to receive(:commit_test_result).and_return('good!')
         
     | 
| 
       10 
10 
     | 
    
         
             
                  @scenario = double('scenario')
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @steps = double('scenario')
         
     | 
| 
      
 12 
     | 
    
         
            +
                  allow(@steps).to receive(:exception).and_return(nil)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  allow(@scenario).to receive(:steps).and_return(@steps)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  allow(@scenario).to receive(:kind_of?).and_return(false)
         
     | 
| 
       11 
15 
     | 
    
         
             
                  allow(@scenario).to receive(:source_tag_names).and_return(['@C4556'])
         
     | 
| 
       12 
16 
     | 
    
         
             
                  allow(@scenario).to receive(:title).and_return('title')
         
     | 
| 
       13 
17 
     | 
    
         
             
                  allow(@scenario).to receive(:passed?).and_return(true)
         
     | 
    
        data/spec/check_test_run_spec.rb
    CHANGED
    
    | 
         @@ -16,7 +16,7 @@ describe 'Checking test run' do 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                  it 'should change status to fail' do
         
     | 
| 
       19 
     | 
    
         
            -
                    test_case_results = TestRail::Check.check_test_run_statuses
         
     | 
| 
      
 19 
     | 
    
         
            +
                    test_case_results = TestRail::Check.check_test_run_statuses(anything)
         
     | 
| 
       20 
20 
     | 
    
         
             
                    expect(test_case_results[0].comment).to eq({:status => 5, :comment => "test **failed:**"})
         
     | 
| 
       21 
21 
     | 
    
         
             
                  end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
         @@ -25,7 +25,12 @@ describe 'Checking test run' do 
     | 
|
| 
       25 
25 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:get_case_info).once
         
     | 
| 
       26 
26 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:get_test_results).once
         
     | 
| 
       27 
27 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:commit_test_result).once
         
     | 
| 
       28 
     | 
    
         
            -
                    TestRail::Check.check_test_run_statuses
         
     | 
| 
      
 28 
     | 
    
         
            +
                    TestRail::Check.check_test_run_statuses(anything)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  it 'should set test run id with new id' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                    TestRail::Check.check_test_run_statuses('11111')
         
     | 
| 
      
 33 
     | 
    
         
            +
                    expect(TestRail::Connection::test_run_id).to eq('11111')
         
     | 
| 
       29 
34 
     | 
    
         
             
                  end
         
     | 
| 
       30 
35 
     | 
    
         | 
| 
       31 
36 
     | 
    
         
             
                end
         
     | 
| 
         @@ -40,7 +45,7 @@ describe 'Checking test run' do 
     | 
|
| 
       40 
45 
     | 
    
         
             
                  end
         
     | 
| 
       41 
46 
     | 
    
         | 
| 
       42 
47 
     | 
    
         
             
                  it 'should have two results' do
         
     | 
| 
       43 
     | 
    
         
            -
                    test_case_results = TestRail::Check.check_test_run_statuses
         
     | 
| 
      
 48 
     | 
    
         
            +
                    test_case_results = TestRail::Check.check_test_run_statuses(anything)
         
     | 
| 
       44 
49 
     | 
    
         
             
                    expect(test_case_results.length).to eq 2
         
     | 
| 
       45 
50 
     | 
    
         
             
                  end
         
     | 
| 
       46 
51 
     | 
    
         | 
| 
         @@ -49,7 +54,7 @@ describe 'Checking test run' do 
     | 
|
| 
       49 
54 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:get_case_info).twice
         
     | 
| 
       50 
55 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:get_test_results).twice
         
     | 
| 
       51 
56 
     | 
    
         
             
                    expect(TestRail::Connection).to receive(:commit_test_result).twice
         
     | 
| 
       52 
     | 
    
         
            -
                    TestRail::Check.check_test_run_statuses
         
     | 
| 
      
 57 
     | 
    
         
            +
                    TestRail::Check.check_test_run_statuses(anything)
         
     | 
| 
       53 
58 
     | 
    
         
             
                  end
         
     | 
| 
       54 
59 
     | 
    
         | 
| 
       55 
60 
     | 
    
         
             
                end
         
     | 
    
        data/spec/cli_spec.rb
    ADDED
    
    | 
         @@ -0,0 +1,74 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative '../lib/test_rail_integration/cli'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe CLI do
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                @subject = CLI.new
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              context 'when executing perform cli command' do
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @subject.perform
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                it 'run_test_run.rb should be copied' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  expect(File.exist?('run_test_run.rb')).to eq(true)
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                it 'copied run_test_run.rb should be identical' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(File.read('run_test_run.rb')).to eq(File.read('lib/test_rail_integration/generator/project/run_test_run.rb'))
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                it 'test_rail_data.yml should be copied' do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  expect(File.exist?('config/data/test_rail_data.yml')).to eq(true)
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it 'copied test_rail_data.yml should be identical' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  expect(File.exist?('run_test_run.rb')).to eq(true)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(File.read('run_test_run.rb')).to eq(File.read('lib/test_rail_integration/generator/project/run_test_run.rb'))
         
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(File.exist?('config/data/test_rail_data.yml')).to eq(true)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(File.read('config/data/test_rail_data.yml')).to eq(File.read('lib/test_rail_integration/generator/project/test_rail_data.yml'))
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              context 'when executing check_test_run_and_update cli command ' do
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                context 'and not passing test_run_id param' do
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  it 'should see output message' do
         
     | 
| 
      
 42 
     | 
    
         
            +
                    result = capture(:stdout) { @subject.check_test_run_and_update }
         
     | 
| 
      
 43 
     | 
    
         
            +
                    expect(result).to eq("You must set correct test run id through --test_run_id\n")
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  it 'should not not call check_test_run_statuses method' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                    expect(TestRail::Check).not_to receive(:check_test_run_statuses)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    @subject.check_test_run_and_update
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                context 'and passing test run id parameter ' do
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  before(:all) do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    @subject.options = {:test_run_id => 12345}
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  it 'should execute command once' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                    expect(TestRail::Check).to receive(:check_test_run_statuses)
         
     | 
| 
      
 61 
     | 
    
         
            +
                    @subject.check_test_run_and_update
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  it 'should not see any output ' do
         
     | 
| 
      
 65 
     | 
    
         
            +
                    allow(TestRail::Check).to receive(:check_test_run_statuses).and_return([])
         
     | 
| 
      
 66 
     | 
    
         
            +
                    result = capture(:stdout) { @subject.check_test_run_and_update }
         
     | 
| 
      
 67 
     | 
    
         
            +
                    expect(result).to eq('')
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/hooks_spec.rb
    CHANGED
    
    | 
         @@ -109,6 +109,9 @@ describe 'Update test results' do 
     | 
|
| 
       109 
109 
     | 
    
         | 
| 
       110 
110 
     | 
    
         
             
              private
         
     | 
| 
       111 
111 
     | 
    
         
             
              def passed_scenario
         
     | 
| 
      
 112 
     | 
    
         
            +
                @steps = double('steps')
         
     | 
| 
      
 113 
     | 
    
         
            +
                allow(@steps).to receive(:exception).and_return(nil)
         
     | 
| 
      
 114 
     | 
    
         
            +
                allow(@scenario).to receive(:steps).and_return(@steps)
         
     | 
| 
       112 
115 
     | 
    
         
             
                allow(@scenario).to receive(:passed?).and_return(true)
         
     | 
| 
       113 
116 
     | 
    
         
             
                @scenario
         
     | 
| 
       114 
117 
     | 
    
         
             
              end
         
     | 
| 
         @@ -116,9 +119,9 @@ describe 'Update test results' do 
     | 
|
| 
       116 
119 
     | 
    
         
             
              private
         
     | 
| 
       117 
120 
     | 
    
         
             
              def failed_scenario
         
     | 
| 
       118 
121 
     | 
    
         
             
                allow(@scenario).to receive(:passed?).and_return(false)
         
     | 
| 
       119 
     | 
    
         
            -
                steps = double('steps')
         
     | 
| 
       120 
     | 
    
         
            -
                allow(steps).to receive(:exception).and_return( 
     | 
| 
       121 
     | 
    
         
            -
                allow(@scenario).to receive(:steps).and_return(steps)
         
     | 
| 
      
 122 
     | 
    
         
            +
                @steps = double('steps')
         
     | 
| 
      
 123 
     | 
    
         
            +
                allow(@steps).to receive(:exception).and_return("exception")
         
     | 
| 
      
 124 
     | 
    
         
            +
                allow(@scenario).to receive(:steps).and_return(@steps)
         
     | 
| 
       122 
125 
     | 
    
         
             
                @scenario
         
     | 
| 
       123 
126 
     | 
    
         
             
              end
         
     | 
| 
       124 
127 
     | 
    
         | 
| 
         @@ -0,0 +1,98 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative '../lib/test_rail_integration/generator/connection'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative '../lib/test_rail_integration/generator/test_rail_hooks'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe 'Scenario types' do
         
     | 
| 
      
 6 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                ENV['rspec-tests-running'] = '1'
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              context 'when scenario outline received' do
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  allow(TestRail::Connection).to receive(:commit_test_result).and_return('good!')
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @scenario = double('scenario')
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @scenario_outline = double('scenario')
         
     | 
| 
      
 16 
     | 
    
         
            +
                  allow(@scenario_outline).to receive(:title).and_return('title scenario outline')
         
     | 
| 
      
 17 
     | 
    
         
            +
                  allow(@scenario).to receive(:scenario_outline).and_return(@scenario_outline)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  allow(@scenario).to receive(:kind_of?).and_return(true)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  allow(@scenario).to receive(:source_tag_names).and_return(['@C4556'])
         
     | 
| 
      
 20 
     | 
    
         
            +
                  allow(TestRail::Connection).to receive(:get_test_results).and_return([])
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                context 'with pass result' do
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 26 
     | 
    
         
            +
                    allow(@scenario).to receive(:passed?).and_return(true)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    allow(@scenario).to receive(:scenario_exception).and_return(nil)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  it 'should receive outline title' do
         
     | 
| 
      
 31 
     | 
    
         
            +
                    test_result = TestRail::Hook.update_test_rail(@scenario)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    expect(test_result.test_case_id).to eq('4556')
         
     | 
| 
      
 33 
     | 
    
         
            +
                    expect(test_result.comment).to eq({:status => 1, :comment => 'test **passed:**'})
         
     | 
| 
      
 34 
     | 
    
         
            +
                    expect(test_result.to_test_rail_api).to eq({:status_id => 1, :comment => "test **passed:** \"title scenario outline\""})
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                context 'with fail result' do
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 41 
     | 
    
         
            +
                    allow(@scenario).to receive(:scenario_exception).and_return('scenario outline exception')
         
     | 
| 
      
 42 
     | 
    
         
            +
                    allow(@scenario).to receive(:passed?).and_return(false)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  it 'should receive outline title and execption' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                    test_result = TestRail::Hook.update_test_rail(@scenario)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    expect(test_result.test_case_id).to eq('4556')
         
     | 
| 
      
 48 
     | 
    
         
            +
                    expect(test_result.comment).to eq({:status => 5, :comment => 'test **failed:**'})
         
     | 
| 
      
 49 
     | 
    
         
            +
                    expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title scenario outline\"\n Exception : scenario outline exception\n "})
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              context 'when standart scenario received' do
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 57 
     | 
    
         
            +
                  allow(TestRail::Connection).to receive(:commit_test_result).and_return('good!')
         
     | 
| 
      
 58 
     | 
    
         
            +
                  @scenario = double('scenario')
         
     | 
| 
      
 59 
     | 
    
         
            +
                  @steps = double('steps')
         
     | 
| 
      
 60 
     | 
    
         
            +
                  allow(@scenario).to receive(:kind_of?).and_return(false)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  allow(@scenario).to receive(:source_tag_names).and_return(['@C4556'])
         
     | 
| 
      
 62 
     | 
    
         
            +
                  allow(@scenario).to receive(:title).and_return('title')
         
     | 
| 
      
 63 
     | 
    
         
            +
                  allow(TestRail::Connection).to receive(:get_test_results).and_return([])
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                context 'with passed result' do
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 69 
     | 
    
         
            +
                    allow(@steps).to receive(:exception).and_return(nil)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    allow(@scenario).to receive(:steps).and_return(@steps)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    allow(@scenario).to receive(:passed?).and_return(true)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  it "should keep title from scenrio" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                    test_result = TestRail::Hook.update_test_rail(@scenario)
         
     | 
| 
      
 76 
     | 
    
         
            +
                    expect(test_result.test_case_id).to eq('4556')
         
     | 
| 
      
 77 
     | 
    
         
            +
                    expect(test_result.comment).to eq({:status => 1, :comment => 'test **passed:**'})
         
     | 
| 
      
 78 
     | 
    
         
            +
                    expect(test_result.to_test_rail_api).to eq({:status_id => 1, :comment => "test **passed:** \"title\""})
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                context 'with failed result' do
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 85 
     | 
    
         
            +
                    allow(@steps).to receive(:exception).and_return('exception')
         
     | 
| 
      
 86 
     | 
    
         
            +
                    allow(@scenario).to receive(:steps).and_return(@steps)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    allow(@scenario).to receive(:passed?).and_return(false)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  it 'should receive scenario title and exception' do
         
     | 
| 
      
 91 
     | 
    
         
            +
                    test_result = TestRail::Hook.update_test_rail(@scenario)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    expect(test_result.test_case_id).to eq('4556')
         
     | 
| 
      
 93 
     | 
    
         
            +
                    expect(test_result.comment).to eq({:status => 5, :comment => 'test **failed:**'})
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(test_result.to_test_rail_api).to eq({:status_id => 5, :comment => "test **failed:** \"title\"\n Exception : exception\n "})
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -7,6 +7,18 @@ SimpleCov.start do 
     | 
|
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
       8 
8 
     | 
    
         
             
            end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
      
 10 
     | 
    
         
            +
            def capture(stream)
         
     | 
| 
      
 11 
     | 
    
         
            +
              begin
         
     | 
| 
      
 12 
     | 
    
         
            +
                stream = stream.to_s
         
     | 
| 
      
 13 
     | 
    
         
            +
                eval "$#{stream} = StringIO.new"
         
     | 
| 
      
 14 
     | 
    
         
            +
                yield
         
     | 
| 
      
 15 
     | 
    
         
            +
                result = eval("$#{stream}").string
         
     | 
| 
      
 16 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 17 
     | 
    
         
            +
                eval("$#{stream} = #{stream.upcase}")
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
              result
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       10 
22 
     | 
    
         
             
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
       11 
23 
     | 
    
         
             
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
       12 
24 
     | 
    
         
             
            # The generated `.rspec` file contains `--require spec_helper` which will cause
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: test_rail_integration
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0.8. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.8.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Kirikami
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-03-26 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -181,7 +181,9 @@ files: 
     | 
|
| 
       181 
181 
     | 
    
         
             
            - lib/test_rail_integration/version.rb
         
     | 
| 
       182 
182 
     | 
    
         
             
            - spec/api_calls_spec.rb
         
     | 
| 
       183 
183 
     | 
    
         
             
            - spec/check_test_run_spec.rb
         
     | 
| 
      
 184 
     | 
    
         
            +
            - spec/cli_spec.rb
         
     | 
| 
       184 
185 
     | 
    
         
             
            - spec/hooks_spec.rb
         
     | 
| 
      
 186 
     | 
    
         
            +
            - spec/scenario_types_spec.rb
         
     | 
| 
       185 
187 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       186 
188 
     | 
    
         
             
            - test_rail_integration.gemspec
         
     | 
| 
       187 
189 
     | 
    
         
             
            homepage: https://github.com/Kirikami/test_rail_integration
         
     | 
| 
         @@ -211,5 +213,7 @@ summary: Gem for integration between framework and TestRail API 
     | 
|
| 
       211 
213 
     | 
    
         
             
            test_files:
         
     | 
| 
       212 
214 
     | 
    
         
             
            - spec/api_calls_spec.rb
         
     | 
| 
       213 
215 
     | 
    
         
             
            - spec/check_test_run_spec.rb
         
     | 
| 
      
 216 
     | 
    
         
            +
            - spec/cli_spec.rb
         
     | 
| 
       214 
217 
     | 
    
         
             
            - spec/hooks_spec.rb
         
     | 
| 
      
 218 
     | 
    
         
            +
            - spec/scenario_types_spec.rb
         
     | 
| 
       215 
219 
     | 
    
         
             
            - spec/spec_helper.rb
         
     |