[rspec-users] matcher to see if radio button is selected at page load

Pau Cor lists at ruby-forum.com
Tue Nov 25 23:16:02 EST 2008


Hi. I'm trying to write a matcher to make sure a radio button is
selected when the page loads.

I got this at the moment:

When /^I leave "(.*)" selected$/ do |label|
  field = field_labeled label
  unless field.instance_variable_get("@element")['checked'] &&
field.instance_variable_get("@element")['checked'] == "checked"
    raise "Expected radio button with label #{label} to be checked, but
it wasn't"
  end
end

But I'm kind of assuming that there is a reason that @element isn't
accessible. Is there a better way to do this?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list