Ruby on rails Rails:无法加载这样的文件-spec.rb
我正在学习Hartl的rails教程的第9章。我刚刚为“编辑”页面添加了一些测试,但它不会在命令行上运行 我正在尝试运行“bundle exec rspec spec/requests/user\u pages\u spec.rb-e“edit page”” 我想我的用户页面可能有问题。我可能有太多的'结束'在底部Ruby on rails Rails:无法加载这样的文件-spec.rb,ruby-on-rails,Ruby On Rails,我正在学习Hartl的rails教程的第9章。我刚刚为“编辑”页面添加了一些测试,但它不会在命令行上运行 我正在尝试运行“bundle exec rspec spec/requests/user\u pages\u spec.rb-e“edit page”” 我想我的用户页面可能有问题。我可能有太多的'结束'在底部 C:\Sites\sample_app>bundle exec rspec spec/requests/user_page_spec.rb -e "edit p age" C:
C:\Sites\sample_app>bundle exec rspec spec/requests/user_page_spec.rb -e "edit p
age"
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec
/core/configuration.rb:819:in `load': cannot load such file -- C:/Sites/sample_a
pp/spec/requests/user_page_spec.rb (LoadError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/configuration.rb:819:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/command_line.rb:22:in `run'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/runner.rb:80:in `run'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.1
3.1/lib/rspec/core/runner.rb:17:in `block in autorun'
用户\u页面\u 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) }
it { should have_content(user.name) }
it { should have_title(user.name) }
end
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
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 }
let(:user) { User.find_by(email: 'user@example.com') }
it { should have_link('Sign out') }
it { should have_title(user.name) }
it { should have_selector('div.alert.alert-success', text: 'Welcome') }
end
describe "edit" do
let(:user) { FactoryGirl.create(:user) }
before { visit edit_user_path(user) }
describe "page" do
it { should have_content("Update your profile") }
it { should have_title("Edit user") }
it { should have_link('change', href: 'http://gravatar.com/emails') }
end
describe "with invalid information" do
before { click_button "Save changes" }
it { should have_content('error') }
end
end
end
end
end
gemfile
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.8'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
# The following optional lines are part of the advanced setup.
# gem 'guard-rspec', '2.5.0'
# gem 'spork-rails', '4.0.0'
# gem 'guard-spork', '1.5.0'
# gem 'childprocess', '0.3.6'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.0'
gem 'cucumber-rails', '1.4.0', :require => false
gem 'database_cleaner', github: 'bmabey/database_cleaner'
# Uncomment this line on OS X.
# gem 'growl', '1.0.3'
# Uncomment these lines on Linux.
# gem 'libnotify', '0.8.0'
# Uncomment these lines on Windows.
gem 'rb-notifu', '0.0.4'
gem 'wdm', '0.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
我可以看出您正在执行错误的文件: 更改此项:
bundle exec rspec spec/requests/user_page_spec.rb -e "edit p
age"
致:
应该是
bundle exec rspec spec/requests/user_pages_spec.rb
因为您的文件是user\u pages\u spec.rb
bundle exec rspec spec/requests/user_pages_spec.rb