From 18e65bfa4457b3e3a25f39f846f14cf8255cf454 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Fri, 28 Nov 2008 00:55:45 -0500 Subject: [PATCH] Cleaning up some more specs --- spec/api/click_button_spec.rb | 6 ++--- spec/api/locators/field_by_xpath_spec.rb | 4 ++- spec/api/matchers_spec.rb | 2 -- spec/webrat/core/field_spec.rb | 34 +++++++++++++++++++++--- spec/webrat/core/session_spec.rb | 2 +- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/spec/api/click_button_spec.rb b/spec/api/click_button_spec.rb index ab6913d..70f5b15 100644 --- a/spec/api/click_button_spec.rb +++ b/spec/api/click_button_spec.rb @@ -209,10 +209,10 @@ describe "click_button" do with_html <<-HTML
- - + + - +
diff --git a/spec/api/locators/field_by_xpath_spec.rb b/spec/api/locators/field_by_xpath_spec.rb index e92d081..c63b560 100644 --- a/spec/api/locators/field_by_xpath_spec.rb +++ b/spec/api/locators/field_by_xpath_spec.rb @@ -12,6 +12,8 @@ describe "field_by_xpath" do HTML - field_by_xpath(".//input").id.should == "element_42" + field = field_by_xpath(".//input") + field.should_not be_nil + field.id.should == "element_42" end end diff --git a/spec/api/matchers_spec.rb b/spec/api/matchers_spec.rb index c879ff6..af885b3 100644 --- a/spec/api/matchers_spec.rb +++ b/spec/api/matchers_spec.rb @@ -6,7 +6,6 @@ describe Webrat::Matchers do before(:each) do @body = <<-HTML -
hello, world!
- HTML end diff --git a/spec/webrat/core/field_spec.rb b/spec/webrat/core/field_spec.rb index 7179968..fa741f9 100644 --- a/spec/webrat/core/field_spec.rb +++ b/spec/webrat/core/field_spec.rb @@ -3,24 +3,50 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper") module Webrat describe CheckboxField do it "should say it is checked if it is" do - checkbox = CheckboxField.new(nil, (Webrat::XML.document("").search('input')).first) + html = <<-HTML + + + + HTML + + element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first + checkbox = CheckboxField.new(nil, element) checkbox.should be_checked end it "should say it is not checked if it is not" do - checkbox = CheckboxField.new(nil, (Webrat::XML.document("").search('input')).first) + html = <<-HTML + + + + HTML + + element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first + checkbox = CheckboxField.new(nil, element) checkbox.should_not be_checked end end describe RadioField do it "should say it is checked if it is" do - radio_button = RadioField.new(nil, (Webrat::XML.document("").search('input')).first) + html = <<-HTML + + + + HTML + + element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first + radio_button = RadioField.new(nil, element) radio_button.should be_checked end it "should say it is not checked if it is not" do - radio_button = RadioField.new(nil, (Webrat::XML.document("").search('input')).first) + html = <<-HTML + + HTML + + element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first + radio_button = RadioField.new(nil, element) radio_button.should_not be_checked end end diff --git a/spec/webrat/core/session_spec.rb b/spec/webrat/core/session_spec.rb index 6fdcc48..c0a5974 100644 --- a/spec/webrat/core/session_spec.rb +++ b/spec/webrat/core/session_spec.rb @@ -18,7 +18,7 @@ describe Webrat::Session do "" end - session.current_dom.should respond_to(:search) + session.should respond_to(:current_dom) end it "should open the page in the browser in MacOSX" do