From 118cf0340ad62b9a01c1dd46a7dd10d21269153e Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 7 Apr 2008 20:35:06 -0400 Subject: [PATCH] Fix some bugs uncovered when running the weplay scenarios --- lib/webrat.rb | 4 ++++ lib/webrat/field.rb | 2 +- lib/webrat/page.rb | 4 +++- lib/webrat/select_option.rb | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/webrat.rb b/lib/webrat.rb index 018355f..d01de62 100644 --- a/lib/webrat.rb +++ b/lib/webrat.rb @@ -18,6 +18,10 @@ module ActionController @current_page ||= Webrat::Page.new(self) end + def current_page=(new_page) + @current_page = new_page + end + # Issues a GET request for a page, follows any redirects, and verifies the final page # load was successful. # diff --git a/lib/webrat/field.rb b/lib/webrat/field.rb index 51ad39b..e021652 100644 --- a/lib/webrat/field.rb +++ b/lib/webrat/field.rb @@ -102,7 +102,7 @@ module Webrat class ButtonField < Field def matches_value?(value) - @element["value"] =~ /^\W*#{value}\b/i + @element["value"] =~ /^\W*#{Regexp.escape(value.to_s)}\b*/i end def to_param diff --git a/lib/webrat/page.rb b/lib/webrat/page.rb index 1e8376e..8d539b2 100644 --- a/lib/webrat/page.rb +++ b/lib/webrat/page.rb @@ -13,9 +13,11 @@ module Webrat @url = url @method = method @data = data - + reset_dom reloads if @url + + session.current_page = self end # Verifies an input field or textarea exists on the current page, and stores a value for diff --git a/lib/webrat/select_option.rb b/lib/webrat/select_option.rb index a1ba3a6..f687941 100644 --- a/lib/webrat/select_option.rb +++ b/lib/webrat/select_option.rb @@ -6,8 +6,8 @@ module Webrat @element = element end - def matches_text?(text) - @element.innerHTML =~ /^\W*#{Regexp.escape(text.to_s)}\b/i + def matches_text?(text) + @element.innerHTML == text.to_s end def choose