capybara:post,将请求目录的名称更改为功能时,get方法不起作用 [英] capybara: post, get methods not working when changing name of requests directory to features
本文介绍了capybara:post,将请求目录的名称更改为功能时,get方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
未定义方法`get' for#< RSpec :: Core :: ExampleGroup :: Nested_1 :: Nested_1 :: Nested_1 :: Nested_1 :: Nested_1:0x007f9cce9adc20>
以下是触发错误的代码:
描述获得帖子在{get(forum_posts_path)}
之前做
它应该用200做回应do
response.response_code.should == 200
end
end
对此的任何解决方法?
解决方案
您不会将 spec / requests 目录重命名为 spec / features : :
- 使用Capybara DSL(
visit
等),并且通常针对
页面
进入 spec / features 中。
- 测试使用机架测试DSL(
get
等),并且通常针对响应
进入 spec / requests 答案的详细信息,特别是外壳rnal链接那里。After upgrading to the latest version of Capybara, all of my visit methods stopped working so I followed a solution presented by some people which was to rename the requests spec directory to "features". Now my visit methods are working again but any get or post method in a request spec causes this error:
undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1::Nested_1:0x007f9cce9adc20>
Here's the code that triggers the error:
describe "getting posts" do before { get(forum_posts_path) } it "should respond with a 200" do response.response_code.should == 200 end end
Any workaround for this?
解决方案You don't rename the spec/requests directory to spec/features: you have both:
- Tests that use the Capybara DSL (
visit
etc) and usually assert againstpage
go in spec/features. - Tests that use the rack-test DSL (
get
etc) and usually assert againstresponse
go in spec/requests
See this StackOverflow answer for details, specifically the external links there.
这篇关于capybara:post,将请求目录的名称更改为功能时,get方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 测试使用机架测试DSL(
查看全文