rspec-rails:失败/错误:获取“ /”没有路由匹配
||
试用rspec-rails。我收到一个怪异的错误-即使在运行rails时可以在浏览器中正常访问它们,也未找到任何路由。
我什至只是/
Failure/Error: get \"/\"
ActionController::RoutingError:
No route matches {:controller=>\"action_view/test_case/test\", :action=>\"/\"}
我绝对可以在浏览器中访问/和其他资源。设置rspec时,我会错过什么吗?我将其放入Gemfile并运行rspec:install。
谢谢,
先生
编辑:这是我的测试
1 require \'spec_helper\'
2
3 describe \"resource\" do
4 describe \"GET\" do
5 it \"contains /\" do
6 get \"/\"
7 response.should have_selector(\"h1\", :content => \"Project\")
8 end
9 end
10 end
这是我的路线文件:
myApp::Application.routes.draw do
resources :groups do
resources :projects
end
resources :projects do
resources :variants
resources :steps
member do
get \'compare\'
end
end
resources :steps do
resources :costs
end
resources :variants do
resources :costs
end
resources :costs
root :to => \"home#index\"
end
我的spec_helper.rb:
ENV[\"RAILS_ENV\"] ||= \'test\'
require File.expand_path(\"../../config/environment\", __FILE__)
require \'rspec/rails\'
Dir[Rails.root.join(\"spec/support/**/*.rb\")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.include RSpec::Rails::ControllerExampleGroup
config.fixture_path = \"#{::Rails.root}/spec/fixtures\"
config.use_transactional_fixtures = true
end
我认为这里真的没有任何改变。
没有找到相关结果
已邀请:
2 个回复
悍蕾驮苇袜
然后添加一个文件“ 6”,我正在使用由单身或非凡的人定义的扩展匹配器。
实际上,我几乎从不使用
,而是始终尽可能地隔离测试我的组件。视图是否包含正确的标题,我在视图规范中测试了该视图。 我使用rspec分别测试每个组件(模型,控制器,视图,路由),并使用Cucumber编写高级测试以遍历所有层。 希望这可以帮助。
碉罕城爸