howitzer 0.0.3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +32 -0
- data/GETTING_STARTED.md +529 -0
- data/Gemfile +4 -2
- data/LICENSE +2 -2
- data/README.md +57 -13
- data/Rakefile +9 -2
- data/bin/howitzer +79 -31
- data/generators/base_generator.rb +87 -0
- data/generators/config/config_generator.rb +16 -20
- data/generators/config/templates/default.yml +26 -7
- data/generators/cucumber/cucumber_generator.rb +20 -26
- data/generators/{tasks → cucumber}/templates/cucumber.rake +0 -0
- data/generators/{config → cucumber}/templates/cucumber.yml +0 -0
- data/generators/emails/emails_generator.rb +11 -18
- data/generators/emails/templates/example_email.rb +1 -0
- data/generators/pages/pages_generator.rb +16 -18
- data/generators/pages/templates/example_menu.rb +1 -0
- data/generators/pages/templates/example_page.rb +1 -1
- data/generators/root/root_generator.rb +18 -20
- data/generators/root/templates/.gitignore +2 -1
- data/generators/root/templates/Gemfile +3 -2
- data/generators/root/templates/Rakefile +10 -0
- data/generators/root/templates/boot.rb +3 -9
- data/generators/rspec/rspec_generator.rb +23 -0
- data/generators/rspec/templates/example_spec.rb +7 -0
- data/generators/rspec/templates/rspec.rake +34 -0
- data/generators/rspec/templates/spec_helper.rb +56 -0
- data/generators/tasks/tasks_generator.rb +11 -17
- data/generators/tasks/templates/common.rake +15 -0
- data/howitzer.gemspec +13 -2
- data/lib/howitzer.rb +1 -0
- data/lib/howitzer/helpers.rb +87 -2
- data/lib/howitzer/init.rb +0 -1
- data/lib/howitzer/patches/rawler_patched.rb +86 -0
- data/lib/howitzer/settings.rb +27 -0
- data/lib/howitzer/utils.rb +3 -12
- data/lib/howitzer/utils/capybara_patched.rb +3 -2
- data/lib/howitzer/utils/capybara_settings.rb +158 -24
- data/lib/howitzer/utils/data_generator/data_storage.rb +35 -1
- data/lib/howitzer/utils/data_generator/gen.rb +45 -3
- data/lib/howitzer/utils/email/email.rb +44 -5
- data/lib/howitzer/utils/email/mail_client.rb +28 -22
- data/lib/howitzer/utils/email/mailgun_helper.rb +30 -4
- data/lib/howitzer/utils/locator_store.rb +111 -19
- data/lib/howitzer/utils/log.rb +137 -0
- data/lib/howitzer/utils/page_validator.rb +86 -0
- data/lib/howitzer/vendor/firebug-1.12.1-fx.xpi +0 -0
- data/lib/howitzer/vendor/firepath-0.9.7-fx.xpi +0 -0
- data/lib/howitzer/version.rb +2 -2
- data/lib/howitzer/web_page.rb +159 -19
- data/spec/active_resource.rb +0 -0
- data/spec/config/custom.yml +1 -0
- data/spec/config/default.yml +28 -0
- data/spec/spec_helper.rb +46 -1
- data/spec/support/boot_helper.rb +15 -0
- data/spec/support/generator_helper.rb +13 -0
- data/spec/support/logger_helper.rb +12 -0
- data/spec/unit/bin/howitzer_spec.rb +175 -0
- data/spec/unit/generators/generators_spec.rb +175 -0
- data/spec/unit/lib/capybara_settings_spec.rb +170 -0
- data/spec/unit/lib/helpers_spec.rb +619 -0
- data/spec/unit/lib/init_spec.rb +14 -0
- data/spec/unit/lib/settings_spec.rb +17 -0
- data/spec/unit/lib/utils/data_generator/data_storage_spec.rb +62 -0
- data/spec/unit/lib/utils/data_generator/gen_spec.rb +151 -0
- data/spec/unit/lib/utils/email/email_spec.rb +75 -0
- data/spec/unit/lib/utils/email/mail_client_spec.rb +115 -0
- data/spec/unit/lib/utils/email/mailgun_helper_spec.rb +95 -0
- data/spec/unit/lib/utils/locator_store_spec.rb +122 -0
- data/spec/unit/lib/utils/log_spec.rb +107 -0
- data/spec/unit/lib/utils/page_validator_spec.rb +142 -0
- data/spec/unit/lib/web_page_spec.rb +250 -0
- data/spec/unit/version_spec.rb +8 -0
- metadata +215 -15
- data/Gemfile.lock +0 -103
- data/History.md +0 -20
- data/lib/howitzer/utils/logger.rb +0 -108
- data/spec/howitzer/version_spec.rb +0 -8
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require "#{lib_path}/howitzer/utils/capybara_settings"
|
4
|
+
|
5
|
+
describe "CapybaraSettings" do
|
6
|
+
let(:log) { double("log") }
|
7
|
+
let(:test_object) { double("test_object").extend(CapybaraSettings) }
|
8
|
+
before do
|
9
|
+
allow(log).to receive(:error).and_return( true )
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#sauce_resource_path" do
|
13
|
+
subject { test_object.sauce_resource_path(name) }
|
14
|
+
let (:name) { "test_name" }
|
15
|
+
before do
|
16
|
+
allow(settings).to receive(:sl_user) { "vlad" }
|
17
|
+
allow(settings).to receive(:sl_api_key) { "11111" }
|
18
|
+
allow(test_object).to receive(:session_id) { '12341234' }
|
19
|
+
end
|
20
|
+
|
21
|
+
it { expect(subject).to eql("https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name") }
|
22
|
+
end
|
23
|
+
describe ".sauce_resource_path" do
|
24
|
+
subject { CapybaraSettings.sauce_resource_path(name) }
|
25
|
+
let (:name) { "test_name" }
|
26
|
+
before do
|
27
|
+
allow(settings).to receive(:sl_user) { "vlad" }
|
28
|
+
allow(settings).to receive(:sl_api_key) { "11111" }
|
29
|
+
allow(CapybaraSettings).to receive(:session_id) { '12341234' }
|
30
|
+
end
|
31
|
+
|
32
|
+
it { expect(subject).to eql("https://vlad:11111@saucelabs.com/rest/vlad/jobs/12341234/results/test_name") }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#update_sauce_job_status" do
|
36
|
+
subject { test_object.update_sauce_job_status }
|
37
|
+
before do
|
38
|
+
allow(settings).to receive(:sl_user) { "vlad1" }
|
39
|
+
allow(settings).to receive(:sl_api_key) { "22222" }
|
40
|
+
allow(test_object).to receive(:session_id) { '12341234' }
|
41
|
+
stub_const("RestClient", double)
|
42
|
+
end
|
43
|
+
|
44
|
+
it do
|
45
|
+
expect(RestClient).to receive(:put).with("http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234", "{}", {content_type: :json, accept: :json}).once
|
46
|
+
subject
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".update_sauce_resource_path" do
|
51
|
+
subject { CapybaraSettings.update_sauce_job_status }
|
52
|
+
before do
|
53
|
+
allow(settings).to receive(:sl_user) { "vlad1" }
|
54
|
+
allow(settings).to receive(:sl_api_key) { "22222" }
|
55
|
+
allow(CapybaraSettings).to receive(:session_id) { '12341234' }
|
56
|
+
stub_const("RestClient", double)
|
57
|
+
end
|
58
|
+
|
59
|
+
it do
|
60
|
+
expect(RestClient).to receive(:put).with("http://vlad1:22222@saucelabs.com/rest/v1/vlad1/jobs/12341234", "{}", {content_type: :json, accept: :json}).once
|
61
|
+
subject
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#suite_name" do
|
66
|
+
subject { test_object.suite_name }
|
67
|
+
before do
|
68
|
+
allow(settings).to receive(:sl_browser_name) { 'ie' }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when environment present" do
|
72
|
+
before { ENV['RAKE_TASK'] = rake_task }
|
73
|
+
context "when includes rspec" do
|
74
|
+
let(:rake_task) { 'rspec:bvt' }
|
75
|
+
it { expect(subject).to eql("BVT IE")}
|
76
|
+
end
|
77
|
+
context "when includes spec" do
|
78
|
+
let(:rake_task) { 'spec:bvt' }
|
79
|
+
it { expect(subject).to eql("BVT IE")}
|
80
|
+
end
|
81
|
+
|
82
|
+
context "when includes cucumber" do
|
83
|
+
let(:rake_task) { 'cucumber:bvt' }
|
84
|
+
it { expect(subject).to eql("BVT IE")}
|
85
|
+
end
|
86
|
+
context "when not includes rpsec and cucumber" do
|
87
|
+
let(:rake_task) { 'unknown' }
|
88
|
+
it { expect(subject).to eql("UNKNOWN IE")}
|
89
|
+
end
|
90
|
+
context "when includes only cucumber" do
|
91
|
+
let(:rake_task) { 'cucumber' }
|
92
|
+
it { expect(subject).to eql("ALL IE")}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
context "when environment empty" do
|
96
|
+
before { ENV['RAKE_TASK'] = nil }
|
97
|
+
it { expect(subject).to eql("CUSTOM IE")}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe ".suite_name" do
|
102
|
+
subject { CapybaraSettings.suite_name }
|
103
|
+
before do
|
104
|
+
allow(settings).to receive(:sl_browser_name) { 'ie' }
|
105
|
+
end
|
106
|
+
|
107
|
+
context "when environment present" do
|
108
|
+
before { ENV['RAKE_TASK'] = rake_task }
|
109
|
+
context "when includes rspec" do
|
110
|
+
let(:rake_task) { 'rspec:bvt' }
|
111
|
+
it { expect(subject).to eql("BVT IE")}
|
112
|
+
end
|
113
|
+
context "when includes spec" do
|
114
|
+
let(:rake_task) { 'spec:bvt' }
|
115
|
+
it { expect(subject).to eql("BVT IE")}
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when includes cucumber" do
|
119
|
+
let(:rake_task) { 'cucumber:bvt' }
|
120
|
+
it { expect(subject).to eql("BVT IE")}
|
121
|
+
end
|
122
|
+
context "when not includes rpsec and cucumber" do
|
123
|
+
let(:rake_task) { 'unknown' }
|
124
|
+
it { expect(subject).to eql("UNKNOWN IE")}
|
125
|
+
end
|
126
|
+
context "when includes only cucumber" do
|
127
|
+
let(:rake_task) { 'cucumber' }
|
128
|
+
it { expect(subject).to eql("ALL IE")}
|
129
|
+
end
|
130
|
+
end
|
131
|
+
context "when environment empty" do
|
132
|
+
before { ENV['RAKE_TASK'] = nil }
|
133
|
+
it { expect(subject).to eql("CUSTOM IE")}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "#session_id" do
|
138
|
+
subject { test_object.session_id }
|
139
|
+
before do
|
140
|
+
browser = double
|
141
|
+
current_session = double
|
142
|
+
driver = double
|
143
|
+
instance_variable = double
|
144
|
+
allow(Capybara).to receive(:current_session){current_session}
|
145
|
+
allow(current_session).to receive(:driver){driver}
|
146
|
+
allow(driver).to receive(:browser){browser}
|
147
|
+
allow(browser).to receive(:instance_variable_get).with(:@bridge){ instance_variable }
|
148
|
+
allow(instance_variable).to receive(:session_id){ 'test'}
|
149
|
+
end
|
150
|
+
|
151
|
+
it { expect(subject).to eql('test') }
|
152
|
+
end
|
153
|
+
|
154
|
+
describe ".session_id" do
|
155
|
+
subject { CapybaraSettings.session_id }
|
156
|
+
before do
|
157
|
+
browser = double
|
158
|
+
current_session = double
|
159
|
+
driver = double
|
160
|
+
instance_variable = double
|
161
|
+
allow(Capybara).to receive(:current_session){current_session}
|
162
|
+
allow(current_session).to receive(:driver){driver}
|
163
|
+
allow(driver).to receive(:browser){browser}
|
164
|
+
allow(browser).to receive(:instance_variable_get).with(:@bridge){ instance_variable }
|
165
|
+
allow(instance_variable).to receive(:session_id){ 'test'}
|
166
|
+
end
|
167
|
+
|
168
|
+
it { expect(subject).to eql('test') }
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,619 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require "#{lib_path}/howitzer/helpers"
|
4
|
+
|
5
|
+
describe "Helpers" do
|
6
|
+
let(:settings) { double("settings")}
|
7
|
+
|
8
|
+
describe "#sauce_driver?" do
|
9
|
+
subject { sauce_driver? }
|
10
|
+
before { allow(settings).to receive(:driver) { driver_setting } }
|
11
|
+
context "when :sauce" do
|
12
|
+
let(:driver_setting) {:sauce}
|
13
|
+
it{ expect(subject).to be_true }
|
14
|
+
end
|
15
|
+
context "when not :sauce" do
|
16
|
+
let(:driver_setting) {:phantomjs}
|
17
|
+
it{ expect(subject).to be_false }
|
18
|
+
end
|
19
|
+
context "when driver specified as String" do
|
20
|
+
let(:driver_setting) {"sauce"}
|
21
|
+
it{ expect(subject).to be_true }
|
22
|
+
end
|
23
|
+
context "when driver is not specified" do
|
24
|
+
let(:driver_setting) { nil }
|
25
|
+
it { expect {subject}.to raise_error(DriverNotSpecified, "Please check your settings") }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#testingbot_driver?" do
|
30
|
+
subject { testingbot_driver? }
|
31
|
+
before { allow(settings).to receive(:driver) { driver_setting } }
|
32
|
+
context "when :testingbot" do
|
33
|
+
let(:driver_setting) {:testingbot}
|
34
|
+
it{ expect(subject).to be_true }
|
35
|
+
end
|
36
|
+
context "when not :testingbot" do
|
37
|
+
let(:driver_setting) {:phantomjs}
|
38
|
+
it{ expect(subject).to be_false }
|
39
|
+
end
|
40
|
+
context "when driver specified as String" do
|
41
|
+
let(:driver_setting) {"testingbot"}
|
42
|
+
it{ expect(subject).to be_true }
|
43
|
+
end
|
44
|
+
context "when driver is not specified" do
|
45
|
+
let(:driver_setting) { nil }
|
46
|
+
it { expect {subject}.to raise_error(DriverNotSpecified, "Please check your settings") }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#selenium_driver?" do
|
51
|
+
subject { selenium_driver? }
|
52
|
+
before { allow(settings).to receive(:driver) { driver_setting } }
|
53
|
+
context "when :selenium" do
|
54
|
+
let(:driver_setting) {:selenium}
|
55
|
+
it{ expect(subject).to be_true }
|
56
|
+
end
|
57
|
+
context "when not :selenium" do
|
58
|
+
let(:driver_setting) {:phantomjs}
|
59
|
+
it{ expect(subject).to be_false }
|
60
|
+
end
|
61
|
+
context "when driver specified as String" do
|
62
|
+
let(:driver_setting) {"selenium"}
|
63
|
+
it{ expect(subject).to be_true }
|
64
|
+
end
|
65
|
+
context "when driver is not specified" do
|
66
|
+
let(:driver_setting) { nil }
|
67
|
+
it { expect {subject}.to raise_error(DriverNotSpecified, "Please check your settings") }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#ie_browser?" do
|
72
|
+
subject { ie_browser? }
|
73
|
+
before { allow(self).to receive(:sauce_driver?) {sauce_driver} }
|
74
|
+
before { allow(self).to receive(:testingbot_driver?) {testingbot_driver} }
|
75
|
+
context "when sauce_driver? is TRUE" do
|
76
|
+
let(:sauce_driver) { true }
|
77
|
+
let(:testingbot_driver) { false }
|
78
|
+
context "settings.sl_browser_name = :ie" do
|
79
|
+
before { allow(settings).to receive(:sl_browser_name) { :ie } }
|
80
|
+
it { expect(subject).to be_true }
|
81
|
+
end
|
82
|
+
context "settings.sl_browser_name = :iexplore" do
|
83
|
+
before { allow(settings).to receive(:sl_browser_name) { :iexplore } }
|
84
|
+
it { expect(subject).to be_true }
|
85
|
+
end
|
86
|
+
context "settings.sl_browser_name = :chrome" do
|
87
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
88
|
+
it { expect(subject).to be_false }
|
89
|
+
end
|
90
|
+
context "settings.sl_browser_name is not specified" do
|
91
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
92
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
context "when sauce_driver? is FALSE" do
|
96
|
+
let(:sauce_driver) { false }
|
97
|
+
let(:testingbot_driver) { false }
|
98
|
+
before { allow(self).to receive(:selenium_driver?){ selenium_driver} }
|
99
|
+
context "when selenium_driver? is TRUE" do
|
100
|
+
let(:selenium_driver) { true }
|
101
|
+
context "settings.sel_browser = :ie" do
|
102
|
+
before { allow(settings).to receive(:sel_browser) { :ie } }
|
103
|
+
it { expect(subject).to be_true }
|
104
|
+
end
|
105
|
+
context "settings.sel_browser = :iexplore" do
|
106
|
+
before { allow(settings).to receive(:sel_browser) { :iexplore } }
|
107
|
+
it { expect(subject).to be_true }
|
108
|
+
end
|
109
|
+
context "settings.sel_browser = :chrome" do
|
110
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
111
|
+
it { expect(subject).to be_false }
|
112
|
+
end
|
113
|
+
context "settings.sel_browser is not specified" do
|
114
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
115
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
context "when selenium_driver? is FALSE" do
|
119
|
+
let(:selenium_driver) { false }
|
120
|
+
it { expect(subject).to be_false }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context "when testingbot_driver? is TRUE" do
|
124
|
+
let(:testingbot_driver) { true }
|
125
|
+
let(:sauce_driver) { false }
|
126
|
+
before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }
|
127
|
+
context "settings.sel_browser = :ie" do
|
128
|
+
before do
|
129
|
+
allow(settings).to receive(:tb_browser_name) { :ie }
|
130
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
131
|
+
end
|
132
|
+
it { expect(subject).to be_true }
|
133
|
+
end
|
134
|
+
context "settings.tb_browser_name = :iexplore" do
|
135
|
+
before do
|
136
|
+
allow(settings).to receive(:tb_browser_name) { :iexplore }
|
137
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
138
|
+
end
|
139
|
+
it { expect(subject).to be_true }
|
140
|
+
end
|
141
|
+
context "settings.tb_browser_name = :firefox" do
|
142
|
+
before do
|
143
|
+
allow(settings).to receive(:tb_browser_name) { :firefox }
|
144
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
145
|
+
end
|
146
|
+
it { expect(subject).to be_false }
|
147
|
+
end
|
148
|
+
context "settings.tb_browser_name is not specified" do
|
149
|
+
before { allow(settings).to receive(:tb_browser_name) { nil } }
|
150
|
+
it { expect{subject}.to raise_error(TbBrowserNameNotSpecified, "Please check your settings") }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
context "when testingbot_driver? is FALSE" do
|
154
|
+
before { allow(self).to receive(:sauce_driver?) { sauce_driver } }
|
155
|
+
context "when sauce_driver? is TRUE" do
|
156
|
+
let(:testingbot_driver) { false }
|
157
|
+
let(:sauce_driver) { true }
|
158
|
+
context "settings.sl_browser_name = :ie" do
|
159
|
+
before { allow(settings).to receive(:sl_browser_name) { :ie } }
|
160
|
+
it { expect(subject).to be_true }
|
161
|
+
end
|
162
|
+
context "settings.sl_browser_name = :iexplore" do
|
163
|
+
before { allow(settings).to receive(:sl_browser_name) { :iexplore } }
|
164
|
+
it { expect(subject).to be_true }
|
165
|
+
end
|
166
|
+
context "settings.sl_browser_name = :chrome" do
|
167
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
168
|
+
it { expect(subject).to be_false }
|
169
|
+
end
|
170
|
+
context "settings.sl_browser_name is not specified" do
|
171
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
172
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
context "when selenium_driver? is TRUE" do
|
177
|
+
let(:sauce_driver) { false }
|
178
|
+
let(:testingbot_driver) { false }
|
179
|
+
before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
|
180
|
+
context "when selenium_driver? is TRUE" do
|
181
|
+
let(:selenium_driver) { true }
|
182
|
+
context "settings.sel_browser = :ie" do
|
183
|
+
before { allow(settings).to receive(:sel_browser) { :ie } }
|
184
|
+
it { expect(subject).to be_true }
|
185
|
+
end
|
186
|
+
context "settings.sel_browser = :iexplore" do
|
187
|
+
before { allow(settings).to receive(:sel_browser) { :iexplore } }
|
188
|
+
it { expect(subject).to be_true }
|
189
|
+
end
|
190
|
+
context "settings.sel_browser = :chrome" do
|
191
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
192
|
+
it { expect(subject).to be_false }
|
193
|
+
end
|
194
|
+
context "settings.sel_browser is not specified" do
|
195
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
196
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
context "when selenium_driver? is FALSE" do
|
201
|
+
before { allow(self).to receive(:selenium_driver?) { false } }
|
202
|
+
context "when testingbot_driver? is TRUE" do
|
203
|
+
let(:testingbot_driver) { true }
|
204
|
+
let(:sauce_driver) { false }
|
205
|
+
before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }
|
206
|
+
context "settings.sl_browser_name = :ie" do
|
207
|
+
before do
|
208
|
+
allow(settings).to receive(:tb_browser_name) { :ie }
|
209
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
210
|
+
end
|
211
|
+
it { expect(subject).to be_true }
|
212
|
+
end
|
213
|
+
context "settings.tb_browser_name = :iexplore" do
|
214
|
+
before do
|
215
|
+
allow(settings).to receive(:tb_browser_name) { :iexplore }
|
216
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
217
|
+
end
|
218
|
+
it { expect(subject).to be_true }
|
219
|
+
end
|
220
|
+
context "settings.tb_browser_name = :firefox" do
|
221
|
+
before do
|
222
|
+
allow(settings).to receive(:tb_browser_name) { :firefox }
|
223
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
224
|
+
end
|
225
|
+
it { expect(subject).to be_false }
|
226
|
+
end
|
227
|
+
context "settings.tb_browser_name is not specified" do
|
228
|
+
before { allow(settings).to receive(:tb_browser_name) { nil } }
|
229
|
+
it { expect{subject}.to raise_error(TbBrowserNameNotSpecified, "Please check your settings") }
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
describe "#ff_browser?" do
|
235
|
+
subject { ff_browser? }
|
236
|
+
before { allow(self).to receive(:sauce_driver?){ sauce_driver} }
|
237
|
+
before { allow(self).to receive(:testingbot_driver?){ testingbot_driver} }
|
238
|
+
context "when sauce_driver? is TRUE" do
|
239
|
+
let(:sauce_driver) { true }
|
240
|
+
let(:testingbot_driver) { false }
|
241
|
+
context "settings.sl_browser_name = :ff" do
|
242
|
+
before { allow(settings).to receive(:sl_browser_name) { :ff } }
|
243
|
+
it { expect(subject).to be_true }
|
244
|
+
end
|
245
|
+
context "settings.sl_browser_name = :firefox" do
|
246
|
+
before { allow(settings).to receive(:sl_browser_name) { :firefox } }
|
247
|
+
it { expect(subject).to be_true }
|
248
|
+
end
|
249
|
+
context "settings.sl_browser_name = :chrome" do
|
250
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
251
|
+
it { expect(subject).to be_false }
|
252
|
+
end
|
253
|
+
context "settings.sl_browser_name is not specified" do
|
254
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
255
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
256
|
+
end
|
257
|
+
end
|
258
|
+
context "when sauce_driver? is FALSE" do
|
259
|
+
let(:testingbot_driver) { false }
|
260
|
+
let(:sauce_driver) { false }
|
261
|
+
before { allow(self).to receive(:selenium_driver?){ selenium_driver} }
|
262
|
+
context "when selenium_driver? is TRUE" do
|
263
|
+
let(:selenium_driver) { true }
|
264
|
+
context "settings.sel_browser = :ff" do
|
265
|
+
before { allow(settings).to receive(:sel_browser) { :ff } }
|
266
|
+
it { expect(subject).to be_true }
|
267
|
+
end
|
268
|
+
context "settings.sel_browser = :firefox" do
|
269
|
+
before { allow(settings).to receive(:sel_browser) { :firefox } }
|
270
|
+
it { expect(subject).to be_true }
|
271
|
+
end
|
272
|
+
context "settings.sel_browser = :chrome" do
|
273
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
274
|
+
it { expect(subject).to be_false }
|
275
|
+
end
|
276
|
+
context "settings.sel_browser is not specified" do
|
277
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
278
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
279
|
+
end
|
280
|
+
end
|
281
|
+
context "when selenium_driver? is FALSE" do
|
282
|
+
let(:selenium_driver) { false }
|
283
|
+
it { expect(subject).to be_false }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
context "when testingbot_driver? is TRUE" do
|
287
|
+
let(:testingbot_driver) { true }
|
288
|
+
let(:sauce_driver) { false }
|
289
|
+
before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }
|
290
|
+
context "settings.tb_browser_name = :ff" do
|
291
|
+
before do
|
292
|
+
allow(settings).to receive(:tb_browser_name) { :ff }
|
293
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
294
|
+
end
|
295
|
+
it { expect(subject).to be_true }
|
296
|
+
end
|
297
|
+
context "settings.tb_browser_name = :firefox" do
|
298
|
+
before do
|
299
|
+
allow(settings).to receive(:tb_browser_name) { :firefox }
|
300
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
301
|
+
end
|
302
|
+
it { expect(subject).to be_true }
|
303
|
+
end
|
304
|
+
context "settings.tb_browser_name = :iexplore" do
|
305
|
+
before do
|
306
|
+
allow(settings).to receive(:tb_browser_name) { :iexplore }
|
307
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
308
|
+
end
|
309
|
+
it { expect(subject).to be_false }
|
310
|
+
end
|
311
|
+
context "settings.tb_browser_name is not specified" do
|
312
|
+
before { allow(settings).to receive(:tb_browser_name) { nil } }
|
313
|
+
it { expect{subject}.to raise_error(TbBrowserNameNotSpecified, "Please check your settings") }
|
314
|
+
end
|
315
|
+
end
|
316
|
+
context "when testingbot_driver? is FALSE" do
|
317
|
+
before { allow(self).to receive(:sauce_driver?) { sauce_driver } }
|
318
|
+
context "when sauce_driver? is TRUE" do
|
319
|
+
let(:testingbot_driver) { false }
|
320
|
+
let(:sauce_driver) { true }
|
321
|
+
context "settings.sl_browser_name = :ff" do
|
322
|
+
before { allow(settings).to receive(:sl_browser_name) { :ff } }
|
323
|
+
it { expect(subject).to be_true }
|
324
|
+
end
|
325
|
+
context "settings.sl_browser_name = :firefox" do
|
326
|
+
before { allow(settings).to receive(:sl_browser_name) { :firefox } }
|
327
|
+
it { expect(subject).to be_true }
|
328
|
+
end
|
329
|
+
context "settings.sl_browser_name = :chrome" do
|
330
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
331
|
+
it { expect(subject).to be_false }
|
332
|
+
end
|
333
|
+
context "settings.sl_browser_name is not specified" do
|
334
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
335
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
context "when selenium_driver? is TRUE" do
|
340
|
+
let(:sauce_driver) { false }
|
341
|
+
let(:testingbot_driver) { false }
|
342
|
+
before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
|
343
|
+
context "when selenium_driver? is TRUE" do
|
344
|
+
let(:selenium_driver) { true }
|
345
|
+
context "settings.sel_browser = :ff" do
|
346
|
+
before { allow(settings).to receive(:sel_browser) { :ff } }
|
347
|
+
it { expect(subject).to be_true }
|
348
|
+
end
|
349
|
+
context "settings.sel_browser = :firefox" do
|
350
|
+
before { allow(settings).to receive(:sel_browser) { :firefox } }
|
351
|
+
it { expect(subject).to be_true }
|
352
|
+
end
|
353
|
+
context "settings.sel_browser = :chrome" do
|
354
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
355
|
+
it { expect(subject).to be_false }
|
356
|
+
end
|
357
|
+
context "settings.sel_browser is not specified" do
|
358
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
359
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
context "when selenium_driver? is FALSE" do
|
364
|
+
before { allow(self).to receive(:selenium_driver?) { false } }
|
365
|
+
context "when testingbot_driver? is TRUE" do
|
366
|
+
let(:testingbot_driver) { true }
|
367
|
+
let(:sauce_driver) { false }
|
368
|
+
before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }
|
369
|
+
context "settings.tb_browser_name = :firefox" do
|
370
|
+
before do
|
371
|
+
allow(settings).to receive(:tb_browser_name) { :firefox }
|
372
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
373
|
+
end
|
374
|
+
it { expect(subject).to be_true }
|
375
|
+
end
|
376
|
+
context "settings.tb_browser_name = :ff" do
|
377
|
+
before do
|
378
|
+
allow(settings).to receive(:tb_browser_name) { :ff }
|
379
|
+
allow(settings).to receive(:tb_browser_version) { 8 }
|
380
|
+
end
|
381
|
+
it { expect(subject).to be_true }
|
382
|
+
end
|
383
|
+
context "settings.tb_browser_name = :iexplore" do
|
384
|
+
before do
|
385
|
+
allow(settings).to receive(:tb_browser_name) { :iexplore }
|
386
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
387
|
+
end
|
388
|
+
it { expect(subject).to be_false }
|
389
|
+
end
|
390
|
+
context "settings.tb_browser_name is not specified" do
|
391
|
+
before { allow(settings).to receive(:tb_browser_name) { nil } }
|
392
|
+
it { expect{subject}.to raise_error(TbBrowserNameNotSpecified, "Please check your settings") }
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
end
|
397
|
+
end
|
398
|
+
describe "#chrome_browser?" do
|
399
|
+
subject { chrome_browser? }
|
400
|
+
before { allow(self).to receive(:sauce_driver?){ sauce_driver} }
|
401
|
+
before { allow(self).to receive(:testingbot_driver?){ testingbot_driver} }
|
402
|
+
context "when sauce_driver? is TRUE" do
|
403
|
+
let(:sauce_driver) { true }
|
404
|
+
let(:testingbot_driver) { true }
|
405
|
+
context "settings.sl_browser_name = :chrome" do
|
406
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
407
|
+
it { expect(subject).to be_true }
|
408
|
+
end
|
409
|
+
context "settings.sl_browser_name = :firefox" do
|
410
|
+
before { allow(settings).to receive(:sl_browser_name) { :firefox } }
|
411
|
+
it { expect(subject).to be_false }
|
412
|
+
end
|
413
|
+
context "settings.sl_browser_name is not specified" do
|
414
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
415
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
416
|
+
end
|
417
|
+
end
|
418
|
+
context "when sauce_driver? is FALSE" do
|
419
|
+
let(:sauce_driver) { false }
|
420
|
+
let(:testingbot_driver) { false }
|
421
|
+
before { allow(self).to receive(:selenium_driver?){ selenium_driver} }
|
422
|
+
context "when selenium_driver? is TRUE" do
|
423
|
+
let(:selenium_driver) { true }
|
424
|
+
context "settings.sel_browser = :chrome" do
|
425
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
426
|
+
it { expect(subject).to be_true }
|
427
|
+
end
|
428
|
+
context "settings.sel_browser = :firefox" do
|
429
|
+
before { allow(settings).to receive(:sel_browser) { :firefox } }
|
430
|
+
it { expect(subject).to be_false }
|
431
|
+
end
|
432
|
+
context "settings.sel_browser is not specified" do
|
433
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
434
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
435
|
+
end
|
436
|
+
end
|
437
|
+
context "when selenium_driver? is FALSE" do
|
438
|
+
let(:selenium_driver) { false }
|
439
|
+
it { expect(subject).to be_false }
|
440
|
+
end
|
441
|
+
end
|
442
|
+
context "when testingbot_driver? is TRUE" do
|
443
|
+
let(:testingbot_driver) { true }
|
444
|
+
let(:sauce_driver) { false }
|
445
|
+
before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }
|
446
|
+
context "settings.tb_browser_name = :chrome" do
|
447
|
+
before do
|
448
|
+
allow(settings).to receive(:tb_browser_name) { :chrome }
|
449
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
450
|
+
end
|
451
|
+
it { expect(subject).to be_true }
|
452
|
+
end
|
453
|
+
context "settings.tb_browser_name = :iexplore" do
|
454
|
+
before do
|
455
|
+
allow(settings).to receive(:tb_browser_name) { :iexplore }
|
456
|
+
allow(settings).to receive(:tb_browser_version) { 9 }
|
457
|
+
end
|
458
|
+
it { expect(subject).to be_false }
|
459
|
+
end
|
460
|
+
context "settings.tb_browser_name is not specified" do
|
461
|
+
before { allow(settings).to receive(:tb_browser_name) { nil } }
|
462
|
+
it { expect{subject}.to raise_error(TbBrowserNameNotSpecified, "Please check your settings") }
|
463
|
+
end
|
464
|
+
end
|
465
|
+
context "when testingbot_driver? is FALSE" do
|
466
|
+
before { allow(self).to receive(:sauce_driver?) { sauce_driver } }
|
467
|
+
context "when sauce_driver? is TRUE" do
|
468
|
+
let(:testingbot_driver) { false }
|
469
|
+
let(:sauce_driver) { true }
|
470
|
+
context "settings.sl_browser_name = :chrome" do
|
471
|
+
before { allow(settings).to receive(:sl_browser_name) { :chrome } }
|
472
|
+
it { expect(subject).to be_true }
|
473
|
+
end
|
474
|
+
context "settings.sl_browser_name = :firefox" do
|
475
|
+
before { allow(settings).to receive(:sl_browser_name) { :firefox } }
|
476
|
+
it { expect(subject).to be_false }
|
477
|
+
end
|
478
|
+
context "settings.sl_browser_name is not specified" do
|
479
|
+
before { allow(settings).to receive(:sl_browser_name) { nil } }
|
480
|
+
it { expect {subject}.to raise_error(SlBrowserNameNotSpecified, "Please check your settings") }
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
context "when selenium_driver? is TRUE" do
|
486
|
+
let(:sauce_driver) { false }
|
487
|
+
let(:testingbot_driver) { false }
|
488
|
+
before { allow(self).to receive(:selenium_driver?) { selenium_driver } }
|
489
|
+
context "when selenium_driver? is TRUE" do
|
490
|
+
let(:selenium_driver) { true }
|
491
|
+
context "settings.sel_browser = :chrome" do
|
492
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
493
|
+
it { expect(subject).to be_true }
|
494
|
+
end
|
495
|
+
context "settings.sel_browser = :firefox" do
|
496
|
+
before { allow(settings).to receive(:sel_browser) { :firefox } }
|
497
|
+
it { expect(subject).to be_false }
|
498
|
+
end
|
499
|
+
context "settings.sel_browser is not specified" do
|
500
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
501
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
end
|
506
|
+
context "when selenium_driver? is FALSE" do
|
507
|
+
let(:sauce_driver) { false }
|
508
|
+
let(:testingbot_driver) { false }
|
509
|
+
before { allow(self).to receive(:selenium_driver?){ selenium_driver} }
|
510
|
+
context "when selenium_driver? is TRUE" do
|
511
|
+
let(:selenium_driver) { true }
|
512
|
+
context "settings.sel_browser = :chrome" do
|
513
|
+
before { allow(settings).to receive(:sel_browser) { :chrome } }
|
514
|
+
it { expect(subject).to be_true }
|
515
|
+
end
|
516
|
+
context "settings.sel_browser = :firefox" do
|
517
|
+
before { allow(settings).to receive(:sel_browser) { :firefox } }
|
518
|
+
it { expect(subject).to be_false }
|
519
|
+
end
|
520
|
+
context "settings.sel_browser is not specified" do
|
521
|
+
before { allow(settings).to receive(:sel_browser) { nil } }
|
522
|
+
it { expect {subject}.to raise_error(SelBrowserNotSpecified, "Please check your settings") }
|
523
|
+
end
|
524
|
+
end
|
525
|
+
context "when selenium_driver? is FALSE" do
|
526
|
+
let(:selenium_driver) { false }
|
527
|
+
it { expect(subject).to be_false }
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
describe "#app_url" do
|
532
|
+
subject { app_url }
|
533
|
+
before do
|
534
|
+
allow(settings).to receive(:app_base_auth_login) { app_base_auth_login_setting }
|
535
|
+
allow(settings).to receive(:app_base_auth_pass) { app_base_auth_pass_setting }
|
536
|
+
allow(settings).to receive(:app_protocol) { app_protocol_setting }
|
537
|
+
allow(settings).to receive(:app_host) { app_host_setting }
|
538
|
+
end
|
539
|
+
let(:app_protocol_setting) { nil }
|
540
|
+
let(:app_host_setting) { "redmine.strongqa.com" }
|
541
|
+
context "when login and password present" do
|
542
|
+
let(:app_base_auth_login_setting) { "alex" }
|
543
|
+
let(:app_base_auth_pass_setting) { "pa$$w0rd" }
|
544
|
+
it{ expect(subject).to eq("http://alex:pa$$w0rd@redmine.strongqa.com") }
|
545
|
+
end
|
546
|
+
context "when login and password blank" do
|
547
|
+
let(:app_base_auth_login_setting) { "" }
|
548
|
+
let(:app_base_auth_pass_setting) { "" }
|
549
|
+
it{ expect(subject).to eq("http://redmine.strongqa.com") }
|
550
|
+
end
|
551
|
+
end
|
552
|
+
describe "#app_base_url" do
|
553
|
+
subject { app_base_url(prefix) }
|
554
|
+
before do
|
555
|
+
allow(settings).to receive(:app_protocol) { app_protocol_setting }
|
556
|
+
allow(settings).to receive(:app_host) { app_host_setting }
|
557
|
+
end
|
558
|
+
let(:app_protocol_setting) { nil }
|
559
|
+
let(:app_host_setting) { "redmine.strongqa.com" }
|
560
|
+
context "when login and password present" do
|
561
|
+
let(:prefix) { "alex:pa$$w0rd@" }
|
562
|
+
it{ expect(subject).to eq("http://alex:pa$$w0rd@redmine.strongqa.com") }
|
563
|
+
end
|
564
|
+
context "when login and password blank" do
|
565
|
+
let(:prefix) { nil }
|
566
|
+
it{ expect(subject).to eq("http://redmine.strongqa.com") }
|
567
|
+
end
|
568
|
+
end
|
569
|
+
describe "#duration" do
|
570
|
+
context "when more than hour" do
|
571
|
+
it{ expect(duration(10000)).to eq("[2h 46m 40s]") }
|
572
|
+
end
|
573
|
+
context "when 1 hour exactly" do
|
574
|
+
it{ expect(duration(3600)).to eq("[1h 0m 0s]") }
|
575
|
+
end
|
576
|
+
context "when 0 hours and more than minute" do
|
577
|
+
it{ expect(duration(2000)).to eq("[33m 20s]") }
|
578
|
+
end
|
579
|
+
context "when 1 minute exactly" do
|
580
|
+
it{ expect(duration(60)).to eq("[1m 0s]") }
|
581
|
+
end
|
582
|
+
context "when less than minute" do
|
583
|
+
it{ expect(duration(45)).to eq("[0m 45s]") }
|
584
|
+
end
|
585
|
+
context "when zero" do
|
586
|
+
it{ expect(duration(0)).to eq("[0m 0s]") }
|
587
|
+
end
|
588
|
+
end
|
589
|
+
describe "#ri" do
|
590
|
+
subject { ri 'boom' }
|
591
|
+
it { expect {subject}.to raise_error(RuntimeError, /boom/) }
|
592
|
+
end
|
593
|
+
describe String do
|
594
|
+
describe "#open" do
|
595
|
+
subject { "my".open(:exit) }
|
596
|
+
let(:page_object) { double }
|
597
|
+
before do
|
598
|
+
stub_const("MyPage", page_object)
|
599
|
+
expect(page_object).to receive(:open).with(:exit).once
|
600
|
+
end
|
601
|
+
it { expect(subject).to be_nil }
|
602
|
+
end
|
603
|
+
describe "#given" do
|
604
|
+
subject { "my".given }
|
605
|
+
let(:page_object) { double }
|
606
|
+
before do
|
607
|
+
stub_const("MyPage", page_object)
|
608
|
+
expect(page_object).to receive(:new).once
|
609
|
+
end
|
610
|
+
it { expect(subject).to be_nil }
|
611
|
+
end
|
612
|
+
describe "#as_page_class" do
|
613
|
+
subject { "my".as_page_class }
|
614
|
+
let(:my_page) { double }
|
615
|
+
before { stub_const("MyPage", my_page) }
|
616
|
+
it { expect(subject).to eql(my_page) }
|
617
|
+
end
|
618
|
+
end
|
619
|
+
end
|