开发者

Integration Test Failing in Modification of Hartl sample_app

I'm trying to slightly modify the functionality of Hartl's Ruby On Rails Tutorial and am getting a completely mysterious error from my new integration test.

This is on the Signup page. Instead of user name, email and password fields, I've only got email and question fields. (Not a big change, right?) The form is identical except for the renamed fields (and I'm using a field :baremail for unencrypted email--I encrypt the email address for the database). The route configuration is the same ( match '/signup', :to => 'users#new' ).

Here's the relevant portion of the spec/requests/users_spec.rb file:

require 'spec_helper'

describe "Users" do

  describe "signup" do

    describe "failure" do
      it "should not accept a bogus email" do
        lambda do
          visit signup_path
          fill_in "Question",     :with => ""
          fill_in :baremail,        :with => " bogus email"
          click_button
          response.should render_template('users/new')
          response.should have_selector("div#error_explanation")
        end.should_not change(User, :count)
      end

      it "should not accept a question without an email"  do
        lambda do
          visit signup_path
          fill_in :question,     :with => "What, me worry?"
          fill_in :baremail,        :with => ""
          click_button
          response.should render_template('users/new')
          response.should have_selector("div#error_explanation")
        end.should_not change(User, :count)
      end

(Notice that these two tests use two different protocols for fill_in.)

Here's what I get in response:

  1) Users signup failure should not accept a bogus email
     Failure/Error: fill_in "Question",     :with => ""
     Nokogiri::CSS::SyntaxError:
       unexpected '(' after 'DESCENDANT_SELECTOR'
     # ./spec/requests/users_spec.rb:11:in `block (5 levels) in <top (required)>'
     # ./spec/requests/users_spec.rb:9:in `block (4 levels) in <top (required)>'

  2) Users signup failure should not accept a question without an email
     Failure/Error: fill_in :question,     :with => "What, me worry?"
     Nokogiri::CSS::SyntaxError:
       unexpected '(' after 'DESCENDANT_SELECTOR'
     # ./spec/requests/users_spec.rb:22:in `block (5 levels) in <top (required)>'
     # ./spec/requests/users_spec.rb:20:in `block (4 levels) in <top (required)>

...etc. I have tried replacing signup_path with a string (in case signup_path wasn't defined), with no effect. I have swapped the :question and :email lines in the Rspec file; it throws the error on whi开发者_开发技巧chever one is first.

By the way, the pages work fine. It's only the test that is failing.

Any clues for the clueless?


Edit: turns out I'm wrong, fill_in does take symbols. Original post is below.

What happens if you change the :baremail and :question symbols to strings? As far as I can tell, fill_in doesn't take symbols.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜