简体   繁体   English

在Rails中运行bundle exec rspec spec / requests / static_pages_spec.rb时出错

[英]Getting error while running bundle exec rspec spec/requests/static_pages_spec.rb in Rails

I am following this article where I can written this code in this ruby file below and home page does have sample app, but it still says static pages home page should have content 'Sample App' when I run bundle exec rspec spec/requests/static_pages_spec.rb 我正在关注本文,我可以在下面的此ruby文件中编写此代码,并且首页确实具有示例应用程序,但是当我运行bundle exec rspec spec/requests/static_pages_spec.rb时,仍然说静态页面首页应具有内容“示例应用程序” bundle exec rspec spec/requests/static_pages_spec.rb

spec/requests/static_pages_spec file code: 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 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>

Below is my gem file for this app. 以下是此应用程序的我的gem文件。 please advise. 请指教。 thanks for your help. 谢谢你的帮助。

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'

In the output from your failed rspec test do you have the line FATAL: database "sample_app_test" does not exist many lines above the error Failed examples: rspec ./spec/requests/static_pages_spec.rb:7 # Static pages Home page should have the content 'Ruby on Rails' ? 在失败的rspec测试的输出中,是否存在FATAL: database "sample_app_test" does not existFATAL: database "sample_app_test" does not exist在错误上方FATAL: database "sample_app_test" does not exist很多行Failed examples: rspec ./spec/requests/static_pages_spec.rb:7 # Static pages Home page should have the content 'Ruby on Rails' If so the following steps worked for me: 如果是这样,以下步骤对我有用:

Open the sample_app/config.database.yml file in a text editor, and under test , change the database to the actual name of the postgres db you using, save the .yml file, and re-run the rspec test. 在文本编辑器中打开sample_app/config.database.yml文件,在test下,将数据库更改为您使用的postgres db的实际名称,保存.yml文件,然后重新运行rspec测试。

I think this is a conflict with webrat. 我认为这与webrat有冲突。 Remove it from you gem file. 从您的gem文件中删除它。

#gem 'webrat', '0.7.1'
gem 'capybara', '1.0.0.beta1'

I think that you need to require capybara manualy in the spec_helper.rb . 我认为您需要在spec_helper.rb要求水豚spec_helper.rb That's what I normally do :) 那就是我通常做的:)

暂无
暂无

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

相关问题 运行“Rails S”和“$ bundle exec rspec spec / requests / static_pages_spec.rb”时出现错误消息 - Error message when running “Rails S” & “$ bundle exec rspec spec/requests/static_pages_spec.rb” 输入命令捆绑包exec rspec spec / requests / static_pages_spec.rb时出错 - Error when I type in the command bundle exec rspec spec/requests/static_pages_spec.rb 捆绑exec rspec spec / requests / static_pages_spec.rb错误 - bundle exec rspec spec/requests/static_pages_spec.rb Error 捆绑exec rspec spec / requests / static_pages_spec.rb和错误 - bundle exec rspec spec/requests/static_pages_spec.rb and error 在运行“ bundle exec rspec / requests / static_pages_spec.rb”后,没有任何drb服务器正在运行 - no drb server is running, after ran "bundle exec rspec/requests/static_pages_spec.rb bundle exec rspec spec / requests / static_pages_spec.rb — RubyonRails教程 - bundle exec rspec spec/requests/static_pages_spec.rb — RubyonRails Tutorial 时间束执行程序rspec spec / requests / static_pages_spec.rb-系统无法接受输入的时间 - time bundle exec rspec spec/requests/static_pages_spec.rb --— the system cannot accept the time entered 无法执行bundle exec rspec spec / requests / static_pages_spec.rb - Can't execute bundle exec rspec spec/requests/static_pages_spec.rb 捆绑exec rspec spec / static_pages_spec.rb无法加载错误 - Bundle exec rspec spec/static_pages_spec.rb cannot load error 来自Hartl教程的bundle exec rspec spec / requests / static_pages_spec.rb无效 - bundle exec rspec spec/requests/static_pages_spec.rb from Hartl's tutorial isn't working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM