Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename chooses to choose
  • Loading branch information
brynary committed Nov 5, 2008
1 parent 24ac5d3 commit c5bf4f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/webrat/core/scope.rb
Expand Up @@ -58,12 +58,12 @@ def uncheck(id_or_name_or_label)
# 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
Expand Down
4 changes: 3 additions & 1 deletion lib/webrat/selenium/selenium_session.rb
Expand Up @@ -90,9 +90,11 @@ def selects(option_text, options = {})
@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}")
Expand Down
18 changes: 9 additions & 9 deletions spec/api/choose_spec.rb
@@ -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
Expand All @@ -11,7 +11,7 @@
</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
Expand All @@ -21,7 +21,7 @@
</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
Expand All @@ -35,7 +35,7 @@
</form>
EOS
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.choose "Male"
@session.clicks_button
end

Expand All @@ -50,8 +50,8 @@
</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

Expand All @@ -63,7 +63,7 @@
</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
Expand All @@ -74,7 +74,7 @@
</form>
EOS
@session.should_receive(:post).with("/login", "first_option" => "on")
@session.chooses "first_option"
@session.choose "first_option"
@session.clicks_button
end

Expand All @@ -100,7 +100,7 @@
</form>
EOS
@session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.choose "Male"
@session.clicks_button
end
end

0 comments on commit c5bf4f3

Please sign in to comment.