Skip to content

Commit

Permalink
Rename checks and unchecks to check and uncheck
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 5, 2008
1 parent 5e531f1 commit ea193e1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
12 changes: 6 additions & 6 deletions lib/webrat/core/scope.rb
Expand Up @@ -36,23 +36,23 @@ def fill_in(id_or_name_or_label, options = {})
# as checked, so that the value will be submitted with the form.
#
# Example:
# checks 'Remember Me'
def checks(id_or_name_or_label)
# check 'Remember Me'
def check(id_or_name_or_label)
find_field(id_or_name_or_label, CheckboxField).check
end

alias_method :check, :checks
alias_method :checks, :check

# Verifies that an input checkbox exists on the current page and marks it
# as unchecked, so that the value will not be submitted with the form.
#
# Example:
# unchecks 'Remember Me'
def unchecks(id_or_name_or_label)
# uncheck 'Remember Me'
def uncheck(id_or_name_or_label)
find_field(id_or_name_or_label, CheckboxField).uncheck
end

alias_method :uncheck, :unchecks
alias_method :unchecks, :uncheck

# Verifies that an input radio button exists on the current page and marks it
# as checked, so that the value will be submitted with the form.
Expand Down
4 changes: 3 additions & 1 deletion lib/webrat/selenium/selenium_session.rb
Expand Up @@ -91,10 +91,12 @@ def chooses(label_text)
@selenium.click("webrat=#{label_text}")
end

def checks(label_text)
def check(label_text)
@selenium.check("webrat=#{label_text}")
end

alias_method :checks, :check

def is_ordered(*args)
@selenium.is_ordered(*args)
end
Expand Down
28 changes: 14 additions & 14 deletions spec/api/check_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe "checks" do
describe "check" do
before do
@session = Webrat::TestSession.new
end
Expand All @@ -11,7 +11,7 @@
</form>
EOS

lambda { @session.checks "remember_me" }.should raise_error
lambda { @session.check "remember_me" }.should raise_error
end

it "should fail if input is not a checkbox" do
Expand All @@ -21,7 +21,7 @@
</form>
EOS

lambda { @session.checks "remember_me" }.should raise_error
lambda { @session.check "remember_me" }.should raise_error
end

it "should check rails style checkboxes" do
Expand All @@ -34,7 +34,7 @@
</form>
EOS
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
@session.checks "TOS"
@session.check "TOS"
@session.clicks_button
end

Expand All @@ -46,7 +46,7 @@
</form>
EOS
@session.should_receive(:post).with("/login", "remember_me" => "on")
@session.checks "remember_me"
@session.check "remember_me"
@session.clicks_button
end

Expand All @@ -57,7 +57,7 @@
<input type="submit" />
</form>
EOS
lambda { @session.checks "remember_me" }.should raise_error
lambda { @session.check "remember_me" }.should raise_error
end

it "should result in a custom value being posted" do
Expand All @@ -68,12 +68,12 @@
</form>
EOS
@session.should_receive(:post).with("/login", "remember_me" => "yes")
@session.checks "remember_me"
@session.check "remember_me"
@session.clicks_button
end
end

describe "unchecks" do
describe "uncheck" do
before do
@session = Webrat::TestSession.new
end
Expand All @@ -84,7 +84,7 @@
</form>
EOS

lambda { @session.unchecks "remember_me" }.should raise_error
lambda { @session.uncheck "remember_me" }.should raise_error
end

it "should fail if input is not a checkbox" do
Expand All @@ -94,7 +94,7 @@
</form>
EOS

lambda { @session.unchecks "remember_me" }.should raise_error
lambda { @session.uncheck "remember_me" }.should raise_error
end

it "should fail if the checkbox is disabled" do
Expand All @@ -104,7 +104,7 @@
<input type="submit" />
</form>
EOS
lambda { @session.unchecks "remember_me" }.should raise_error
lambda { @session.uncheck "remember_me" }.should raise_error
end

it "should uncheck rails style checkboxes" do
Expand All @@ -117,8 +117,8 @@
</form>
EOS
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
@session.checks "TOS"
@session.unchecks "TOS"
@session.check "TOS"
@session.uncheck "TOS"
@session.clicks_button
end

Expand All @@ -130,7 +130,7 @@
</form>
EOS
@session.should_receive(:post).with("/login", {})
@session.unchecks "remember_me"
@session.uncheck "remember_me"
@session.clicks_button
end
end

0 comments on commit ea193e1

Please sign in to comment.