require 'spec_helper' describe Symbiont::Enclosers do let(:watir_browser) { mock_browser_for_watir } let(:watir_definition) { DefinitionTest.new(watir_browser) } describe "browser-level actions" do context "a definition using watir-webdriver" do it "should visit a page" do watir_browser.should_receive(:goto).with("http://localhost:4567") watir_definition.visit("http://localhost:4567") end it "should get the active url" do watir_browser.should_receive(:url).and_return("http://localhost:4567") watir_definition.url.should == "http://localhost:4567" end it "should get a screenshot" do watir_browser.should_receive(:wd).and_return(watir_browser) watir_browser.should_receive(:save_screenshot) watir_definition.screenshot("testing.png") end it "should run a script against the browser" do watir_browser.should_receive(:execute_script).twice.and_return("input") watir_definition.run_script("return document.activeElement").should == "input" watir_definition.execute_script("return document.activeElement").should == "input" end end end describe "page-level actions" do context "a definition using watir-webdriver" do it "should return all the text on a page" do watir_browser.should_receive(:text).and_return("page text") watir_definition.text.should == "page text" end it "should return all the markup on a page" do watir_browser.should_receive(:html).twice.and_return("

Page Title

") watir_definition.markup.should == "

Page Title

" watir_definition.html.should == "

Page Title

" end it "should return the title of a page" do watir_browser.should_receive(:title).and_return("Page Title") watir_definition.title.should == "Page Title" end it "should return the web object that has focus" do watir_browser.should_receive(:execute_script).and_return(watir_browser) watir_browser.should_receive(:tag_name).twice.and_return(:input) watir_browser.should_receive(:type).and_return(:submit) watir_definition.focus.class.should == Symbiont::WebObjects::Button end end end end