SOLVED 3 June 2013 15:35 GMT/23.35 SGT
Thank you, +Drew Ulmer, my default DatabaseCleaner setup was indeed the culprit. Changing the strategy to :truncation fixed the problem. Of course, the idea that a database-cleanup utility could FUBAR your spec-automation tool in such a way that valid specs would fail, in your word, non-deterministically, is a Nietzsche incident. ("That which does not kill you makes you stronger.")
UPDATED 3 June 2013 11:08 GMT/19:08 SGT
Sort-of solved; using the exact same spec_helper.rb
file as I was using on a different project that successfully deals with feature specs (but not JavaScript testing, yet) got me back to a known point. I've attached the earlier and current spec_helper.rb
files for your spelunking pleasure.
Importantly, the spec at line 14 of user_signs_in_and_sees_name_greeting_spec.rb
can either work or have the js: true
option set; it can't (presently) have both.
I still don't know:
- why enabling JS testing with either spec helper fails, even when no JS code is actually tested;
- what changes really need to make to do authomated Script testing from RSpec; and thus
- why the 'working'
spec_helper.rb
works and the 'non-working' one doesn't.
What am I missing here?
Very simple POC project with User model and feature spec as attached here. Feature spec fills in a (Devise-generated) login form and clicks the button. Zero rocket science here; we're at "RSpec Feature Specs with Capybara" 101, Exercise 1.
So how come
1. the form never gets the password value, and thus responds with expectable-under-the-circumstances `Username or password invalid`? Think the password isn't there? Uncomment lines 12 and 20 and see that the outputs from the `puts` calls match.
2. if you uncomment the `save_and_open_page` at line 22, it doesn't show the browser browser page *as Selenium saw it at that point*, but rather your *default* browser, at the (empty) login page, and oh yeah, the {Java,Coffee}Script files and stylesheets that are included in the "real" page, aren't?
I've been beating my head against this for an hour and all I have to show for my efforts is a headache. Any help appreciated; this has to be so basic I'm just not seeing it.
Attachments:
3. `spec/features/user_signs_in_and_sees_name_greeting_spec.rb`: **The spec demonstrating the confusion.**;
1. `app/models/user.rb`: a vestigial User class, with Devise bloviage included;
2. `spec/spec_helper.rb`: lines to note are 17-18, 33 and 69, where Capybara is wired in;
4. `spec/support/features.rb`: Configuration wiring for feature session helpers, per [Thoughtbot](http://robots.thoughtbot.com/post/33771089985/);
5. **Newly added** Output from `rake routes` command.
*Note that* through the "magic" of Github, these attachments do not appear in the order they were attached (or listed here).
Any ideas?