0
我有一个相当简单的Rails 3项目中,我已经定义了一个自定义路由:使用RSpec2测试控制器的show动作
get 'factions/:name' => 'factions#show', :as => :factions
get 'factions' => 'factions#index'
...它运行时rails s
给了我预期的页面(http://localhost:3000/factions/xyz
是显示app/views/factions/show.html.haml
的HTTP 200)。不过,我已经试过表达规范,将工作的多种不同的方式,下面是我的最新的化身:
require 'spec_helper'
describe FactionsController do
render_views
describe "GET 'show'" do
before { get '/xyz' }
subject { controller }
it { should respond_with(:success) }
it { should render_template(:show) }
end
describe "GET 'index'" do
it "should be successful" do
get 'index'
response.should be_success
end
end
end
的GET 'index'
规范通过无投诉,但无论我做什么了GET 'show'
规范不能通过 - 即使他们当我在本地浏览时会成功。
1) FactionsController GET 'show'
Failure/Error: before { get '/xyz' }
ActionController::RoutingError:
No route matches {:controller=>"factions", :action=>"/xyz"}
# ./spec/controllers/factions_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
动作确实应该show
但我routes.rb
配置必须是不正确或东西。是什么赋予了?
(其他方面:我使用bundle exec spork
加快我的规格,我已经重新启动spork
服务器多次公正,以确保我不能完全疯了。)
尝试,而不是“/ XYZ”“某某” – 2011-06-08 01:32:48
也可以尝试'耙routes'以确保路由存在,你指望它。 – 2011-06-08 03:20:53