You can clone with
HTTPS or Subversion.
I'm confused by the assert_select code generated by rspec-rails/lib/generators/rspec/scaffold/templates/edit_spec.rb and new_spec.rb.
Specifically, it generates code like this:
assert_select "form", :action => foos_path(@foo), :method => "post" do
I can't find any documentation for the :action and :method options for ActionDispatch::Assertions::SelectorAssertions#assert_select. Furthermore, mangling the values for those options doesn't seem to have any impact on whether the assertion succeeds or not, leading me to believe those options don't actually do anything.
It looks like ActionDispatch::Assertions::SelectorAssertions#assert_select eventually assigns the hash to equals (from which it does use the :text, :html, :count, etc. options), but it never calls assert_valid_keys on equals. Which explains why it doesn't complain about the invalid options, thus allowing the scaffold code to continue to appear to test something it's not actually testing.
On the other hand, it is entirely conceivable that I'm just really confused, and if so I apologize!
@dchelimsky, do you know anything about assert_select taking these arguments? It looks like the scaffold generator started including them during a refactor related to webrat, but I came late enough to the game that I'm not familiar with it. I will dig if needed, but thought you might know offhand.
Actually, I just found http://content.labnotes.org/assert_select/assert_select.html, which has this example at the bottom:
assert_select "html:root>head>title", "Login"
assert_select "form[action=?]", url_for(:action=>"login") do
So the generated code might have been a typo based on :action => "login" without wrapping it in url_for. Just guessing.
:action => "login"
Thanks @dchelimsky, that makes more sense. After digging a bit more myself, I've improved the specs that will be generated by scaffolding.
Uses assert_select correctly in edit scaffolded specs
* Fixes #664