1:ubuntu 各文件已是最新。 2:搜了其他解决办法,清空 rvm(remove all),重新安装 ruby,建 gemset,然后 bundle update/install,还是不行。 3:bundle exec rspec spec/ -->出现一个红色 F 错误,后面“段错误(核心已转储)“ 4:bundle exec rspec spec/requests/user_pages_spec.rb -->测试通过 5:bundle exec rspec spec/requests/authentication_pages_spec.rb,分别出现Control frame information、C level backtrace information、Other runtime information、Process memory map 这几大块错误信息,总共 n 多行。 6:应用运行无错。
tiger@tigerPC:~/sample_app$ bundle exec rspec spec/
No DRb server is running. Running in local process instead ...
........[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
..............................................F段错误 (核心已转储)
tiger@tigerPC:~/sample_app$ bundle exec rspec spec/requests/user_pages_spec.rb
No DRb server is running. Running in local process instead ...
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
..................
Finished in 1.45 seconds
18 examples, 0 failures
Randomized with seed 43555
tiger@tigerPC:~/sample_app$ bundle exec rspec spec/requests/authentication_pages_spec.rb
No DRb server is running. Running in local process instead ...
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
........../home/tiger/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/example.rb:179: [BUG] vm_call_cfunc - cfp consistency error
ruby 2.0.0p576 (2014-09-19 revision 47628) [x86_64-linux]
-- Control frame information ------------------
Gemfile 如下:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
group :development, :test do
gem 'sqlite3', '1.3.7'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
gem 'spork-rails', github: 'railstutorial/spork-rails'
gem 'guard-spork', '1.5.0'
gem 'childprocess', '0.5.3'
end
group :test do
gem 'selenium-webdriver', '~>2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.1'
end
gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
gem 'bcrypt-ruby', '3.0.1'
authentication_pages_spec.rb 如下:
require 'spec_helper'
describe "AuthenticationPages" do
subject { page }
describe "signin page" do
before { visit signin_path }
it { should have_content('Sign in') }
it { should have_title('Sign in') }
end
describe "signin" do
before { visit signin_path }
describe "invalid" do
before { click_button "Sign in" }
it { should have_title("Sign in") }
it { should have_selector("div.alert.alert-error"), text: "invalid" }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
describe "valid" do
let(:user) { FactoryGirl.create(:user) }
before do
fill_in "Email", with: user.email.upcase
fill_in "Password", with: user.password
click_button "Sign in"
end
it { should have_title(user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Sign out'), href: signout_path }
it { should_not have_link('Sign in'), href: signin_path }
describe "after signouting" do
before { click_link 'Sign out' }
it { should have_link('Sign in') }
end
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
it { should have_link("Profile", href: user_path(user)) }
it { should have_link("Settings", href: edit_user_path(user)) }
it { should have_link("Sign out", href: signout_path) }
it { should have_title(user.name) }
it { should_not have_link("Sign in", href: signin_path) }
end
describe "访问权限控制" do
describe "对于未登录的用户" do
let(:user) { FactoryGirl.create(:user) }
describe "试图访问编辑页面时" do
before do
visit edit_user_path(user)
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Sign in"
end
describe "在登录后" do
it "应该转向之前用户想访问的页面" do
expect(page).to have_title("Edit user")
end
end
end
describe "在users控制器" do
describe "访问编辑页面" do
before { visit edit_user_path(user) }
it { should have_title("Sign in") }
end
describe "点击更新按钮" do
before { patch user_path(user) }
it "应该跳到登录界面" do
expect(response).to redirect_to(signin_path)
end
end
end
end
describe "试图更改其他用户的资料" do
let(:user) { FactoryGirl.create(user) }
let(:wrong_user) {FactoryGirl.create(:user, email: "[email protected]")}
before { sign_in user, no_capybara: true }
describe "访问users#edit page" do
before { visit edit_user_path(wrong_user) }
it { should_not have_title(full_title("Edit user")) }
end
describe "提交一个patch请求给users#update" do
before { patch user_path(wrong_user) }
specify { expect(response).to redirect_to(root_path) }
end
end
end
end