require 'spec_helper' describe Symbiont::Generators do let(:watir_browser) { mock_browser_for_watir } let(:watir_definition) { DefinitionTest.new(watir_browser) } describe "select list web objects" do context "when declared in a definition" do it "should generate methods for referencing the select list" do watir_definition.should respond_to(:concepts_select_list) watir_definition.should respond_to(:concepts_object) end it "should generate methods for interacting with the select list" do watir_definition.should respond_to(:concepts) watir_definition.should respond_to(:concepts_option?) watir_definition.should respond_to(:concepts_exists?) watir_definition.should respond_to(:concepts_visible?) watir_definition.should respond_to(:concepts_enabled?) watir_definition.should respond_to(:concepts?) watir_definition.should respond_to(:concepts_?) watir_definition.should respond_to(:concepts!) watir_definition.should respond_to(:concepts=) end end context "when used by the watir platform" do it "should locate the select list" do watir_browser.should_receive(:select_list).and_return(watir_browser) web_object = watir_definition.concepts_object web_object.should_not be_nil web_object.should be_instance_of Symbiont::WebObjects::SelectList end it "should retrieve the current value of a selected option" do watir_browser.should_receive(:select_list).and_return(watir_browser) watir_browser.should_receive(:value).and_return("testing") watir_definition.concepts_option?.should == "testing" end it "should retrieve the current selection from the select list" do selected = "testing" selected.should_receive(:text).and_return("testing") watir_browser.should_receive(:select_list).and_return(watir_browser) watir_browser.should_receive(:selected_options).and_return([selected]) watir_definition.concepts.should == "testing" end it "should select an item from the select list" do watir_browser.should_receive(:select_list).and_return watir_browser watir_browser.should_receive(:select).with("testing") watir_definition.concepts = "testing" end it "should determine if a select list exists" do watir_browser.should_receive(:select_list).twice.and_return(watir_browser) watir_browser.should_receive(:exists?).twice.and_return(watir_browser) watir_definition.concepts_exists?.should be_true watir_definition.concepts?.should be_true end it "should determine if a select list is visible" do watir_browser.should_receive(:select_list).twice.and_return(watir_browser) watir_browser.should_receive(:visible?).twice.and_return(watir_browser) watir_definition.concepts_visible?.should be_true watir_definition.concepts_?.should be_true end it "should determine if a select list is enabled" do watir_browser.should_receive(:select_list).twice.and_return(watir_browser) watir_browser.should_receive(:enabled?).twice.and_return(watir_browser) watir_definition.concepts_enabled?.should be_true watir_definition.concepts!.should be_true end end end end