lib/mechanical-cuke/web_steps.rb in mechanical-cuke-0.2.0 vs lib/mechanical-cuke/web_steps.rb in mechanical-cuke-0.3.0

- old
+ new

@@ -37,10 +37,21 @@ f = find_field(field) raise "Can't find field \"#{field}\"" if f.nil? f.option_with(:value => value).select end + +When /^(?:|I )check "([^\"]*)"$/ do |field| + cb = find_checkbox(field) + cb.checked = true +end + +When /^(?:|I )uncheck "([^\"]*)"$/ do |field| + cb = find_checkbox(field) + cb.checked = false +end + When /^(?:|I )choose "([^\"]*)"$/ do |field| r = find_radiobutton(field) raise "Can't find radio button \"#{field}\"" if r.nil? r.check end @@ -79,9 +90,45 @@ But /^(?:|I )should not see "([^\"]*)"$/ do |text| if defined?(Spec::Rails::Matchers) response.should_not contain(text) else assert !current_page.body.include?(text) + end +end + +Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value| + f = find_field(field) + if defined?(Spec::Rails::Matchers) + f.should == field + else + assert_equal value, f.value + end +end + +Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value| + f = find_field(field) + if defined?(Spec::Rails::Matchers) + f.should_not == value + else + assert_not_equal value, f.value + end +end + +Then /^the "([^\"]*)" checkbox should be checked$/ do |label| + cb = find_checkbox(label) + if defined?(Spec::Rails::Matchers) + cb.checked.should be true + else + assert cb.checked + end +end + +Then /^the "([^\"]*)" checkbox should not be checked$/ do |label| + cb = find_checkbox(label) + if defined?(Spec::Rails::Matchers) + cb.checked.should be true + else + assert !cb.checked end end Then /^(?:|I )should be on (.+)$/ do |page_name| current_path = current_page.uri.to_s