test_rail_integration 0.0.8.8 → 0.0.8.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ed7f55c09af75e46f728054c3b80906347bdb1d
4
- data.tar.gz: 832be35fa6b15227d41358ae5e97247234eb6e48
3
+ metadata.gz: 0651cb6aabdecfe9a50f505e029038dbbb2c4fcd
4
+ data.tar.gz: 5b9eea8b4cfd649b35477e3f6de116b3166133d5
5
5
  SHA512:
6
- metadata.gz: a061d95b24909abe0e2421b37eb92ff38b37e306809be5ba1846ae764260f0a3a169eb8f69ddb7f51db728d276e996ebb108d086818f4069fd771c5662ccf183
7
- data.tar.gz: d2acb38a1da642bc582154fceb40c6d0a2ec2301cc6d72da66a04b54b948338eb994e4d87aea839260bda026c2b3b24883415f7b058736b6d23f76d9a110f87a
6
+ metadata.gz: 8b8ceec7cb756c098a32303013da483be093a7933e772a77b052881593aec14df77c552bb5183f8012da590c46833d1398dc0d521fe0a4052d777dbb00038982
7
+ data.tar.gz: 22dd7beb287162d2be292622300934ef204d53119b768ad3823634b0db6beeef1d0255e0b7fe00e59b55597b901b6be0e22cee1ff71920ba36c57070e6dc4440
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .idea/*
2
- Gemfile.lock
2
+ Gemfile.lock
3
+ coverage
4
+ spec/coverage
@@ -1,7 +1,7 @@
1
1
  require 'thor'
2
2
  require_relative 'generator/project'
3
3
  require_relative 'generator/project/check'
4
- require_relative 'generator/test_run_creation'
4
+ require_relative 'generator/test_run'
5
5
 
6
6
  class CLI < Thor
7
7
  include TestRail
@@ -21,20 +21,34 @@ class CLI < Thor
21
21
  end
22
22
  end
23
23
 
24
+ desc "create_test_run", "Create test run with name. Set test run name through --test_run_name parameter"
25
+ option :test_run_name
26
+ def create_test_run
27
+ test_run_name = options[:test_run_name]
28
+ if test_run_name
29
+ if test_run_name == ''
30
+ puts "Test_run_name parameter should not be empty"
31
+ else
32
+ test_run = TestRail::TestRun.create(test_run_name)
33
+ puts "You successfully created test run with id #{test_run.id}"
34
+ end
35
+ else
36
+ puts "You must set correct test run name through --test_run_name\n"
37
+ end
38
+ end
39
+
24
40
  desc "shoot", "Run Test Rail integration with \n
25
41
  --test_run_id for run id,
26
42
  optional:
27
43
  --venture for describing venture,
28
44
  --env for describing environment for run,
29
45
  --showroom with showroom name where start tests,
30
- --command with new command
31
- --auto for creating test run automatically and push all information inside"
46
+ --command with new command"
32
47
  option :test_run_id
33
48
  option :venture
34
49
  option :showroom
35
50
  option :command
36
51
  option :env
37
- option :auto
38
52
  def shoot
39
53
  if options[:test_run_id]
40
54
  run_id = options[:test_run_id]
@@ -53,10 +67,6 @@ class CLI < Thor
53
67
  Connection.test_run_id = run_id
54
68
  TestRailTools.write_test_run_id(run_id)
55
69
  TestRailTools.execute_generated_command(run_id, environment_for_run, command)
56
- elsif options[:auto]
57
- run_id = TestRunCreation.initialize_test_run
58
- environment_for_run = options[:venture], options[:env]
59
- TestRailTools.execute_generated_command(run_id, environment_for_run)
60
70
  else
61
71
  puts "You must set correct test run id through --test_run_id"
62
72
  end
@@ -126,27 +126,5 @@ module TestRail
126
126
  client.send_post("update_run/#{run_id}", {name: new_name})
127
127
  end
128
128
 
129
- #
130
- # Send request for creation test run with name
131
- # ("add_run/3", {suite_id: 3, name "New test run", include_all: false, case_ids: C31, C32, C33}
132
- #
133
- def self.create_new_test_run_with_name
134
- client.send_post("add_run/#{project_id}", {suite_id: test_suite_id, name: generate_test_run_name, include_all: false, case_ids: cases_with_types})
135
- end
136
-
137
- #
138
- # Get all test runs for project
139
- #
140
- def self.get_test_runs
141
- client.send_get("get_runs/#{project_id}")
142
- end
143
-
144
- #
145
- # Generate name for test run with date
146
- #
147
- def self.generate_test_run_name
148
- "Test run #{Time.now.strftime("%d/%m/%Y")}"
149
- end
150
-
151
129
  end
152
130
  end
@@ -0,0 +1,17 @@
1
+ module TestRail
2
+
3
+ class TestRun
4
+
5
+ attr_accessor :id
6
+
7
+ private
8
+ def initialize(result)
9
+ self.id = result["id"]
10
+ end
11
+
12
+ def self.create(test_run_name)
13
+ command_result = TestRail::Connection.create_test_run_with_name(test_run_name)
14
+ TestRun.new(command_result)
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module TestRailIntegration
2
- VERSION = "0.0.8.8"
2
+ VERSION = "0.0.8.9"
3
3
  end
@@ -39,7 +39,7 @@ describe 'Checking test run' do
39
39
 
40
40
  before(:each) do
41
41
  allow(TestRail::Connection).to receive(:cases_with_types).and_return([1011, 1213])
42
- allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}])
42
+ allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}] )
43
43
  allow(TestRail::Connection).to receive(:get_case_info).and_return({id: 1011, "title" => 'MLP'})
44
44
  allow(TestRail::Connection).to receive(:commit_test_result).and_return([])
45
45
  end
data/spec/cli_spec.rb CHANGED
@@ -67,76 +67,87 @@ describe CLI do
67
67
 
68
68
  end
69
69
 
70
- context 'when executing shoot cli command' do
70
+ context 'when executing create_test_run command' do
71
+
72
+ context 'and not passing test_run_name parameter' do
73
+
74
+ it 'should see output message' do
75
+ result = capture(:stdout) { @subject.create_test_run }
76
+ expect(result).to eq("You must set correct test run name through --test_run_name\n")
77
+ end
78
+
79
+ it 'should not not call check_test_run_statuses method' do
80
+ expect(TestRail::Connection).not_to receive(:create_test_run_with_name)
81
+ @subject.create_test_run
82
+ end
71
83
 
72
- before(:each) do
73
- allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
74
- allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
75
- allow(TestRail::TestRailTools).to receive(:exec).and_return("Ok")
76
84
  end
77
85
 
78
- context 'and not passing test run id param' do
86
+ context 'and passing test_run_name parameter' do
87
+
88
+ before(:all) do
89
+ @subject.options = {:test_run_name => 'test run name'}
90
+ end
79
91
 
80
92
  before(:each) do
81
- allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
82
- allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
93
+ allow(TestRail::Connection).to receive(:create_test_run_with_name).and_return(
94
+ {"id" => "561"})
83
95
  end
84
96
 
85
- it 'should not execute command once' do
86
- expect(TestRail::TestRailTools).not_to receive(:exec)
87
- @subject.shoot
97
+ it 'should execute command once' do
98
+ expect(TestRail::Connection).to receive(:create_test_run_with_name)
99
+ @subject.create_test_run
88
100
  end
89
101
 
90
- it 'should see output ' do
91
- result = capture(:stdout) { @subject.shoot }
92
- expect(result).to eq("You must set correct test run id through --test_run_id\n")
102
+ it 'should see created test run id in output' do
103
+ result = capture(:stdout) { @subject.create_test_run }
104
+ expect(result).to eq("You successfully created test run with id 561\n")
93
105
  end
94
106
 
95
107
  end
96
108
 
97
- context 'and not passing auto param' do
109
+ context 'and passing empty test_run_name parameter' do
98
110
 
99
- it 'should see output message' do
100
- result = capture(:stdout) { @subject.shoot }
101
- expect(result).to eq("You must set correct test run id through --test_run_id\n")
111
+ before(:all) do
112
+ @subject.options = {:test_run_name => ''}
102
113
  end
103
114
 
104
115
  it 'should not execute command once' do
105
- expect(TestRail::TestRailTools).not_to receive(:exec)
106
- @subject.shoot
116
+ expect(TestRail::Connection).not_to receive(:create_test_run_with_name)
117
+ @subject.create_test_run
107
118
  end
108
119
 
120
+ it 'should see a output' do
121
+ result = capture(:stdout) { @subject.create_test_run }
122
+ expect(result).to eq("Test_run_name parameter should not be empty\n")
123
+ end
109
124
  end
110
125
 
111
- context 'and passing auto param flag' do
126
+ end
112
127
 
113
- before(:each) do
114
- @subject.options[:auto] = ''
115
- @subject.options[:venture] = 'vn'
116
- @subject.options[:env] = 'live_test'
117
- allow(TestRail::TestRunCreation).to receive(:check_presence_of_test_run).and_return(true)
118
- allow(TestRail::TestRunCreation).to receive(:get_created_test_run_id).and_return("12345")
119
- end
128
+ context 'when executing shoot cli command' do
120
129
 
121
- after(:each) do
122
- @subject.options.delete("auto")
123
- @subject.options.delete("venture")
124
- @subject.options.delete("env")
125
- end
130
+ before(:each) do
131
+ allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
132
+ allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
133
+ allow(TestRail::TestRailTools).to receive(:exec).and_return("Ok")
134
+ end
126
135
 
127
- it 'should execute correct command' do
128
- result = capture(:stdout) { @subject.shoot }
129
- expect(result).to eq("\"Gem will execute command: cucumber -p lazada.vn.live_test TESTRAIL=1 --color -f json -o cucumber.json -t @C11,@C22,@C33\"\n")
136
+ context 'and not passing test run id param' do
137
+
138
+ before(:each) do
139
+ allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
140
+ allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
130
141
  end
131
142
 
132
- it 'should write test run id in config file' do
143
+ it 'should not execute command once' do
144
+ expect(TestRail::TestRailTools).not_to receive(:exec)
133
145
  @subject.shoot
134
- expect(YAML.load(File.open(TestRail::TestRailDataLoad::TEST_RAIL_FILE_CONFIG_PATH))[:test_run_id]).to eq(12345)
135
146
  end
136
147
 
137
- it 'should call execution command' do
138
- expect(TestRail::TestRailTools).to receive(:exec)
139
- @subject.shoot
148
+ it 'should see output ' do
149
+ result = capture(:stdout) { @subject.shoot }
150
+ expect(result).to eq("You must set correct test run id through --test_run_id\n")
140
151
  end
141
152
 
142
153
  end
@@ -269,11 +280,4 @@ describe CLI do
269
280
  end
270
281
  end
271
282
  end
272
- end
273
-
274
-
275
-
276
-
277
-
278
-
279
-
283
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_rail_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.8
4
+ version: 0.0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirikami
@@ -174,7 +174,7 @@ files:
174
174
  - lib/test_rail_integration/generator/test_rail_data_load.rb
175
175
  - lib/test_rail_integration/generator/test_rail_hooks.rb
176
176
  - lib/test_rail_integration/generator/test_rail_tools.rb
177
- - lib/test_rail_integration/generator/test_run_creation.rb
177
+ - lib/test_rail_integration/generator/test_run.rb
178
178
  - lib/test_rail_integration/generator/test_run_parameters.rb
179
179
  - lib/test_rail_integration/version.rb
180
180
  - spec/api_calls_spec.rb
@@ -1,49 +0,0 @@
1
- require_relative 'test_rail_data_load'
2
- require_relative 'connection'
3
- require_relative 'test_run_parameters'
4
-
5
- module TestRail
6
- class TestRunCreation
7
-
8
- #
9
- # Get all test run names for project
10
- #
11
- def self.get_test_runs_names
12
- test_runs = Connection.get_test_runs
13
- test_runs_names = []
14
- test_runs.each { |test_run| test_runs_names.push(test_run.fetch("name")) }
15
- test_runs_names
16
- end
17
-
18
- #
19
- # Get id for new test run that we created
20
- #
21
- def self.get_created_test_run_id
22
- test_runs = Connection.get_test_runs
23
- created_test_run_id = test_runs.map { |test_run|
24
- test_run.fetch("id") if test_run.fetch("name").eql? Connection.generate_test_run_name
25
- }
26
- created_test_run_id.first
27
- end
28
-
29
- #
30
- # Checking that test run already created
31
- #
32
- def self.check_presence_of_test_run
33
- TestRunCreation.get_test_runs_names.include? Connection.generate_test_run_name
34
- end
35
-
36
- #
37
- # Check and create test run
38
- #
39
- def self.initialize_test_run
40
- unless TestRunCreation.check_presence_of_test_run
41
- Connection.create_new_test_run_with_name
42
- end
43
- created_test_run_id = TestRunCreation.get_created_test_run_id
44
- TestRailTools.write_test_run_id(created_test_run_id)
45
- end
46
-
47
- end
48
-
49
- end