Rename checks and unchecks to check and uncheck

This commit is contained in:
Bryan Helmkamp 2008-11-05 18:24:48 -05:00
parent 5e531f1a0a
commit ea193e15d2
3 changed files with 23 additions and 21 deletions

View File

@ -36,23 +36,23 @@ module Webrat
# as checked, so that the value will be submitted with the form. # as checked, so that the value will be submitted with the form.
# #
# Example: # Example:
# checks 'Remember Me' # check 'Remember Me'
def checks(id_or_name_or_label) def check(id_or_name_or_label)
find_field(id_or_name_or_label, CheckboxField).check find_field(id_or_name_or_label, CheckboxField).check
end end
alias_method :check, :checks alias_method :checks, :check
# Verifies that an input checkbox exists on the current page and marks it # 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. # as unchecked, so that the value will not be submitted with the form.
# #
# Example: # Example:
# unchecks 'Remember Me' # uncheck 'Remember Me'
def unchecks(id_or_name_or_label) def uncheck(id_or_name_or_label)
find_field(id_or_name_or_label, CheckboxField).uncheck find_field(id_or_name_or_label, CheckboxField).uncheck
end end
alias_method :uncheck, :unchecks alias_method :unchecks, :uncheck
# Verifies that an input radio button exists on the current page and marks it # 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. # as checked, so that the value will be submitted with the form.

View File

@ -91,10 +91,12 @@ module Webrat
@selenium.click("webrat=#{label_text}") @selenium.click("webrat=#{label_text}")
end end
def checks(label_text) def check(label_text)
@selenium.check("webrat=#{label_text}") @selenium.check("webrat=#{label_text}")
end end
alias_method :checks, :check
def is_ordered(*args) def is_ordered(*args)
@selenium.is_ordered(*args) @selenium.is_ordered(*args)
end end

View File

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "checks" do describe "check" do
before do before do
@session = Webrat::TestSession.new @session = Webrat::TestSession.new
end end
@ -11,7 +11,7 @@ describe "checks" do
</form> </form>
EOS EOS
lambda { @session.checks "remember_me" }.should raise_error lambda { @session.check "remember_me" }.should raise_error
end end
it "should fail if input is not a checkbox" do it "should fail if input is not a checkbox" do
@ -21,7 +21,7 @@ describe "checks" do
</form> </form>
EOS EOS
lambda { @session.checks "remember_me" }.should raise_error lambda { @session.check "remember_me" }.should raise_error
end end
it "should check rails style checkboxes" do it "should check rails style checkboxes" do
@ -34,7 +34,7 @@ describe "checks" do
</form> </form>
EOS EOS
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) @session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
@session.checks "TOS" @session.check "TOS"
@session.clicks_button @session.clicks_button
end end
@ -46,7 +46,7 @@ describe "checks" do
</form> </form>
EOS EOS
@session.should_receive(:post).with("/login", "remember_me" => "on") @session.should_receive(:post).with("/login", "remember_me" => "on")
@session.checks "remember_me" @session.check "remember_me"
@session.clicks_button @session.clicks_button
end end
@ -57,7 +57,7 @@ describe "checks" do
<input type="submit" /> <input type="submit" />
</form> </form>
EOS EOS
lambda { @session.checks "remember_me" }.should raise_error lambda { @session.check "remember_me" }.should raise_error
end end
it "should result in a custom value being posted" do it "should result in a custom value being posted" do
@ -68,12 +68,12 @@ describe "checks" do
</form> </form>
EOS EOS
@session.should_receive(:post).with("/login", "remember_me" => "yes") @session.should_receive(:post).with("/login", "remember_me" => "yes")
@session.checks "remember_me" @session.check "remember_me"
@session.clicks_button @session.clicks_button
end end
end end
describe "unchecks" do describe "uncheck" do
before do before do
@session = Webrat::TestSession.new @session = Webrat::TestSession.new
end end
@ -84,7 +84,7 @@ describe "unchecks" do
</form> </form>
EOS EOS
lambda { @session.unchecks "remember_me" }.should raise_error lambda { @session.uncheck "remember_me" }.should raise_error
end end
it "should fail if input is not a checkbox" do it "should fail if input is not a checkbox" do
@ -94,7 +94,7 @@ describe "unchecks" do
</form> </form>
EOS EOS
lambda { @session.unchecks "remember_me" }.should raise_error lambda { @session.uncheck "remember_me" }.should raise_error
end end
it "should fail if the checkbox is disabled" do it "should fail if the checkbox is disabled" do
@ -104,7 +104,7 @@ describe "unchecks" do
<input type="submit" /> <input type="submit" />
</form> </form>
EOS EOS
lambda { @session.unchecks "remember_me" }.should raise_error lambda { @session.uncheck "remember_me" }.should raise_error
end end
it "should uncheck rails style checkboxes" do it "should uncheck rails style checkboxes" do
@ -117,8 +117,8 @@ describe "unchecks" do
</form> </form>
EOS EOS
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"}) @session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
@session.checks "TOS" @session.check "TOS"
@session.unchecks "TOS" @session.uncheck "TOS"
@session.clicks_button @session.clicks_button
end end
@ -130,7 +130,7 @@ describe "unchecks" do
</form> </form>
EOS EOS
@session.should_receive(:post).with("/login", {}) @session.should_receive(:post).with("/login", {})
@session.unchecks "remember_me" @session.uncheck "remember_me"
@session.clicks_button @session.clicks_button
end end
end end