From ea193e15d2107019bf898d5d1d6d091327441c99 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 5 Nov 2008 18:24:48 -0500 Subject: [PATCH] Rename checks and unchecks to check and uncheck --- lib/webrat/core/scope.rb | 12 +++++------ lib/webrat/selenium/selenium_session.rb | 4 +++- spec/api/check_spec.rb | 28 ++++++++++++------------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb index f2336bc..f4cb8ab 100644 --- a/lib/webrat/core/scope.rb +++ b/lib/webrat/core/scope.rb @@ -36,23 +36,23 @@ module Webrat # 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. diff --git a/lib/webrat/selenium/selenium_session.rb b/lib/webrat/selenium/selenium_session.rb index 5d8f650..e9db203 100644 --- a/lib/webrat/selenium/selenium_session.rb +++ b/lib/webrat/selenium/selenium_session.rb @@ -91,10 +91,12 @@ module Webrat @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 diff --git a/spec/api/check_spec.rb b/spec/api/check_spec.rb index cd357f1..647a27a 100644 --- a/spec/api/check_spec.rb +++ b/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 @@ -11,7 +11,7 @@ describe "checks" do 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 @@ -21,7 +21,7 @@ describe "checks" do 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 @@ -34,7 +34,7 @@ describe "checks" do EOS @session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) - @session.checks "TOS" + @session.check "TOS" @session.clicks_button end @@ -46,7 +46,7 @@ describe "checks" do EOS @session.should_receive(:post).with("/login", "remember_me" => "on") - @session.checks "remember_me" + @session.check "remember_me" @session.clicks_button end @@ -57,7 +57,7 @@ describe "checks" do 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 @@ -68,12 +68,12 @@ describe "checks" do 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 @@ -84,7 +84,7 @@ describe "unchecks" do 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 @@ -94,7 +94,7 @@ describe "unchecks" do 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 @@ -104,7 +104,7 @@ describe "unchecks" do 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 @@ -117,8 +117,8 @@ describe "unchecks" do 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 @@ -130,7 +130,7 @@ describe "unchecks" do EOS @session.should_receive(:post).with("/login", {}) - @session.unchecks "remember_me" + @session.uncheck "remember_me" @session.clicks_button end end