ruby-on-rails – 在Rails中运行bundle exec rspec spec / reque
发布时间:2020-12-17 03:21:31 所属栏目:百科 来源:网络整理
导读:我正在关注这篇文章,我可以在下面的 ruby文件中编写此代码,主页确实有示例应用程序,但它仍然说静态页面主页应该有内容’Sample App’当我运行bundle exec rspec spec / requests / static_pages_spec .RB spec / requests / static_pages_spec文件代码: req
我正在关注这篇文章,我可以在下面的
ruby文件中编写此代码,主页确实有示例应用程序,但它仍然说静态页面主页应该有内容’Sample App’当我运行bundle exec rspec spec / requests / static_pages_spec .RB
spec / requests / static_pages_spec文件代码: require 'spec_helper' describe "Static pages" do describe "Home page" do it "should have the content 'Sample App'" do visit '/static_pages/home' page.should have_content('Sample App') end end end home.html.erb <h1>Sample App</h1> <p> This is the home page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application. </p> 下面是我的这个应用程序的宝石文件.请指教.谢谢你的帮助. source 'https://rubygems.org' gem 'rails','3.2.1' gem 'sqlite3' # Bundle edge Rails instead: # gem 'rails',:git => 'git://github.com/rails/rails.git' group :development do gem 'rspec-rails','2.6.0' end group :test do gem 'webrat','0.7.1' gem 'capybara','1.0.0.beta1' end # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails','3.2.3' gem 'coffee-rails','3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer' gem 'uglifier','1.0.3' end gem 'jquery-rails','2.0.0' group :production do gem 'pg','0.12.2' end # To use ActiveModel has_secure_password # gem 'bcrypt-ruby','~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug19',:require => 'ruby-debug' 解决方法
在失败的rspec测试的输出中你有FATAL行:数据库“sample_app_test”不存在错误上面的许多行失败的例子:rspec ./spec/requests/static_pages_spec.rb:7#静态页面主页应该有内容’Ruby on Rails’?如果是这样,以下步骤对我有用:
在文本编辑器中打开sample_app / config.database.yml文件,并在测试中,将数据库更改为您使用的postgres数据库的实际名称,保存.yml文件,然后重新运行rspec测试. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |