How to use error method of Howitzer Package

Best Howitzer_ruby code snippet using Howitzer.error

helpers_spec.rb

Source:helpers_spec.rb Github

copy

Full Screen

...24 end25 context 'when driver is not specified' do26 let(:driver_setting) { nil }27 it do28 expect(log).to receive(:error).with(29 Howitzer::DriverNotSpecifiedError,30 'Please check your settings'31 ).once.and_call_original32 expect { subject }.to raise_error(Howitzer::DriverNotSpecifiedError)33 end34 end35 end36 describe '#testingbot_driver?' do37 subject { testingbot_driver? }38 before { allow(settings).to receive(:driver) { driver_setting } }39 context 'when :testingbot' do40 let(:driver_setting) { :testingbot }41 it { is_expected.to be_truthy }42 end43 context 'when not :testingbot' do44 let(:driver_setting) { :phantomjs }45 it { is_expected.to be_falsey }46 end47 context 'when driver specified as String' do48 let(:driver_setting) { 'testingbot' }49 it { is_expected.to be_truthy }50 end51 context 'when driver is not specified' do52 let(:driver_setting) { nil }53 it do54 expect(log).to receive(:error).with(55 Howitzer::DriverNotSpecifiedError,56 'Please check your settings'57 ).once.and_call_original58 expect { subject }.to raise_error(Howitzer::DriverNotSpecifiedError)59 end60 end61 end62 describe '#phantomjs_driver?' do63 subject { phantomjs_driver? }64 before { allow(settings).to receive(:driver) { driver_setting } }65 context 'when :phantomjs' do66 let(:driver_setting) { :phantomjs }67 it { is_expected.to be_truthy }68 end69 context 'when not :phantomjs' do70 let(:driver_setting) { :selenium }71 it { is_expected.to be_falsey }72 end73 context 'when :selenium_grid' do74 let(:driver_setting) { :selenium_grid }75 it { is_expected.to be_falsey }76 end77 context 'when driver specified as String' do78 let(:driver_setting) { 'phantomjs' }79 it { is_expected.to be_truthy }80 end81 context 'when driver is not specified' do82 let(:driver_setting) { nil }83 it do84 expect(log).to receive(:error).with(85 Howitzer::DriverNotSpecifiedError,86 'Please check your settings'87 ).once.and_call_original88 expect { subject }.to raise_error(Howitzer::DriverNotSpecifiedError)89 end90 end91 end92 describe '#selenium_driver?' do93 subject { selenium_driver? }94 before { allow(settings).to receive(:driver) { driver_setting } }95 context 'when :selenium' do96 let(:driver_setting) { :selenium }97 it { is_expected.to be_truthy }98 end99 context 'when :selenium_grid' do100 let(:driver_setting) { :selenium_grid }101 it { is_expected.to be_falsey }102 end103 context 'when not :selenium' do104 let(:driver_setting) { :phantomjs }105 it { is_expected.to be_falsey }106 end107 context 'when driver specified as String' do108 let(:driver_setting) { 'selenium' }109 it { is_expected.to be_truthy }110 end111 context 'when driver is not specified' do112 let(:driver_setting) { nil }113 it do114 expect(log).to receive(:error).with(115 Howitzer::DriverNotSpecifiedError,116 'Please check your settings'117 ).once.and_call_original118 expect { subject }.to raise_error(Howitzer::DriverNotSpecifiedError)119 end120 end121 end122 describe '#selenium_grid_driver?' do123 subject { selenium_grid_driver? }124 before { allow(settings).to receive(:driver) { driver_setting } }125 context 'when :selenium_grid' do126 let(:driver_setting) { :selenium_grid }127 it { is_expected.to be_truthy }128 end129 context 'when :selenium' do130 let(:driver_setting) { :selenium }131 it { is_expected.to be_falsey }132 end133 context 'when not :selenium' do134 let(:driver_setting) { :phantomjs }135 it { is_expected.to be_falsey }136 end137 context 'when driver specified as String' do138 let(:driver_setting) { 'selenium_grid' }139 it { is_expected.to be_truthy }140 end141 context 'when driver is not specified' do142 let(:driver_setting) { nil }143 it do144 expect(log).to receive(:error).with(145 Howitzer::DriverNotSpecifiedError,146 'Please check your settings'147 ).once.and_call_original148 expect { subject }.to raise_error(Howitzer::DriverNotSpecifiedError)149 end150 end151 end152 describe '#ie_browser?' do153 subject { ie_browser? }154 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }155 before { allow(self).to receive(:testingbot_driver?) { testingbot_driver } }156 before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }157 context 'when sauce_driver? is TRUE' do158 let(:sauce_driver) { true }159 context 'settings.sl_browser_name = :ie' do160 before { allow(settings).to receive(:sl_browser_name) { :ie } }161 it { is_expected.to be_truthy }162 end163 context 'settings.sl_browser_name = :iexplore' do164 before { allow(settings).to receive(:sl_browser_name) { :iexplore } }165 it { is_expected.to be_truthy }166 end167 context 'settings.sl_browser_name = :chrome' do168 before { allow(settings).to receive(:sl_browser_name) { :chrome } }169 it { is_expected.to be_falsey }170 end171 context 'settings.sl_browser_name is not specified' do172 before { allow(settings).to receive(:sl_browser_name) { nil } }173 it do174 expect(log).to receive(:error).with(175 Howitzer::SlBrowserNotSpecifiedError,176 'Please check your settings'177 ).once.and_call_original178 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)179 end180 end181 end182 context 'when sauce_driver? is FALSE' do183 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }184 context 'when selenium_driver? is TRUE' do185 let(:selenium_driver) { true }186 context 'settings.sel_browser = :ie' do187 before { allow(settings).to receive(:sel_browser) { :ie } }188 it { is_expected.to be_truthy }189 end190 context 'settings.sel_browser = :iexplore' do191 before { allow(settings).to receive(:sel_browser) { :iexplore } }192 it { is_expected.to be_truthy }193 end194 context 'settings.sel_browser = :chrome' do195 before { allow(settings).to receive(:sel_browser) { :chrome } }196 it { is_expected.to be_falsey }197 end198 context 'settings.sel_browser is not specified' do199 before { allow(settings).to receive(:sel_browser) { nil } }200 it do201 expect(log).to receive(:error).with(202 Howitzer::SelBrowserNotSpecifiedError,203 'Please check your settings'204 ).once.and_call_original205 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)206 end207 end208 end209 context 'when selenium_driver? is FALSE' do210 it { is_expected.to be_falsey }211 end212 context 'when selenium_grid_driver? is TRUE' do213 let(:selenium_grid_driver) { true }214 context 'settings.sel_browser = :ie' do215 before { allow(settings).to receive(:sel_browser) { :ie } }216 it { is_expected.to be_truthy }217 end218 context 'settings.sel_browser = :iexplore' do219 before { allow(settings).to receive(:sel_browser) { :iexplore } }220 it { is_expected.to be_truthy }221 end222 context 'settings.sel_browser = :chrome' do223 before { allow(settings).to receive(:sel_browser) { :chrome } }224 it { is_expected.to be_falsey }225 end226 context 'settings.sel_browser is not specified' do227 before { allow(settings).to receive(:sel_browser) { nil } }228 it do229 expect(log).to receive(:error).with(230 Howitzer::SelBrowserNotSpecifiedError,231 'Please check your settings'232 ).once.and_call_original233 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)234 end235 end236 end237 context 'when selenium_grid_driver? is FALSE' do238 it { is_expected.to be_falsey }239 end240 end241 context 'when testingbot_driver? is TRUE' do242 let(:testingbot_driver) { true }243 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }244 context 'settings.sel_browser = :ie' do245 before do246 allow(settings).to receive(:tb_browser_name) { :ie }247 allow(settings).to receive(:tb_browser_version) { 9 }248 end249 it { is_expected.to be_truthy }250 end251 context 'settings.tb_browser_name = :iexplore' do252 before do253 allow(settings).to receive(:tb_browser_name) { :iexplore }254 allow(settings).to receive(:tb_browser_version) { 9 }255 end256 it { is_expected.to be_truthy }257 end258 context 'settings.tb_browser_name = :firefox' do259 before do260 allow(settings).to receive(:tb_browser_name) { :firefox }261 allow(settings).to receive(:tb_browser_version) { 8 }262 end263 it { is_expected.to be_falsey }264 end265 context 'settings.tb_browser_name is not specified' do266 before { allow(settings).to receive(:tb_browser_name) { nil } }267 it do268 expect(log).to receive(:error).with(269 Howitzer::TbBrowserNotSpecifiedError,270 'Please check your settings'271 ).once.and_call_original272 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)273 end274 end275 end276 context 'when testingbot_driver? is FALSE' do277 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }278 context 'when sauce_driver? is TRUE' do279 let(:sauce_driver) { true }280 context 'settings.sl_browser_name = :ie' do281 before { allow(settings).to receive(:sl_browser_name) { :ie } }282 it { is_expected.to be_truthy }283 end284 context 'settings.sl_browser_name = :iexplore' do285 before { allow(settings).to receive(:sl_browser_name) { :iexplore } }286 it { is_expected.to be_truthy }287 end288 context 'settings.sl_browser_name = :chrome' do289 before { allow(settings).to receive(:sl_browser_name) { :chrome } }290 it { is_expected.to be_falsey }291 end292 context 'settings.sl_browser_name is not specified' do293 before { allow(settings).to receive(:sl_browser_name) { nil } }294 it do295 expect(log).to receive(:error).with(296 Howitzer::SlBrowserNotSpecifiedError,297 'Please check your settings'298 ).once.and_call_original299 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)300 end301 end302 end303 end304 context 'when selenium_driver? is TRUE' do305 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }306 context 'when selenium_driver? is TRUE' do307 let(:selenium_driver) { true }308 context 'settings.sel_browser = :ie' do309 before { allow(settings).to receive(:sel_browser) { :ie } }310 it { is_expected.to be_truthy }311 end312 context 'settings.sel_browser = :iexplore' do313 before { allow(settings).to receive(:sel_browser) { :iexplore } }314 it { is_expected.to be_truthy }315 end316 context 'settings.sel_browser = :chrome' do317 before { allow(settings).to receive(:sel_browser) { :chrome } }318 it { is_expected.to be_falsey }319 end320 context 'settings.sel_browser is not specified' do321 before { allow(settings).to receive(:sel_browser) { nil } }322 it do323 expect(log).to receive(:error).with(324 Howitzer::SelBrowserNotSpecifiedError,325 'Please check your settings'326 ).once.and_call_original327 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)328 end329 end330 end331 end332 context 'when selenium_driver? is FALSE' do333 before { allow(self).to receive(:selenium_driver?) { false } }334 context 'when testingbot_driver? is TRUE' do335 let(:testingbot_driver) { true }336 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }337 context 'settings.sl_browser_name = :ie' do338 before do339 allow(settings).to receive(:tb_browser_name) { :ie }340 allow(settings).to receive(:tb_browser_version) { 9 }341 end342 it { is_expected.to be_truthy }343 end344 context 'settings.tb_browser_name = :iexplore' do345 before do346 allow(settings).to receive(:tb_browser_name) { :iexplore }347 allow(settings).to receive(:tb_browser_version) { 9 }348 end349 it { is_expected.to be_truthy }350 end351 context 'settings.tb_browser_name = :firefox' do352 before do353 allow(settings).to receive(:tb_browser_name) { :firefox }354 allow(settings).to receive(:tb_browser_version) { 8 }355 end356 it { is_expected.to be_falsey }357 end358 context 'settings.tb_browser_name is not specified' do359 before { allow(settings).to receive(:tb_browser_name) { nil } }360 it do361 expect(log).to receive(:error).with(362 Howitzer::TbBrowserNotSpecifiedError,363 'Please check your settings'364 ).once.and_call_original365 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)366 end367 end368 end369 end370 end371 describe '#ff_browser?' do372 subject { ff_browser? }373 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }374 before { allow(self).to receive(:testingbot_driver?) { testingbot_driver } }375 before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }376 context 'when sauce_driver? is TRUE' do377 let(:sauce_driver) { true }378 context 'settings.sl_browser_name = :ff' do379 before { allow(settings).to receive(:sl_browser_name) { :ff } }380 it { is_expected.to be_truthy }381 end382 context 'settings.sl_browser_name = :firefox' do383 before { allow(settings).to receive(:sl_browser_name) { :firefox } }384 it { is_expected.to be_truthy }385 end386 context 'settings.sl_browser_name = :chrome' do387 before { allow(settings).to receive(:sl_browser_name) { :chrome } }388 it { is_expected.to be_falsey }389 end390 context 'settings.sl_browser_name is not specified' do391 before { allow(settings).to receive(:sl_browser_name) { nil } }392 it do393 expect(log).to receive(:error).with(394 Howitzer::SlBrowserNotSpecifiedError,395 'Please check your settings'396 ).once.and_call_original397 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)398 end399 end400 end401 context 'when sauce_driver? is FALSE' do402 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }403 context 'when selenium_driver? is TRUE' do404 let(:selenium_driver) { true }405 context 'settings.sel_browser = :ff' do406 before { allow(settings).to receive(:sel_browser) { :ff } }407 it { is_expected.to be_truthy }408 end409 context 'settings.sel_browser = :firefox' do410 before { allow(settings).to receive(:sel_browser) { :firefox } }411 it { is_expected.to be_truthy }412 end413 context 'settings.sel_browser = :chrome' do414 before { allow(settings).to receive(:sel_browser) { :chrome } }415 it { is_expected.to be_falsey }416 end417 context 'settings.sel_browser is not specified' do418 before { allow(settings).to receive(:sel_browser) { nil } }419 it do420 expect(log).to receive(:error).with(421 Howitzer::SelBrowserNotSpecifiedError,422 'Please check your settings'423 ).once.and_call_original424 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)425 end426 end427 end428 context 'when selenium_driver? is FALSE' do429 it { is_expected.to be_falsey }430 end431 end432 context 'when testingbot_driver? is TRUE' do433 let(:testingbot_driver) { true }434 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }435 context 'settings.tb_browser_name = :ff' do436 before do437 allow(settings).to receive(:tb_browser_name) { :ff }438 allow(settings).to receive(:tb_browser_version) { 8 }439 end440 it { is_expected.to be_truthy }441 end442 context 'settings.tb_browser_name = :firefox' do443 before do444 allow(settings).to receive(:tb_browser_name) { :firefox }445 allow(settings).to receive(:tb_browser_version) { 8 }446 end447 it { is_expected.to be_truthy }448 end449 context 'settings.tb_browser_name = :iexplore' do450 before do451 allow(settings).to receive(:tb_browser_name) { :iexplore }452 allow(settings).to receive(:tb_browser_version) { 9 }453 end454 it { is_expected.to be_falsey }455 end456 context 'settings.tb_browser_name is not specified' do457 before { allow(settings).to receive(:tb_browser_name) { nil } }458 it do459 expect(log).to receive(:error).with(460 Howitzer::TbBrowserNotSpecifiedError,461 'Please check your settings'462 ).once.and_call_original463 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)464 end465 end466 end467 context 'when testingbot_driver? is FALSE' do468 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }469 context 'when sauce_driver? is TRUE' do470 let(:sauce_driver) { true }471 context 'settings.sl_browser_name = :ff' do472 before { allow(settings).to receive(:sl_browser_name) { :ff } }473 it { is_expected.to be_truthy }474 end475 context 'settings.sl_browser_name = :firefox' do476 before { allow(settings).to receive(:sl_browser_name) { :firefox } }477 it { is_expected.to be_truthy }478 end479 context 'settings.sl_browser_name = :chrome' do480 before { allow(settings).to receive(:sl_browser_name) { :chrome } }481 it { is_expected.to be_falsey }482 end483 context 'settings.sl_browser_name is not specified' do484 before { allow(settings).to receive(:sl_browser_name) { nil } }485 it do486 expect(log).to receive(:error).with(487 Howitzer::SlBrowserNotSpecifiedError,488 'Please check your settings'489 ).once.and_call_original490 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)491 end492 end493 end494 end495 context 'when selenium_driver? is TRUE' do496 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }497 context 'when selenium_driver? is TRUE' do498 let(:selenium_driver) { true }499 context 'settings.sel_browser = :ff' do500 before { allow(settings).to receive(:sel_browser) { :ff } }501 it { is_expected.to be_truthy }502 end503 context 'settings.sel_browser = :firefox' do504 before { allow(settings).to receive(:sel_browser) { :firefox } }505 it { is_expected.to be_truthy }506 end507 context 'settings.sel_browser = :chrome' do508 before { allow(settings).to receive(:sel_browser) { :chrome } }509 it { is_expected.to be_falsey }510 end511 context 'settings.sel_browser is not specified' do512 before { allow(settings).to receive(:sel_browser) { nil } }513 it do514 expect(log).to receive(:error).with(515 Howitzer::SelBrowserNotSpecifiedError,516 'Please check your settings'517 ).once.and_call_original518 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)519 end520 end521 end522 end523 context 'when selenium_driver? is FALSE' do524 before { allow(self).to receive(:selenium_driver?) { false } }525 context 'when testingbot_driver? is TRUE' do526 let(:testingbot_driver) { true }527 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }528 context 'settings.tb_browser_name = :firefox' do529 before do530 allow(settings).to receive(:tb_browser_name) { :firefox }531 allow(settings).to receive(:tb_browser_version) { 8 }532 end533 it { is_expected.to be_truthy }534 end535 context 'settings.tb_browser_name = :ff' do536 before do537 allow(settings).to receive(:tb_browser_name) { :ff }538 allow(settings).to receive(:tb_browser_version) { 8 }539 end540 it { is_expected.to be_truthy }541 end542 context 'settings.tb_browser_name = :iexplore' do543 before do544 allow(settings).to receive(:tb_browser_name) { :iexplore }545 allow(settings).to receive(:tb_browser_version) { 9 }546 end547 it { is_expected.to be_falsey }548 end549 context 'settings.tb_browser_name is not specified' do550 before { allow(settings).to receive(:tb_browser_name) { nil } }551 it do552 expect(log).to receive(:error).with(553 Howitzer::TbBrowserNotSpecifiedError,554 'Please check your settings'555 ).once.and_call_original556 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)557 end558 end559 end560 context 'when selenium_grid_driver? is TRUE' do561 before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }562 context 'when selenium_grid_driver? is TRUE' do563 let(:selenium_grid_driver) { true }564 context 'settings.sel_browser = :ff' do565 before { allow(settings).to receive(:sel_browser) { :ff } }566 it { is_expected.to be_truthy }567 end568 context 'settings.sel_browser = :firefox' do569 before { allow(settings).to receive(:sel_browser) { :firefox } }570 it { is_expected.to be_truthy }571 end572 context 'settings.sel_browser = :chrome' do573 before { allow(settings).to receive(:sel_browser) { :chrome } }574 it { is_expected.to be_falsey }575 end576 context 'settings.sel_browser is not specified' do577 before { allow(settings).to receive(:sel_browser) { nil } }578 it do579 expect(log).to receive(:error).with(580 Howitzer::SelBrowserNotSpecifiedError,581 'Please check your settings'582 ).once.and_call_original583 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)584 end585 end586 end587 end588 context 'when selenium_grid_driver? is FALSE' do589 before { allow(self).to receive(:selenium_grid_driver?) { false } }590 context 'when testingbot_driver? is TRUE' do591 let(:testingbot_driver) { true }592 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }593 context 'settings.tb_browser_name = :firefox' do594 before do595 allow(settings).to receive(:tb_browser_name) { :firefox }596 allow(settings).to receive(:tb_browser_version) { 8 }597 end598 it { is_expected.to be_truthy }599 end600 context 'settings.tb_browser_name = :ff' do601 before do602 allow(settings).to receive(:tb_browser_name) { :ff }603 allow(settings).to receive(:tb_browser_version) { 8 }604 end605 it { is_expected.to be_truthy }606 end607 context 'settings.tb_browser_name = :iexplore' do608 before do609 allow(settings).to receive(:tb_browser_name) { :iexplore }610 allow(settings).to receive(:tb_browser_version) { 9 }611 end612 it { is_expected.to be_falsey }613 end614 context 'settings.tb_browser_name is not specified' do615 before { allow(settings).to receive(:tb_browser_name) { nil } }616 it do617 expect(log).to receive(:error).with(618 Howitzer::TbBrowserNotSpecifiedError,619 'Please check your settings'620 ).once.and_call_original621 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)622 end623 end624 end625 end626 end627 end628 describe '#chrome_browser?' do629 subject { chrome_browser? }630 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }631 before { allow(self).to receive(:testingbot_driver?) { testingbot_driver } }632 before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }633 context 'when sauce_driver? is TRUE' do634 let(:sauce_driver) { true }635 let(:testingbot_driver) { true }636 context 'settings.sl_browser_name = :chrome' do637 before { allow(settings).to receive(:sl_browser_name) { :chrome } }638 it { is_expected.to be_truthy }639 end640 context 'settings.sl_browser_name = :firefox' do641 before { allow(settings).to receive(:sl_browser_name) { :firefox } }642 it { is_expected.to be_falsey }643 end644 context 'settings.sl_browser_name is not specified' do645 before { allow(settings).to receive(:sl_browser_name) { nil } }646 it do647 expect(log).to receive(:error).with(648 Howitzer::SlBrowserNotSpecifiedError,649 'Please check your settings'650 ).once.and_call_original651 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)652 end653 end654 end655 context 'when sauce_driver? is FALSE' do656 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }657 context 'when selenium_driver? is TRUE' do658 let(:selenium_driver) { true }659 context 'settings.sel_browser = :chrome' do660 before { allow(settings).to receive(:sel_browser) { :chrome } }661 it { is_expected.to be_truthy }662 end663 context 'settings.sel_browser = :firefox' do664 before { allow(settings).to receive(:sel_browser) { :firefox } }665 it { is_expected.to be_falsey }666 end667 context 'settings.sel_browser is not specified' do668 before { allow(settings).to receive(:sel_browser) { nil } }669 it do670 expect(log).to receive(:error).with(671 Howitzer::SelBrowserNotSpecifiedError,672 'Please check your settings'673 ).once.and_call_original674 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)675 end676 end677 end678 context 'when selenium_driver? is FALSE' do679 it { is_expected.to be_falsey }680 end681 end682 context 'when testingbot_driver? is TRUE' do683 let(:testingbot_driver) { true }684 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }685 context 'settings.tb_browser_name = :chrome' do686 before do687 allow(settings).to receive(:tb_browser_name) { :chrome }688 allow(settings).to receive(:tb_browser_version) { 9 }689 end690 it { is_expected.to be_truthy }691 end692 context 'settings.tb_browser_name = :iexplore' do693 before do694 allow(settings).to receive(:tb_browser_name) { :iexplore }695 allow(settings).to receive(:tb_browser_version) { 9 }696 end697 it { is_expected.to be_falsey }698 end699 context 'settings.tb_browser_name is not specified' do700 before { allow(settings).to receive(:tb_browser_name) { nil } }701 it do702 expect(log).to receive(:error).with(703 Howitzer::TbBrowserNotSpecifiedError,704 'Please check your settings'705 ).once.and_call_original706 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)707 end708 end709 end710 context 'when testingbot_driver? is FALSE' do711 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }712 context 'when sauce_driver? is TRUE' do713 let(:sauce_driver) { true }714 context 'settings.sl_browser_name = :chrome' do715 before { allow(settings).to receive(:sl_browser_name) { :chrome } }716 it { is_expected.to be_truthy }717 end718 context 'settings.sl_browser_name = :firefox' do719 before { allow(settings).to receive(:sl_browser_name) { :firefox } }720 it { is_expected.to be_falsey }721 end722 context 'settings.sl_browser_name is not specified' do723 before { allow(settings).to receive(:sl_browser_name) { nil } }724 it do725 expect(log).to receive(:error).with(726 Howitzer::SlBrowserNotSpecifiedError,727 'Please check your settings'728 ).once.and_call_original729 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)730 end731 end732 end733 end734 context 'when selenium_driver? is TRUE' do735 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }736 context 'when selenium_driver? is TRUE' do737 let(:selenium_driver) { true }738 context 'settings.sel_browser = :chrome' do739 before { allow(settings).to receive(:sel_browser) { :chrome } }740 it { is_expected.to be_truthy }741 end742 context 'settings.sel_browser = :firefox' do743 before { allow(settings).to receive(:sel_browser) { :firefox } }744 it { is_expected.to be_falsey }745 end746 context 'settings.sel_browser is not specified' do747 before { allow(settings).to receive(:sel_browser) { nil } }748 it do749 expect(log).to receive(:error).with(750 Howitzer::SelBrowserNotSpecifiedError,751 'Please check your settings'752 ).once.and_call_original753 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)754 end755 end756 end757 end758 context 'when selenium_driver? is FALSE' do759 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }760 context 'when selenium_driver? is TRUE' do761 let(:selenium_driver) { true }762 context 'settings.sel_browser = :chrome' do763 before { allow(settings).to receive(:sel_browser) { :chrome } }764 it { is_expected.to be_truthy }765 end766 context 'settings.sel_browser = :firefox' do767 before { allow(settings).to receive(:sel_browser) { :firefox } }768 it { is_expected.to be_falsey }769 end770 context 'settings.sel_browser is not specified' do771 before { allow(settings).to receive(:sel_browser) { nil } }772 it do773 expect(log).to receive(:error).with(774 Howitzer::SelBrowserNotSpecifiedError,775 'Please check your settings'776 ).once.and_call_original777 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)778 end779 end780 end781 context 'when selenium_driver? is FALSE' do782 it { is_expected.to be_falsey }783 end784 end785 end786 describe '#safari_browser?' do787 subject { safari_browser? }788 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }789 before { allow(self).to receive(:testingbot_driver?) { testingbot_driver } }790 before { allow(self).to receive(:selenium_grid_driver?) { selenium_grid_driver } }791 context 'when sauce_driver? is TRUE' do792 let(:sauce_driver) { true }793 let(:testingbot_driver) { true }794 context 'settings.sl_browser_name = :safari' do795 before { allow(settings).to receive(:sl_browser_name) { :safari } }796 it { is_expected.to be_truthy }797 end798 context 'settings.sl_browser_name = :firefox' do799 before { allow(settings).to receive(:sl_browser_name) { :firefox } }800 it { is_expected.to be_falsey }801 end802 context 'settings.sl_browser_name is not specified' do803 before { allow(settings).to receive(:sl_browser_name) { nil } }804 it do805 expect(log).to receive(:error).with(806 Howitzer::SlBrowserNotSpecifiedError,807 'Please check your settings'808 ).once.and_call_original809 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)810 end811 end812 end813 context 'when sauce_driver? is FALSE' do814 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }815 context 'when selenium_driver? is TRUE' do816 let(:selenium_driver) { true }817 context 'settings.sel_browser = :safari' do818 before { allow(settings).to receive(:sel_browser) { :safari } }819 it { is_expected.to be_truthy }820 end821 context 'settings.sel_browser = :firefox' do822 before { allow(settings).to receive(:sel_browser) { :firefox } }823 it { is_expected.to be_falsey }824 end825 context 'settings.sel_browser is not specified' do826 before { allow(settings).to receive(:sel_browser) { nil } }827 it do828 expect(log).to receive(:error).with(829 Howitzer::SelBrowserNotSpecifiedError,830 'Please check your settings'831 ).once.and_call_original832 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)833 end834 end835 end836 context 'when selenium_driver? is FALSE' do837 it { is_expected.to be_falsey }838 end839 end840 context 'when testingbot_driver? is TRUE' do841 let(:testingbot_driver) { true }842 before { allow(settings).to receive(:testingbot_driver?) { testingbot_driver } }843 context 'settings.tb_browser_name = :safari' do844 before do845 allow(settings).to receive(:tb_browser_name) { :safari }846 allow(settings).to receive(:tb_browser_version) { 9 }847 end848 it { is_expected.to be_truthy }849 end850 context 'settings.tb_browser_name = :iexplore' do851 before do852 allow(settings).to receive(:tb_browser_name) { :iexplore }853 allow(settings).to receive(:tb_browser_version) { 9 }854 end855 it { is_expected.to be_falsey }856 end857 context 'settings.tb_browser_name is not specified' do858 before { allow(settings).to receive(:tb_browser_name) { nil } }859 it do860 expect(log).to receive(:error).with(861 Howitzer::TbBrowserNotSpecifiedError,862 'Please check your settings'863 ).once.and_call_original864 expect { subject }.to raise_error(Howitzer::TbBrowserNotSpecifiedError)865 end866 end867 end868 context 'when testingbot_driver? is FALSE' do869 before { allow(self).to receive(:sauce_driver?) { sauce_driver } }870 context 'when sauce_driver? is TRUE' do871 let(:sauce_driver) { true }872 context 'settings.sl_browser_name = :safari' do873 before { allow(settings).to receive(:sl_browser_name) { :safari } }874 it { is_expected.to be_truthy }875 end876 context 'settings.sl_browser_name = :firefox' do877 before { allow(settings).to receive(:sl_browser_name) { :firefox } }878 it { is_expected.to be_falsey }879 end880 context 'settings.sl_browser_name is not specified' do881 before { allow(settings).to receive(:sl_browser_name) { nil } }882 it do883 expect(log).to receive(:error).with(884 Howitzer::SlBrowserNotSpecifiedError,885 'Please check your settings'886 ).once.and_call_original887 expect { subject }.to raise_error(Howitzer::SlBrowserNotSpecifiedError)888 end889 end890 end891 end892 context 'when selenium_driver? is TRUE' do893 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }894 context 'when selenium_driver? is TRUE' do895 let(:selenium_driver) { true }896 context 'settings.sel_browser = :safari' do897 before { allow(settings).to receive(:sel_browser) { :safari } }898 it { is_expected.to be_truthy }899 end900 context 'settings.sel_browser = :firefox' do901 before { allow(settings).to receive(:sel_browser) { :firefox } }902 it { is_expected.to be_falsey }903 end904 context 'settings.sel_browser is not specified' do905 before { allow(settings).to receive(:sel_browser) { nil } }906 it do907 expect(log).to receive(:error).with(908 Howitzer::SelBrowserNotSpecifiedError,909 'Please check your settings'910 ).once.and_call_original911 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)912 end913 end914 end915 end916 context 'when selenium_driver? is FALSE' do917 before { allow(self).to receive(:selenium_driver?) { selenium_driver } }918 context 'when selenium_driver? is TRUE' do919 let(:selenium_driver) { true }920 context 'settings.sel_browser = :safari' do921 before { allow(settings).to receive(:sel_browser) { :safari } }922 it { is_expected.to be_truthy }923 end924 context 'settings.sel_browser = :firefox' do925 before { allow(settings).to receive(:sel_browser) { :firefox } }926 it { is_expected.to be_falsey }927 end928 context 'settings.sel_browser is not specified' do929 before { allow(settings).to receive(:sel_browser) { nil } }930 it do931 expect(log).to receive(:error).with(932 Howitzer::SelBrowserNotSpecifiedError,933 'Please check your settings'934 ).once.and_call_original935 expect { subject }.to raise_error(Howitzer::SelBrowserNotSpecifiedError)936 end937 end938 end939 context 'when selenium_driver? is FALSE' do940 it { is_expected.to be_falsey }941 end942 end943 end944 describe '#app_url' do945 subject { app_url }946 before do947 allow(settings).to receive(:app_base_auth_login) { app_base_auth_login_setting }948 allow(settings).to receive(:app_base_auth_pass) { app_base_auth_pass_setting }949 allow(settings).to receive(:app_protocol) { app_protocol_setting }950 allow(settings).to receive(:app_host) { app_host_setting }951 end952 let(:app_protocol_setting) { nil }953 let(:app_host_setting) { 'redmine.strongqa.com' }954 context 'when login and password present' do955 let(:app_base_auth_login_setting) { 'alex' }956 let(:app_base_auth_pass_setting) { 'pa$$w0rd' }957 it { is_expected.to eq('http://alex:pa$$w0rd@redmine.strongqa.com') }958 end959 context 'when login and password blank' do960 let(:app_base_auth_login_setting) { '' }961 let(:app_base_auth_pass_setting) { '' }962 it { is_expected.to eq('http://redmine.strongqa.com') }963 end964 end965 describe '#app_base_url' do966 subject { app_base_url(prefix) }967 before do968 allow(settings).to receive(:app_protocol) { app_protocol_setting }969 allow(settings).to receive(:app_host) { app_host_setting }970 end971 let(:app_protocol_setting) { nil }972 let(:app_host_setting) { 'redmine.strongqa.com' }973 context 'when login and password present' do974 let(:prefix) { 'alex:pa$$w0rd@' }975 it { is_expected.to eq('http://alex:pa$$w0rd@redmine.strongqa.com') }976 end977 context 'when login and password blank' do978 let(:prefix) { nil }979 it { is_expected.to eq('http://redmine.strongqa.com') }980 end981 end982 describe '#duration' do983 context 'when more than hour' do984 it { expect(duration(10_000)).to eq('[2h 46m 40s]') }985 end986 context 'when 1 hour exactly' do987 it { expect(duration(3600)).to eq('[1h 0m 0s]') }988 end989 context 'when 0 hours and more than minute' do990 it { expect(duration(2000)).to eq('[33m 20s]') }991 end992 context 'when 1 minute exactly' do993 it { expect(duration(60)).to eq('[1m 0s]') }994 end995 context 'when less than minute' do996 it { expect(duration(45)).to eq('[0m 45s]') }997 end998 context 'when zero' do999 it { expect(duration(0)).to eq('[0m 0s]') }1000 end1001 end1002 describe '#ri' do1003 subject { ri 'boom' }1004 it { expect { subject }.to raise_error(RuntimeError, /boom/) }1005 end1006 describe String do1007 let(:page_name) { 'my' }1008 let(:page_object) { double }1009 before { stub_const('MyPage', page_object) }1010 describe '#open' do1011 subject { page_name.open(:exit) }1012 before do1013 expect(page_object).to receive(:open).with(:exit).once1014 end1015 it { is_expected.to be_nil }1016 end1017 describe '#given' do1018 subject { page_name.given }...

Full Screen

Full Screen

page_validator_spec.rb

Source:page_validator_spec.rb Github

copy

Full Screen

...20 describe '#check_validations_are_defined!' do21 subject { web_page.check_validations_are_defined! }22 context 'when no validation specified' do23 it do24 expect(log).to receive(:error).with(25 Howitzer::NoValidationError,26 "No any page validation was found for 'TestWebPageClass' page"27 ).once.and_call_original28 expect { subject }.to raise_error(Howitzer::NoValidationError)29 end30 end31 context 'when title validation is specified' do32 before do33 web_page.class.validate :title, pattern: /Foo/34 end35 it { expect { subject }.to_not raise_error }36 end37 context 'when url validation is specified' do38 before do39 web_page.class.validate :url, pattern: /Foo/40 end41 it { expect { subject }.to_not raise_error }42 end43 context 'when element_presence validation is specified' do44 before do45 web_page.class.validate :element_presence, locator: :test_locator46 end47 it { expect { subject }.to_not raise_error }48 end49 end50 describe '.validate' do51 before do52 Howitzer::Utils::PageValidator.validations[web_page.class.name] = nil53 end54 subject { web_page.class.validate(name, options) }55 context 'when name = :url' do56 context 'as string' do57 let(:name) { 'url' }58 context 'when options is correct' do59 context '(as string)' do60 let(:options) { { 'pattern' => /foo/ } }61 it do62 is_expected.to be_a(Proc)63 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:url]).to be_a Proc64 end65 end66 context '(as symbol)' do67 let(:options) { { pattern: /foo/ } }68 it do69 is_expected.to be_a(Proc)70 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:url]).to be_a Proc71 end72 end73 end74 context 'when options is incorrect' do75 context '(missing pattern)' do76 let(:options) { {} }77 it do78 expect(log).to receive(:error).with(79 Howitzer::WrongOptionError,80 "Please specify ':pattern' option as Regexp object"81 ).once.and_call_original82 expect { subject }.to raise_error(Howitzer::WrongOptionError)83 end84 end85 context '(string pattern)' do86 let(:options) { { pattern: 'foo' } }87 it do88 expect(log).to receive(:error).with(89 Howitzer::WrongOptionError,90 "Please specify ':pattern' option as Regexp object"91 ).once.and_call_original92 expect { subject }.to raise_error(Howitzer::WrongOptionError)93 end94 end95 context '(not hash)' do96 let(:options) { 'foo' }97 it { expect { subject }.to raise_error(TypeError, "Expected options to be Hash, actual is 'String'") }98 end99 end100 end101 context 'as symbol' do102 let(:name) { :url }103 let(:options) { { pattern: /foo/ } }104 it do105 is_expected.to be_a(Proc)106 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:url]).to be_a Proc107 end108 end109 end110 context 'when name = :element_presence' do111 let(:name) { :element_presence }112 context 'when options is correct' do113 context '(as string)' do114 let(:options) { { 'locator' => 'test_locator' } }115 it do116 is_expected.to be_a(Proc)117 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:element_presence]).to eql(subject)118 end119 end120 context '(as symbol)' do121 let(:options) { { locator: :test_locator } }122 it do123 is_expected.to be_a(Proc)124 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:element_presence]).to eql(subject)125 end126 end127 end128 context 'when options is incorrect' do129 context '(missing locator)' do130 let(:options) { {} }131 it do132 expect(log).to receive(:error).with(133 Howitzer::WrongOptionError,134 "Please specify ':locator' option as one of page locator names"135 ).once.and_call_original136 expect { subject }.to raise_error(Howitzer::WrongOptionError)137 end138 end139 context '(blank locator name)' do140 let(:options) { { locator: '' } }141 it do142 expect(log).to receive(:error).with(143 Howitzer::WrongOptionError,144 "Please specify ':locator' option as one of page locator names"145 ).once.and_call_original146 expect { subject }.to raise_error(Howitzer::WrongOptionError)147 end148 end149 end150 end151 context 'when name = :title' do152 let(:name) { :title }153 context 'when options is correct' do154 context '(as string)' do155 let(:options) { { 'pattern' => /foo/ } }156 it do157 is_expected.to be_a(Proc)158 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:title]).to be_a Proc159 end160 end161 context '(as symbol)' do162 let(:options) { { pattern: /foo/ } }163 it do164 is_expected.to be_a(Proc)165 expect(Howitzer::Utils::PageValidator.validations[web_page.class.name][:title]).to be_a Proc166 end167 end168 end169 context 'when options is incorrect' do170 context '(missing pattern)' do171 let(:options) { {} }172 it do173 expect(log).to receive(:error).with(174 Howitzer::WrongOptionError,175 "Please specify ':pattern' option as Regexp object"176 ).once.and_call_original177 expect { subject }.to raise_error(Howitzer::WrongOptionError)178 end179 end180 context '(string pattern)' do181 let(:options) { { pattern: 'foo' } }182 it do183 expect(log).to receive(:error).with(184 Howitzer::WrongOptionError,185 "Please specify ':pattern' option as Regexp object"186 ).once.and_call_original187 expect { subject }.to raise_error(Howitzer::WrongOptionError)188 end189 end190 end191 end192 context 'when other name' do193 let(:name) { :unknown }194 let(:options) { {} }195 it do196 expect(log).to receive(:error).with(197 Howitzer::UnknownValidationError,198 "unknown 'unknown' validation type"199 ).once.and_call_original200 expect { subject }.to raise_error(Howitzer::UnknownValidationError)201 end202 end203 end204 describe '.pages' do205 subject { Howitzer::Utils::PageValidator.pages }206 it { is_expected.to eq([]) }207 it do208 subject << Class209 is_expected.to eql([Class])210 end211 end212 describe '.opened?' do213 subject { web_page_class.opened? }214 context 'when no one validation is defined' do215 it do216 expect(log).to receive(:error).with(217 Howitzer::NoValidationError,218 "No any page validation was found for 'TestWebPageClass' page"219 ).once.and_call_original220 expect { subject }.to raise_error(Howitzer::NoValidationError)221 end222 end223 context 'when all validations are defined' do224 before do225 web_page_class.class_eval do226 add_locator :login, '#id'227 validate :url, pattern: /foo/228 validate :title, pattern: /Foo page/229 validate :element_presence, locator: :login230 end231 end232 context 'when all matches' do233 before do234 allow(web_page_class).to receive(:current_url) { 'http://test.com/foo' }...

Full Screen

Full Screen

capybara.rb

Source:capybara.rb Github

copy

Full Screen

...66 CapybaraHelpers.load_driver_gem!(:poltergeist, 'capybara/poltergeist', 'poltergeist')67 Capybara.register_driver :poltergeist do |app|68 Capybara::Poltergeist::Driver.new(69 app,70 js_errors: !Howitzer.phantom_ignore_js_errors,71 phantomjs_options: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]72 )73 end74end75# :phantomjs driver76Capybara.register_driver :phantomjs do |app|77 Capybara::Selenium::Driver.new(78 app, browser: :phantomjs,79 desired_capabilities: {80 javascript_enabled: !Howitzer.phantom_ignore_js_errors81 },82 driver_opts: {83 args: ["--ignore-ssl-errors=#{Howitzer.phantom_ignore_ssl_errors ? 'yes' : 'no'}"]84 }85 )86end87# :sauce driver88Capybara.register_driver :sauce do |app|89 caps = CapybaraHelpers.required_cloud_caps.merge(90 maxDuration: Howitzer.cloud_max_duration,91 idleTimeout: Howitzer.cloud_sauce_idle_timeout,92 recordScreenshots: Howitzer.cloud_sauce_record_screenshots,93 videoUploadOnPass: Howitzer.cloud_sauce_video_upload_on_pass94 )95 url = "http://#{Howitzer.cloud_auth_login}:#{Howitzer.cloud_auth_pass}@ondemand.saucelabs.com:80/wd/hub"96 CapybaraHelpers.cloud_driver(app, caps, url)97end...

Full Screen

Full Screen

error

Using AI Code Generation

copy

Full Screen

1Howitzer.error('Error message')2Howitzer.error('Error message')3Howitzer.error('Error message')4Howitzer.error('Error message')5Howitzer.error('Error message')6Howitzer.error('Error message')7Howitzer.error('Error message')8Howitzer.error('Error message')9Howitzer.error('Error message')10Howitzer.error('Error message')11Howitzer.error('Error message')12Howitzer.error('Error message')13Howitzer.error('Error message')14Howitzer.error('Error message')15Howitzer.error('Error message')16Howitzer.error('Error message')17Howitzer.error('Error message')18Howitzer.error('Error message')19Howitzer.error('Error message')20Howitzer.error('Error message')

Full Screen

Full Screen

error

Using AI Code Generation

copy

Full Screen

1Howitzer::Error.error('Error message')2Howitzer::Error.error('Error message')3Howitzer::Error.error('Error message')4Howitzer::Error.error('Error message')5Howitzer::Error.error('Error message')6Howitzer::Error.error('Error message')7Howitzer::Error.error('Error message')8Howitzer::Error.error('Error message')9Howitzer::Error.error('Error message')10Howitzer::Error.error('Error message')11Howitzer::Error.error('Error message')12Howitzer::Error.error('Error message')13Howitzer::Error.error('Error message')14Howitzer::Error.error('Error message')15Howitzer::Error.error('Error message')16Howitzer::Error.error('Error message')

Full Screen

Full Screen

error

Using AI Code Generation

copy

Full Screen

1Howitzer.error('error')2Howitzer.error('error')3Howitzer.error('error')4Howitzer.error('error')5 def self.error(message)6Inheritance is one of the most important concepts in object-oriented programming. It is the process of using details from a new class without modifying existing class. The newly formed class is a derived class (or child class). Similarly, the existing class is a base class (or parent class). The syntax of inheritance is as follows:

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful