require 'spec_helper' describe Symbiont::Generators do let(:watir_browser) { mock_browser_for_watir } let(:watir_definition) { DefinitionTest.new(watir_browser) } describe "button generators" do context "when declared on a page definition" do it "should generate methods for referencing the button" do watir_definition.should respond_to(:login_object) watir_definition.should respond_to(:login_button) end it "should generate methods for interacting with the button" do watir_definition.should respond_to(:login) watir_definition.should respond_to(:login_text) watir_definition.should respond_to(:login_exists?) watir_definition.should respond_to(:login_visible?) watir_definition.should respond_to(:login_enabled?) watir_definition.should respond_to(:login?) watir_definition.should respond_to(:login_?) watir_definition.should respond_to(:login!) end end context "when used by the watir platform" do it "should locate the button" do watir_browser.should_receive(:button).and_return(watir_browser) web_object = watir_definition.login_object web_object.should_not be_nil web_object.should be_instance_of Symbiont::WebObjects::Button end it "should return the text of the button" do watir_browser.should_receive(:button).and_return(watir_browser) watir_browser.should_receive(:text).and_return('Login') watir_definition.login_text.should == "Login" end it "should click the button" do watir_browser.should_receive(:button).and_return(watir_browser) watir_browser.should_receive(:click) watir_definition.login end it "should determine if a button exists" do watir_browser.should_receive(:button).twice.and_return(watir_browser) watir_browser.should_receive(:exists?).twice.and_return(watir_browser) watir_definition.login?.should be_true watir_definition.login_exists?.should be_true end it "should determine if a button is visible" do watir_browser.should_receive(:button).twice.and_return(watir_browser) watir_browser.should_receive(:present?).twice.and_return(watir_browser) watir_definition.login_?.should be_true watir_definition.login_visible?.should be_true end it "should determine if a button is enabled" do watir_browser.should_receive(:button).twice.and_return(watir_browser) watir_browser.should_receive(:enabled?).twice.and_return(watir_browser) watir_definition.login_enabled?.should be_true watir_definition.login!.should be_true end it "should call a block on the button if specified" do watir_definition.logout_object.should == "logout" end end end end