繁体   English   中英

Michael Hartl撰写的Ruby on Rails教程第7.25章

[英]Ruby on Rails Tutorial by Michael Hartl Chapter 7.25

嗨,我是通过Hartl工作的新手。 在最近的灾难之后,我已经能够将我的应用恢复到接近工作的状态(感谢Github!)。 我现在在测试中犯了一个错误。 因此,当我运行测试时,我得到:

sis-macbook-pro:sample_app Lagaspi$ bundle exec rspec spec/
..............................F

Failures:

1) User pages signup with valid information after saving the user 
 Failure/Error: it { should have_link('Sign out') }
   expected link "Sign out" to return something
 # ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'

Finished in 0.61988 seconds
31 examples, 1 failure

Failed examples:

rspec ./spec/requests/user_pages_spec.rb:48 # User pages signup with valid information after saving the user 

这是我的user_pages_spec.rb

require 'spec_helper'

describe "User pages" do

subject { page }

describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }

describe "signup" do
before { visit signup_path }

it { should have_selector('h1',    text: 'Sign up') }
it { should have_selector('title', text: full_title('Sign up')) }
end

it { should have_selector('h1',    text: user.name) }
it { should have_selector('title', text: user.name) }
end

describe "signup" do

before { visit signup_path }

let(:submit) { "Create my account" }

describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end

describe "with valid information" do
before do
fill_in "Name",         with: "Example User"
fill_in "Email",        with: "user@example.com"
fill_in "Password",     with: "foobar"
fill_in "Confirmation", with: "foobar"
end

it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
  end

  describe "after saving the user" do
before { click_button submit }
it { should have_link('Sign out') }
end
end
end
end

提前致谢。

请检查您的“退出”链接,那里可能出了点问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM