Hi all,

  I am trying to figure out how to use assert_select properly.

 When I created a new resource in rails 3 called Brands, the view
specs for brands had a test which read:

    # Run the generator again with the --webrat flag if you want to
use webrat matchers
    assert_select "form", :action => brands_path, :method => "post" do
      assert_select "input#brand_name", :name => "brand[name]"
      assert_select "input#brand_description", :name =>
"brand[description]"
      assert_select "input#brand_created_by", :name =>
"brand[created_by]"
    end


With my project, I do not want the "created by" attribute
to be set from the new.html.erb entry form.


I read http://content.labnotes.org/assert_select/assert_select.html
and figured I need to use the 'false' equality operator.

It also says the following:


---------- extract starts --------------
assert_select(selector, *values, equality?, message?) { |elems| ... }
assert_select(element, selector, *values, equality?, message?) { |
elems| ... }
---------- extract ends --------------

Alas, my attempts at using it failed.

For  a spec/statement such as 'assert_select
input#brand_created_by", :name => "brand[created_by]',
 I would think that input#brand_created_by would be the 'element' and
the 'selector' combined.

Since I need to use the 'false' equality operator,
1) how do i give null to *values? I have tried the following to no
success and kept getting syntax errors:

a) assert_select "input#brand_created_by", :name =>
"brand[created_by]", '', false   --> spec/views/brands/
new.html.erb_spec.rb:53: syntax error, unexpected ',', expecting
tASSOC (SyntaxError) …me => "brand[created_by]", '', false
b)  assert_select "input#brand_created_by", :name =>
"brand[created_by]", nil, false -->
spec/views/brands/new.html.erb_spec.rb:53: syntax error, unexpected
',', expecting tASSOC (SyntaxError)  ...me => "brand[created_by]",
nil, false
c)  assert_select "input#brand_created_by", :name =>
"brand[created_by]", , false --> spec/views/brands/
new.html.erb_spec.rb:53: syntax error, unexpected ',', expecting
keyword_end (SyntaxError) ...:name => "brand[created_by]", , false


 It looks as if any attempts I make to denote that I have no 'values'
to give to it is not working.

Can someone please tell me what the right syntax is for saying, "i
expect not to see the brand[created_by]" input attribute at all in the
rendered form for adding new entries?

Thank you :)
Gordon
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to