spec/symbiont/enclosers_spec.rb in symbiont-0.1.9 vs spec/symbiont/enclosers_spec.rb in symbiont-0.2.0

- old
+ new

@@ -1,57 +1,76 @@ -require 'spec_helper' - -describe Symbiont::Enclosers do - let(:watir_browser) { mock_browser_for_watir } - let(:watir_definition) { DefinitionTest.new(watir_browser) } - - context "a definition using watir-webdriver" do - it "should allow frames to act as a context" do - watir_browser.should_receive(:frame).with(id: "frame").and_return(watir_browser) - watir_browser.should_receive(:text_field).and_return(watir_browser) - watir_browser.should_receive(:wd).and_return(watir_browser) - watir_browser.should_receive(:switch_to).and_return(watir_browser) - watir_browser.should_receive(:default_content).and_return(watir_browser) - web_object = watir_definition.framedLoginName_text_field - web_object.should_not be_nil - web_object.should be_instance_of Symbiont::WebObjects::TextField - end - - it "should wait for a condition to be true" do - watir_browser.should_receive(:wait_until).with(5, "some condition") - watir_definition.wait_for(5, "some condition") - end - - it "should handle alert message boxes" do - watir_browser.should_receive(:wd).twice.and_return(watir_browser) - watir_browser.should_receive(:execute_script).twice - watir_definition.will_alert do - end - end - - it "should handle confirmation message boxes" do - watir_browser.should_receive(:wd).twice.and_return(watir_browser) - watir_browser.should_receive(:execute_script).twice - watir_definition.will_confirm(true) do - end - end - - it "should handle prompt message boxes" do - watir_browser.should_receive(:wd).twice.and_return(watir_browser) - watir_browser.should_receive(:execute_script).twice - watir_definition.will_prompt("Question") do - end - end - - it "attaches to a window by using the title" do - watir_browser.should_receive(:window).with(:title => /Display\ Results/).and_return(watir_browser) - watir_browser.should_receive(:use) - watir_definition.within_window(title: "Display Results") - end - - it "attaches to a window by using the url" do - watir_browser.should_receive(:window).with(:url => /results\.html/).and_return(watir_browser) - watir_browser.should_receive(:use) - watir_definition.within_window(url: "results.html") - end - end -end +require "spec_helper" + +describe Symbiont::Enclosers do + let(:watir_browser) { mock_browser_for_watir } + let(:watir_definition) { DefinitionTest.new(watir_browser) } + + context "a definition using watir-webdriver" do + it "should wait for a condition to be true" do + watir_browser.should_receive(:wait_until).with(5, "some condition") + watir_definition.wait_for(5, "some condition") + end + + it "should wait for a condition to be true with any page level timeout" do + Symbiont.page_level_wait = 30 + watir_browser.should_receive(:wait_until).with(30, nil) + watir_definition.wait_for + end + + it "should be able to attach to a window by using the title" do + watir_browser.should_receive(:window).with(:title => /Display\ Results/).and_return(watir_browser) + watir_browser.should_receive(:use) + watir_definition.within_window(title: "Display Results") + end + + it "should be able to attach to a window by using the url" do + watir_browser.should_receive(:window).with(:url => /results\.html/).and_return(watir_browser) + watir_browser.should_receive(:use) + watir_definition.within_window(url: "results.html") + end + + it "should allow frames to act as a context" do + watir_browser.should_receive(:frame).with(id: "frame").and_return(watir_browser) + watir_browser.should_receive(:text_field).and_return(watir_browser) + watir_browser.should_receive(:wd).and_return(watir_browser) + watir_browser.should_receive(:switch_to).and_return(watir_browser) + watir_browser.should_receive(:default_content).and_return(watir_browser) + web_object = watir_definition.framedLoginName_text_field + web_object.should_not be_nil + web_object.should be_instance_of Symbiont::WebObjects::TextField + end + + it "should be able to convert a modal popup to a window" do + watir_browser.should_receive(:execute_script) + watir_definition.within_modal {} + end + + it "should handle alert message boxes" do + #watir_browser.should_receive(:wd).twice.and_return(watir_browser) + #watir_browser.should_receive(:execute_script).twice + watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser) + watir_browser.should_receive(:exists?).and_return(true) + watir_browser.should_receive(:text) + watir_browser.should_receive(:ok) + watir_definition.will_alert do + end + end + + it "should handle confirmation message boxes" do + #watir_browser.should_receive(:wd).twice.and_return(watir_browser) + #watir_browser.should_receive(:execute_script).twice + watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser) + watir_browser.should_receive(:exists?).and_return(true) + watir_browser.should_receive(:text) + watir_browser.should_receive(:ok) + watir_definition.will_confirm(true) do + end + end + + it "should handle prompt message boxes" do + watir_browser.should_receive(:wd).twice.and_return(watir_browser) + watir_browser.should_receive(:execute_script).twice + watir_definition.will_prompt("Question") do + end + end + end +end \ No newline at end of file