我使用gem 'rspec-rails'
(所有测试都已通过)并将其更新为gem 'rspec-rails', '~> 3.0.0.beta'
,现在几乎所有测试都失败了,例如:
rspec ./spec/features/static_pages_spec.rb:60 # languages index
我的测试看起来像:
require 'spec_helper'
describe "languages" do
subject { page }
describe "index" do
before { visit root_path }
it { should have_title('EduWords') }
it { should have_content("Toggle navigation EduWords Home Sign up Log in Authors Back to Top EduWords © MiDaS Project 2014") }
end
end
我做错了什么?
config/routes
Eduwords::Application.routes.draw do
get "authors/index"
get "mainpage/index"
resources :tags
resources :languages
resources :words
resources :tests
resources :users
get "sessions/new"
get "users/new"
get "download", to: "words#download", as: 'download'
get "log_out" => "sessions#destroy", :as => "log_out"
get "log_in" => "sessions#new", :as => "log_in"
get "sign_up" => "users#new", :as => "sign_up"
root :to => "mainpage#index"
resources :users
resources :sessions
end
答案 0 :(得分:1)
听起来像RSpec没有找到你的route_helper方法(例如root_path
)。以下是该问题的答案:
https://stackoverflow.com/a/9476576/2231608
如果将以下内容放在rspec_helper.rb中,则命名路由应该有效:
Rspec.configure do |config|
config.include Rails.application.routes.url_helpers
...
end
你是这样设置的吗?