capybara: post, get methods not working when changing name of requests directory to features

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?

Answers


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 against page go in spec/features.
  • Tests that use the rack-test DSL (get etc) and usually assert against response go in spec/requests

See this StackOverflow answer for details, specifically the external links there.


Need Your Help

How to update multiple rows in mysql

php mysql sql

I have importing table in my database. This table columns are product_id and ext_product_id. Product_id is unique, but ext_product_id in table has same. I have to update this multiple ext_product_i...

Error with “Unsigned Char * ” in DLL imported on C#

c# pinvoke

I have been trying to use a VB DLL supplied with a Contactless mifare Card reader, in C#, however there's a problem passing a variable type. The original code is:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.