require 'spec_helper' describe Symbiont::Generators do let(:watir_browser) { mock_browser_for_watir } let(:watir_definition) { DefinitionTest.new(watir_browser) } describe "text area generators" do context "when declared on a page definition" do it "should generate methods for referencing the text area" do watir_definition.should respond_to(:summary_text_area) watir_definition.should respond_to(:summary_object) end it "should generate methods for interacting with the text area" do watir_definition.should respond_to(:summary) watir_definition.should respond_to(:summary_exists?) watir_definition.should respond_to(:summary_visible?) watir_definition.should respond_to(:summary_enabled?) watir_definition.should respond_to(:summary?) watir_definition.should respond_to(:summary_?) watir_definition.should respond_to(:summary!) watir_definition.should respond_to(:summary=) end end context "when used by the watir platform" do it "should locate the text area" do watir_browser.should_receive(:text_area).and_return(watir_browser) web_object = watir_definition.summary_object web_object.should_not be_nil web_object.should be_instance_of Symbiont::WebObjects::TextArea end it "should retrieve text from the text area" do watir_browser.should_receive(:text_area).and_return(watir_browser) watir_browser.should_receive(:value).and_return("testing") watir_definition.summary.should == "testing" end it "should enter text into a text area" do watir_browser.should_receive(:text_area).and_return(watir_browser) watir_browser.should_receive(:set).with("testing") watir_definition.summary = "testing" end it "should determine if a text area exists" do watir_browser.should_receive(:text_area).twice.and_return(watir_browser) watir_browser.should_receive(:exists?).twice.and_return(watir_browser) watir_definition.summary_exists?.should be_true watir_definition.summary?.should be_true end it "should determine if a text area is visible" do watir_browser.should_receive(:text_area).twice.and_return(watir_browser) watir_browser.should_receive(:present?).twice.and_return(watir_browser) watir_definition.summary_visible?.should be_true watir_definition.summary_?.should be_true end it "should determine if a text area is enabled" do watir_browser.should_receive(:text_area).twice.and_return(watir_browser) watir_browser.should_receive(:enabled?).twice.and_return(watir_browser) watir_definition.summary_enabled?.should be_true watir_definition.summary!.should be_true end it "should call a block on the text area if specified" do watir_definition.description_object.should == "description" end end end end