howitzer 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +3 -1
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +4 -1
  6. data/.yardopts +5 -0
  7. data/CHANGELOG.md +23 -1
  8. data/CONTRIBUTING.md +14 -0
  9. data/GETTING_STARTED.md +283 -183
  10. data/Gemfile +3 -2
  11. data/LICENSE +1 -1
  12. data/README.md +93 -39
  13. data/Rakefile +4 -0
  14. data/bin/howitzer +34 -5
  15. data/features/cli_help.feature +3 -2
  16. data/features/cli_new.feature +1 -1
  17. data/features/cli_unknown.feature +1 -1
  18. data/features/cli_update.feature +84 -0
  19. data/features/step_definitions/common_steps.rb +9 -1
  20. data/generators/base_generator.rb +30 -15
  21. data/generators/config/config_generator.rb +7 -7
  22. data/generators/config/templates/custom.yml +1 -0
  23. data/generators/config/templates/default.yml +35 -5
  24. data/generators/cucumber/templates/env.rb +2 -2
  25. data/generators/cucumber/templates/transformers.rb +3 -1
  26. data/generators/root/templates/Gemfile +5 -3
  27. data/generators/root/templates/Rakefile +2 -0
  28. data/generators/rspec/templates/example_spec.rb +3 -3
  29. data/generators/rspec/templates/spec_helper.rb +6 -7
  30. data/howitzer.gemspec +15 -15
  31. data/lib/howitzer/capybara/settings.rb +125 -49
  32. data/lib/howitzer/helpers.rb +161 -94
  33. data/lib/howitzer/mailgun/client.rb +1 -1
  34. data/lib/howitzer/tasks/framework.rake +3 -0
  35. data/lib/howitzer/utils.rb +1 -1
  36. data/lib/howitzer/utils/locator_store.rb +1 -1
  37. data/lib/howitzer/utils/log.rb +1 -1
  38. data/lib/howitzer/utils/page_validator.rb +1 -1
  39. data/lib/howitzer/version.rb +1 -1
  40. data/lib/howitzer/web_page.rb +11 -11
  41. data/spec/spec_helper.rb +25 -22
  42. data/spec/support/generator_helper.rb +8 -1
  43. data/spec/unit/generators/base_generator_spec.rb +242 -0
  44. data/spec/unit/generators/config_generator_spec.rb +34 -0
  45. data/spec/unit/generators/cucumber_generator_spec.rb +45 -0
  46. data/spec/unit/generators/emails_generator_spec.rb +31 -0
  47. data/spec/unit/generators/pages_generator_spec.rb +33 -0
  48. data/spec/unit/generators/root_generator_spec.rb +35 -0
  49. data/spec/unit/generators/rspec_generator_spec.rb +36 -0
  50. data/spec/unit/generators/tasks_generator_spec.rb +31 -0
  51. data/spec/unit/lib/capybara/dsl_ex_spec.rb +11 -11
  52. data/spec/unit/lib/capybara/settings_spec.rb +336 -58
  53. data/spec/unit/lib/email_spec.rb +17 -17
  54. data/spec/unit/lib/helpers_spec.rb +699 -315
  55. data/spec/unit/lib/mailgun/client_spec.rb +9 -9
  56. data/spec/unit/lib/mailgun/connector_spec.rb +20 -20
  57. data/spec/unit/lib/mailgun/response_spec.rb +9 -9
  58. data/spec/unit/lib/settings_spec.rb +6 -6
  59. data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +31 -31
  60. data/spec/unit/lib/utils/data_generator/gen_spec.rb +20 -20
  61. data/spec/unit/lib/utils/locator_store_spec.rb +39 -39
  62. data/spec/unit/lib/utils/log_spec.rb +42 -42
  63. data/spec/unit/lib/utils/page_validator_spec.rb +69 -70
  64. data/spec/unit/lib/web_page_spec.rb +91 -69
  65. data/spec/unit/version_spec.rb +3 -3
  66. metadata +100 -78
  67. data/spec/unit/generators/generators_spec.rb +0 -175
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Generators' do
4
+ let(:destination) { Howitzer::BaseGenerator.destination }
5
+ let(:output) { StringIO.new }
6
+ subject { file_tree_info(destination) }
7
+ before do
8
+ Howitzer::BaseGenerator.logger = output
9
+ generator_name.new
10
+ end
11
+ after { FileUtils.rm_r(destination) }
12
+
13
+ describe 'TasksGenerator' do
14
+ let(:generator_name) { Howitzer::TasksGenerator }
15
+ let(:expected_result) do
16
+ [
17
+ {:name=> '/tasks', :is_directory=>true},
18
+ {:name=> '/tasks/common.rake', :is_directory=>false, :size=>template_file_size('tasks', 'common.rake')}
19
+ ]
20
+ end
21
+ it { is_expected.to eql(expected_result) }
22
+ describe 'output' do
23
+ let(:expected_output) do
24
+ " * Base rake task generation ...
25
+ Added 'tasks/common.rake' file\n"
26
+ end
27
+ subject { output.string }
28
+ it { is_expected.to eql(expected_output) }
29
+ end
30
+ end
31
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'howitzer/capybara/dsl_ex'
3
3
 
4
- describe Howitzer::Capybara::DslEx do
4
+ RSpec.describe Howitzer::Capybara::DslEx do
5
5
  let(:test_page_klass) do
6
6
  Class.new do
7
7
  include Howitzer::Capybara::DslEx
@@ -10,22 +10,22 @@ describe Howitzer::Capybara::DslEx do
10
10
  end
11
11
  let(:test_page) { test_page_klass.new }
12
12
 
13
- describe "#find" do
14
- context "when string argument with block" do
13
+ describe '#find' do
14
+ context 'when string argument with block' do
15
15
  subject { test_page.find('foo'){ 'bar' } }
16
16
  it do
17
17
  expect(test_page.page).to receive(:find).with('foo').and_yield.once
18
18
  subject
19
19
  end
20
20
  end
21
- context "when first hash argument and second hash" do
21
+ context 'when first hash argument and second hash' do
22
22
  subject { test_page.find({xpath: '//bar'}, {with: 'foo'}) }
23
23
  it do
24
- expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=>"foo"}).once
24
+ expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=> 'foo'}).once
25
25
  subject
26
26
  end
27
27
  end
28
- context "when array argument" do
28
+ context 'when array argument' do
29
29
  subject { test_page.find([:xpath, '//bar']) }
30
30
  it do
31
31
  expect(test_page.page).to receive(:find).with(:xpath, '//bar').once
@@ -34,22 +34,22 @@ describe Howitzer::Capybara::DslEx do
34
34
  end
35
35
  end
36
36
 
37
- describe ".find" do
38
- context "when string argument with block" do
37
+ describe '.find' do
38
+ context 'when string argument with block' do
39
39
  subject { test_page_klass.find('foo'){ 'bar' } }
40
40
  it do
41
41
  expect(test_page.page).to receive(:find).with('foo').and_yield.once
42
42
  subject
43
43
  end
44
44
  end
45
- context "when first hash argument and second hash" do
45
+ context 'when first hash argument and second hash' do
46
46
  subject { test_page_klass.find({xpath: '//bar'}, {with: 'foo'}) }
47
47
  it do
48
- expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=>"foo"}).once
48
+ expect(test_page.page).to receive(:find).with(:xpath, '//bar', {:with=> 'foo'}).once
49
49
  subject
50
50
  end
51
51
  end
52
- context "when array argument" do
52
+ context 'when array argument' do
53
53
  subject { test_page_klass.find([:xpath, '//bar']) }
54
54
  it do
55
55
  expect(test_page.page).to receive(:find).with(:xpath, '//bar').once
@@ -2,145 +2,365 @@ require 'spec_helper'
2
2
 
3
3
  require 'howitzer/capybara/settings'
4
4
 
5
- describe "CapybaraSettings" do
6
- it "supports deprecated module name" do
5
+ RSpec.describe 'CapybaraSettings' do
6
+ it 'supports deprecated module name' do
7
7
  expect { CapybaraSettings }.to_not raise_error
8
8
  expect(CapybaraSettings).to eq(Capybara::Settings)
9
9
  end
10
10
  end
11
11
 
12
- describe "Capybara::Settings" do
13
- let(:log) { double("log") }
14
- let(:test_object) { double("test_object").extend(Capybara::Settings) }
12
+ RSpec.describe 'Capybara::Settings' do
13
+ let(:log) { double('log') }
14
+ let(:test_object) { double('test_object').extend(Capybara::Settings) }
15
15
  before do
16
16
  allow(log).to receive(:error).and_return( true )
17
17
  end
18
18
 
19
- describe "#sauce_resource_path" do
19
+ describe '.base_ff_profile_settings' do
20
+ subject { Capybara::Settings.base_ff_profile_settings }
21
+ before do
22
+ allow(::Selenium::WebDriver::Firefox::Profile).to receive(:new) { Hash.new }
23
+ allow(settings).to receive(:app_host) { 'localhost' }
24
+ end
25
+
26
+ it do
27
+ is_expected.to eq(
28
+ 'network.http.phishy-userpass-length' => 255,
29
+ 'browser.safebrowsing.malware.enabled' => false,
30
+ 'network.automatic-ntlm-auth.allow-non-fqdn' => true,
31
+ 'network.ntlm.send-lm-response' => true,
32
+ 'network.automatic-ntlm-auth.trusted-uris' => 'localhost'
33
+ )
34
+ end
35
+ end
36
+
37
+ describe '.define_driver' do
38
+ subject { Capybara::Settings.define_driver }
39
+ context 'when selenium driver' do
40
+ before do
41
+ allow(settings).to receive(:driver).and_return('selenium')
42
+ allow(settings).to receive(:sel_browser).and_return('chrome')
43
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
44
+ end
45
+ it do
46
+ expect(Capybara.default_driver).to be(:selenium)
47
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
48
+ end
49
+ end
50
+
51
+ context 'when selenium dev driver' do
52
+ let(:profile) { Hash.new }
53
+ before do
54
+ allow(::Selenium::WebDriver::Firefox::Profile).to receive(:new) { profile }
55
+ allow(settings).to receive(:app_host) { 'localhost' }
56
+ allow(settings).to receive(:driver).and_return('selenium_dev')
57
+ allow(settings).to receive(:sel_browser).and_return('firefox')
58
+ end
59
+
60
+ context 'when extension is found' do
61
+ before { allow(profile).to receive(:add_extension).and_return('') }
62
+ it do
63
+ expect(Capybara.default_driver).to be(:selenium)
64
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
65
+ end
66
+ it do
67
+ expect(subject.call.options[:profile]).to eq(
68
+ 'network.http.phishy-userpass-length' => 255,
69
+ 'browser.safebrowsing.malware.enabled' => false,
70
+ 'network.automatic-ntlm-auth.allow-non-fqdn' => true,
71
+ 'network.ntlm.send-lm-response' => true,
72
+ 'network.automatic-ntlm-auth.trusted-uris' => 'localhost',
73
+ 'extensions.firebug.currentVersion' => 'Last',
74
+ 'extensions.firebug.previousPlacement' => 1,
75
+ 'extensions.firebug.onByDefault' => true,
76
+ 'extensions.firebug.defaultPanelName' => 'firepath',
77
+ 'extensions.firebug.script.enableSites' => true,
78
+ 'extensions.firebug.net.enableSites' => true,
79
+ 'extensions.firebug.console.enableSites' => true
80
+ )
81
+ end
82
+ end
83
+ end
84
+
85
+ context 'when webkit driver' do
86
+ before do
87
+ allow(settings).to receive(:driver).and_return('webkit')
88
+ allow(Capybara::Settings).to receive(:require).with('capybara-webkit').and_return(true)
89
+ end
90
+ it { is_expected.to be true }
91
+ end
92
+
93
+ context 'when poltergeist driver' do
94
+ before do
95
+ allow(settings).to receive(:driver).and_return('poltergeist')
96
+ allow(settings).to receive(:pjs_ignore_js_errors).and_return(false)
97
+ end
98
+ it do
99
+ expect(subject.call).to be_an_instance_of(Capybara::Poltergeist::Driver)
100
+ expect(subject.call.options).to eq(
101
+ js_errors: !settings.pjs_ignore_js_errors,
102
+ phantomjs_options: ['--ignore-ssl-errors=no']
103
+ )
104
+ end
105
+ end
106
+
107
+ context 'when phantomjs driver' do
108
+ before do
109
+ allow(settings).to receive(:driver).and_return('phantomjs')
110
+ allow(settings).to receive(:pjs_ignore_js_errors).and_return(false)
111
+ end
112
+ it do
113
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
114
+ expect(subject.call.options[:browser]).to eq(:phantomjs)
115
+ expect(subject.call.options[:desired_capabilities][:javascript_enabled]).not_to eq(settings.pjs_ignore_js_errors)
116
+ expect(subject.call.options[:args]).to eq(["--ignore-ssl-errors=no"])
117
+ end
118
+ end
119
+
120
+ context 'when sauce driver' do
121
+ let(:driver) { Object.new }
122
+ before do
123
+ allow(settings).to receive(:driver).and_return('sauce')
124
+ allow(settings).to receive(:sl_browser_name).and_return('firefox')
125
+ allow(driver).to receive_message_chain(:browser, :file_detector=)
126
+ allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
127
+ end
128
+ it { expect(subject.call).to eql(driver) }
129
+ end
130
+
131
+ context 'when testingbot driver' do
132
+ let(:driver) { Object.new }
133
+ before do
134
+ allow(settings).to receive(:driver).and_return('testingbot')
135
+ allow(settings).to receive(:tb_browser_name).and_return('firefox')
136
+ allow(driver).to receive_message_chain(:browser, :file_detector=)
137
+ allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
138
+ end
139
+ it { expect(subject.call).to eql(driver) }
140
+ end
141
+
142
+ context 'when selenium_grid driver' do
143
+ before { allow(settings).to receive(:driver).and_return('selenium_grid') }
144
+
145
+ context "and ie browser" do
146
+ before { allow(Capybara::Settings).to receive(:ie_browser?).and_return(true) }
147
+ it do
148
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
149
+ expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('internet explorer')
150
+ expect(subject.call.options[:desired_capabilities][:platform]).to eq(:windows)
151
+ end
152
+ end
153
+
154
+ context "and firefox browser" do
155
+ before do
156
+ allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
157
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(true)
158
+ end
159
+ it do
160
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
161
+ expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('firefox')
162
+ end
163
+ end
164
+
165
+ context "and chrome browser" do
166
+ before do
167
+ allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
168
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
169
+ allow(Capybara::Settings).to receive(:chrome_browser?).and_return(true)
170
+ end
171
+ it do
172
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
173
+ expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('chrome')
174
+ end
175
+ end
176
+
177
+ context "and opera browser" do
178
+ before do
179
+ allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
180
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
181
+ allow(Capybara::Settings).to receive(:chrome_browser?).and_return(false)
182
+ allow(Capybara::Settings).to receive(:opera_browser?).and_return(true)
183
+ end
184
+ it do
185
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
186
+ expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('opera')
187
+ end
188
+ end
189
+
190
+ context "and safari browser" do
191
+ before do
192
+ allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
193
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
194
+ allow(Capybara::Settings).to receive(:chrome_browser?).and_return(false)
195
+ allow(Capybara::Settings).to receive(:opera_browser?).and_return(false)
196
+ allow(Capybara::Settings).to receive(:safari_browser?).and_return(true)
197
+ end
198
+ it do
199
+ expect(subject.call).to be_an_instance_of(Capybara::Selenium::Driver)
200
+ expect(subject.call.options[:desired_capabilities][:browser_name]).to eq('safari')
201
+ end
202
+ end
203
+
204
+ context "and incorrect browser" do
205
+ before do
206
+ allow(Capybara::Settings).to receive(:ie_browser?).and_return(false)
207
+ allow(Capybara::Settings).to receive(:ff_browser?).and_return(false)
208
+ allow(Capybara::Settings).to receive(:chrome_browser?).and_return(false)
209
+ allow(Capybara::Settings).to receive(:opera_browser?).and_return(false)
210
+ allow(Capybara::Settings).to receive(:safari_browser?).and_return(false)
211
+ it do
212
+ expect { subject }.to raise_error(RuntimeError, "Unknown '#{settings.sel_browser}' sel_browser. Check your settings, it should be one of [:ie, :iexplore, :ff, :firefox, :chrome, :opera, safari]")
213
+ end
214
+ end
215
+ end
216
+ end
217
+
218
+ context 'when browserstack driver' do
219
+ let(:driver) { Object.new }
220
+ before do
221
+ allow(settings).to receive(:driver).and_return('browserstack')
222
+ allow(settings).to receive(:bs_browser_name).and_return('firefox')
223
+ allow(driver).to receive_message_chain(:browser, :file_detector=)
224
+ allow(Capybara::Selenium::Driver).to receive(:new).and_return(driver)
225
+ end
226
+ it { expect(subject.call).to eql(driver) }
227
+ end
228
+
229
+ context 'when incorrect driver' do
230
+ before do
231
+ allow(settings).to receive(:driver).and_return('caramba')
232
+ end
233
+ it do
234
+ expect { subject }.to raise_error(RuntimeError, "Unknown '#{settings.driver}' driver. Check your settings, it should be one of [selenium, selenium_grid, selenium_dev, webkit, poltergeist, phantomjs, sauce, testingbot, browserstack]")
235
+ end
236
+ end
237
+ end
238
+
239
+ describe '#sauce_resource_path' do
20
240
  subject { test_object.sauce_resource_path(name) }
21
- let (:name) { "test_name" }
241
+ let (:name) { 'test_name' }
22
242
  before do
23
- allow(settings).to receive(:sl_user) { "vlad" }
24
- allow(settings).to receive(:sl_api_key) { "11111" }
243
+ allow(settings).to receive(:sl_user) { 'vlad' }
244
+ allow(settings).to receive(:sl_api_key) { '11111' }
25
245
  allow(test_object).to receive(:session_id) { '12341234' }
26
246
  end
27
- it { expect(subject).to eql("https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name") }
247
+ it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name') }
28
248
  end
29
- describe ".sauce_resource_path" do
249
+ describe '.sauce_resource_path' do
30
250
  subject { Capybara::Settings.sauce_resource_path(name) }
31
- let (:name) { "test_name" }
251
+ let (:name) { 'test_name' }
32
252
  before do
33
- allow(settings).to receive(:sl_user) { "vlad" }
34
- allow(settings).to receive(:sl_api_key) { "11111" }
253
+ allow(settings).to receive(:sl_user) { 'vlad' }
254
+ allow(settings).to receive(:sl_api_key) { '11111' }
35
255
  allow(Capybara::Settings).to receive(:session_id) { '12341234' }
36
256
  end
37
257
 
38
- it { expect(subject).to eql("https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name") }
258
+ it { is_expected.to eql('https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name') }
39
259
  end
40
260
 
41
- describe "#update_sauce_job_status" do
261
+ describe '#update_sauce_job_status' do
42
262
  subject { test_object.update_sauce_job_status }
43
263
  before do
44
- allow(settings).to receive(:sl_user) { "vlad1" }
45
- allow(settings).to receive(:sl_api_key) { "22222" }
264
+ allow(settings).to receive(:sl_user) { 'vlad1' }
265
+ allow(settings).to receive(:sl_api_key) { '22222' }
46
266
  allow(test_object).to receive(:session_id) { '12341234' }
47
- stub_const("RestClient", double)
267
+ stub_const('RestClient', double)
48
268
  end
49
269
 
50
270
  it do
51
- expect(RestClient).to receive(:put).with("http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234", "{}", {content_type: :json, accept: :json}).once
271
+ expect(RestClient).to receive(:put).with('http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234', '{}', {content_type: :json, accept: :json}).once
52
272
  subject
53
273
  end
54
274
  end
55
275
 
56
- describe ".update_sauce_resource_path" do
276
+ describe '.update_sauce_resource_path' do
57
277
  subject { Capybara::Settings.update_sauce_job_status }
58
278
  before do
59
- allow(settings).to receive(:sl_user) { "vlad1" }
60
- allow(settings).to receive(:sl_api_key) { "22222" }
279
+ allow(settings).to receive(:sl_user) { 'vlad1' }
280
+ allow(settings).to receive(:sl_api_key) { '22222' }
61
281
  allow(Capybara::Settings).to receive(:session_id) { '12341234' }
62
- stub_const("RestClient", double)
282
+ stub_const('RestClient', double)
63
283
  end
64
284
 
65
285
  it do
66
- expect(RestClient).to receive(:put).with("http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234", "{}", {content_type: :json, accept: :json}).once
286
+ expect(RestClient).to receive(:put).with('http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234', '{}', {content_type: :json, accept: :json}).once
67
287
  subject
68
288
  end
69
289
  end
70
290
 
71
- describe "#suite_name" do
291
+ describe '#suite_name' do
72
292
  subject { test_object.suite_name }
73
293
  before do
74
294
  allow(settings).to receive(:sl_browser_name) { 'ie' }
75
295
  end
76
296
 
77
- context "when environment present" do
297
+ context 'when environment present' do
78
298
  before { ENV['RAKE_TASK'] = rake_task }
79
- context "when includes rspec" do
299
+ context 'when includes rspec' do
80
300
  let(:rake_task) { 'rspec:bvt' }
81
- it { expect(subject).to eql("BVT IE")}
301
+ it { is_expected.to eql('BVT IE')}
82
302
  end
83
- context "when includes spec" do
303
+ context 'when includes spec' do
84
304
  let(:rake_task) { 'spec:bvt' }
85
- it { expect(subject).to eql("BVT IE")}
305
+ it { is_expected.to eql('BVT IE')}
86
306
  end
87
307
 
88
- context "when includes cucumber" do
308
+ context 'when includes cucumber' do
89
309
  let(:rake_task) { 'cucumber:bvt' }
90
- it { expect(subject).to eql("BVT IE")}
310
+ it { is_expected.to eql('BVT IE')}
91
311
  end
92
- context "when not includes rpsec and cucumber" do
312
+ context 'when not includes rpsec and cucumber' do
93
313
  let(:rake_task) { 'unknown' }
94
- it { expect(subject).to eql("UNKNOWN IE")}
314
+ it { is_expected.to eql('UNKNOWN IE')}
95
315
  end
96
- context "when includes only cucumber" do
316
+ context 'when includes only cucumber' do
97
317
  let(:rake_task) { 'cucumber' }
98
- it { expect(subject).to eql("ALL IE")}
318
+ it { is_expected.to eql('ALL IE')}
99
319
  end
100
320
  end
101
- context "when environment empty" do
321
+ context 'when environment empty' do
102
322
  before { ENV['RAKE_TASK'] = nil }
103
- it { expect(subject).to eql("CUSTOM IE")}
323
+ it { is_expected.to eql('CUSTOM IE')}
104
324
  end
105
325
  end
106
326
 
107
- describe ".suite_name" do
327
+ describe '.suite_name' do
108
328
  subject { Capybara::Settings.suite_name }
109
329
  before do
110
330
  allow(settings).to receive(:sl_browser_name) { 'ie' }
111
331
  end
112
332
 
113
- context "when environment present" do
333
+ context 'when environment present' do
114
334
  before { ENV['RAKE_TASK'] = rake_task }
115
- context "when includes rspec" do
335
+ context 'when includes rspec' do
116
336
  let(:rake_task) { 'rspec:bvt' }
117
- it { expect(subject).to eql("BVT IE")}
337
+ it { is_expected.to eql('BVT IE')}
118
338
  end
119
- context "when includes spec" do
339
+ context 'when includes spec' do
120
340
  let(:rake_task) { 'spec:bvt' }
121
- it { expect(subject).to eql("BVT IE")}
341
+ it { is_expected.to eql('BVT IE')}
122
342
  end
123
343
 
124
- context "when includes cucumber" do
344
+ context 'when includes cucumber' do
125
345
  let(:rake_task) { 'cucumber:bvt' }
126
- it { expect(subject).to eql("BVT IE")}
346
+ it { is_expected.to eql('BVT IE')}
127
347
  end
128
- context "when not includes rpsec and cucumber" do
348
+ context 'when not includes rpsec and cucumber' do
129
349
  let(:rake_task) { 'unknown' }
130
- it { expect(subject).to eql("UNKNOWN IE")}
350
+ it { is_expected.to eql('UNKNOWN IE')}
131
351
  end
132
- context "when includes only cucumber" do
352
+ context 'when includes only cucumber' do
133
353
  let(:rake_task) { 'cucumber' }
134
- it { expect(subject).to eql("ALL IE")}
354
+ it { is_expected.to eql('ALL IE')}
135
355
  end
136
356
  end
137
- context "when environment empty" do
357
+ context 'when environment empty' do
138
358
  before { ENV['RAKE_TASK'] = nil }
139
- it { expect(subject).to eql("CUSTOM IE")}
359
+ it { is_expected.to eql('CUSTOM IE')}
140
360
  end
141
361
  end
142
362
 
143
- describe "#session_id" do
363
+ describe '#session_id' do
144
364
  subject { test_object.session_id }
145
365
  before do
146
366
  browser = double
@@ -154,10 +374,10 @@ describe "Capybara::Settings" do
154
374
  allow(instance_variable).to receive(:session_id){ 'test'}
155
375
  end
156
376
 
157
- it { expect(subject).to eql('test') }
377
+ it { is_expected.to eql('test') }
158
378
  end
159
379
 
160
- describe ".session_id" do
380
+ describe '.session_id' do
161
381
  subject { Capybara::Settings.session_id }
162
382
  before do
163
383
  browser = double
@@ -171,6 +391,64 @@ describe "Capybara::Settings" do
171
391
  allow(instance_variable).to receive(:session_id){ 'test'}
172
392
  end
173
393
 
174
- it { expect(subject).to eql('test') }
394
+ it { is_expected.to eql('test') }
175
395
  end
176
- end
396
+
397
+ describe '#rake_task_name' do
398
+ subject { test_object.rake_task_name }
399
+ before { ENV['RAKE_TASK'] = rake_task }
400
+ context 'when includes rspec' do
401
+ let(:rake_task) { 'rspec:bvt' }
402
+ it { is_expected.to eq('BVT') }
403
+ end
404
+ context 'when includes cucumber' do
405
+ let(:rake_task) { 'cucumber:bvt' }
406
+ it { is_expected.to eq('BVT') }
407
+ end
408
+ context 'when includes spec' do
409
+ let(:rake_task) { 'spec:bvt' }
410
+ it { is_expected.to eq('BVT') }
411
+ end
412
+ context 'when includes only cucumber' do
413
+ let(:rake_task) { 'cucumber' }
414
+ it { is_expected.to eq('') }
415
+ end
416
+ context 'when includes unknown task' do
417
+ let(:rake_task) { 'unknown' }
418
+ it { is_expected.to eq('UNKNOWN') }
419
+ end
420
+ context 'when environment is empty' do
421
+ let(:rake_task) { nil }
422
+ it { is_expected.to eq('') }
423
+ end
424
+ end
425
+
426
+ describe '.rake_task_name' do
427
+ subject { Capybara::Settings.rake_task_name }
428
+ before { ENV['RAKE_TASK'] = rake_task }
429
+ context 'when includes rspec' do
430
+ let(:rake_task) { 'rspec:bvt' }
431
+ it { is_expected.to eq('BVT') }
432
+ end
433
+ context 'when includes cucumber' do
434
+ let(:rake_task) { 'cucumber:bvt' }
435
+ it { is_expected.to eq('BVT') }
436
+ end
437
+ context 'when includes spec' do
438
+ let(:rake_task) { 'spec:bvt' }
439
+ it { is_expected.to eq('BVT') }
440
+ end
441
+ context 'when includes only cucumber' do
442
+ let(:rake_task) { 'cucumber' }
443
+ it { is_expected.to eq('') }
444
+ end
445
+ context 'when includes unknown task' do
446
+ let(:rake_task) { 'unknown' }
447
+ it { is_expected.to eq('UNKNOWN') }
448
+ end
449
+ context 'when environment is empty' do
450
+ let(:rake_task) { nil }
451
+ it { is_expected.to eq('') }
452
+ end
453
+ end
454
+ end