index.html.erb code not really testing the count.
Reported by Stephen Anderson | August 21st, 2008 @ 06:40 PM | in No-Milestone-Assigned
"script/generate rspec_scaffold model_name name:string" creates a spec/views/model_name/index.html.erb_spec.rb file that contains this line: "response.should have_tag("tr>td", "value for name", 2)"
This line passes, BUT the count of 2 isn't really being tested. You can verify this by changing the 2 to a 999 and watching the test continue to pass.
The line WILL test the count if changed to: "response.should have_tag("tr>td", :text => "value for name", :count => 2)"
Comments and changes to this ticket
-
Pat Maddox October 21st, 2008 @ 12:27 AM
Stephen, any interest in submitting a patch? We'd love to get your name on the community page...
-
Stephen Anderson October 29th, 2008 @ 04:18 PM
- → Tag changed from bug generators matchers rspec_on_rails to bug generators matchers rspec-rails
Yes, I'm interested in doing so.
Could you please point me to some doc on running the rspec-rails tests? When I run ake spec:plugins:rspec_on_rails I receive 426 errors saying that Table people doesn't exist.
Now I could put a people table in my application temporarily, but that would just be ignoring the fact I don't know how to properly run the rspec-rails tests.
And of course, I don't want to submit a patch without the corresponding test.
Thanks! -Steve-
-
Pat Maddox October 29th, 2008 @ 05:27 PM
Stephen, here are the basic steps you take:
cd rspec-dev/example_rails_app ./script/generate rspec cd vendor/plugins/rspec-rails ruby spec/rails/..._spec.rbYou can use the spec bin if you want to use --line or -e or something:
../../../script/spec spec/rails/example/assigns_hash_proxy_spec.rb -
Pat Maddox October 29th, 2008 @ 05:28 PM
Also, before submitting the patch, run "rake pre_commit" from rspec-dev to make sure you haven't broken anything.
-
Stephen Anderson October 29th, 2008 @ 11:16 PM
In following your instructions here, and here I'm seeing that the output from script/generate rspec_scaffold ... is not tested.
I replaced the entire contents of rspec-dev/example_rails_app/vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb with puts 'FUBAR' and no test failed.
Is it worth opening a separate ticket to introduce testing of code generator output? (i.e.: Is it spitting out the code we expect?)
If so, then is it also worthwhile to test the behavior or that generated code as well? (i.e.: Does the generated code work?) This is the level where this bug ticket would be tested.
Am I overlooking somewhere where this actually is being tested?
Should I just submit this patch with no accompanying test? This is probably the path of least resistance for now. The other questions could be split into separate tickets and considered on their own merits...
-
Pat Maddox October 30th, 2008 @ 12:47 AM
I think you're right that currently the generate specs aren't actually being tested. But it probably makes sense to do so...we'd like to make sure that the specs we generate actually work, right?
I'm not 100% sure on this, as I don't use the resource generator at all anyway. Maybe David or Aslak would care to weigh in?
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
