Forum: Ruby on Rails assert_select tag in Rails 1.2.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
on 2007-02-28 19:03
(Received via mailing list)
Rails 1.2.2 names the form elements like contact[subject],
contact[body] and so on. The following code does not work in latest
version.

def test_login_form_has_all_fields
    get :login
    assert_select "form[action=http://myapp/login] input" do |inputs|
        assert_equal 3, inputs.size
        assert_select inputs[0], "input[type=name][name=username]"
        assert_select inputs[1], "input[type=password][name=password]"
        assert_select inputs[2], "input[type=submit][value=Login]"
    end
end

When the name is changed to contact[subject] format, it bombs out
saying square brackets are not right selector.

Does anyone know how to check the form elements using assert_select
tag? TIA.
Phlip (Guest)
on 2007-02-28 21:25
(Received via mailing list)
bcparanj wrote:

> Does anyone know how to check the form elements using assert_select
> tag? TIA.

You could query by id, typically "user_username".

I just do this. Much more powerful:

  form = select_form 'my_form_id'
  assert_equal 'foo', form['user[username]']
  form.submit

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!
This topic is locked and can not be replied to.