Rename chooses to choose

This commit is contained in:
Bryan Helmkamp 2008-11-05 18:29:04 -05:00
parent 24ac5d3fb7
commit c5bf4f30f6
3 changed files with 15 additions and 13 deletions

View File

@ -58,12 +58,12 @@ module Webrat
# as checked, so that the value will be submitted with the form.
#
# Example:
# chooses 'First Option'
def chooses(label)
# choose 'First Option'
def choose(label)
find_field(label, RadioField).choose
end
alias_method :choose, :chooses
alias_method :chooses, :choose
# Verifies that a an option element exists on the current page with the specified
# text. You can optionally restrict the search to a specific select list by

View File

@ -90,10 +90,12 @@ module Webrat
@selenium.select(select_locator, option_text)
end
def chooses(label_text)
def choose(label_text)
@selenium.click("webrat=#{label_text}")
end
alias_method :chooses, :choose
def check(label_text)
@selenium.check("webrat=#{label_text}")
end

View File

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "chooses" do
describe "choose" do
before do
@session = Webrat::TestSession.new
end
@ -11,7 +11,7 @@ describe "chooses" do
</form>
EOS
lambda { @session.chooses "first option" }.should raise_error
lambda { @session.choose "first option" }.should raise_error
end
it "should fail if input is not a radio button" do
@ -21,7 +21,7 @@ describe "chooses" do
</form>
EOS
lambda { @session.chooses "first_option" }.should raise_error
lambda { @session.choose "first_option" }.should raise_error
end
it "should check rails style radio buttons" do
@ -35,7 +35,7 @@ describe "chooses" do
</form>
EOS
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.choose "Male"
@session.clicks_button
end
@ -50,8 +50,8 @@ describe "chooses" do
</form>
EOS
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Female"
@session.chooses "Male"
@session.choose "Female"
@session.choose "Male"
@session.clicks_button
end
@ -63,7 +63,7 @@ describe "chooses" do
</form>
EOS
lambda { @session.chooses "first_option" }.should raise_error
lambda { @session.choose "first_option" }.should raise_error
end
it "should result in the value on being posted if not specified" do
@ -74,7 +74,7 @@ describe "chooses" do
</form>
EOS
@session.should_receive(:post).with("/login", "first_option" => "on")
@session.chooses "first_option"
@session.choose "first_option"
@session.clicks_button
end
@ -100,7 +100,7 @@ describe "chooses" do
</form>
EOS
@session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.choose "Male"
@session.clicks_button
end
end