I have installed a rspec-rails 3.0.0.beta1
(on ruby2 + rails4) and had some troubles using devise helper in my request specs. After some googling, I've found that I need to move all my specs from spec/requests
to spec/features
(the requests dir was created by rspec installator or scaffold generator [not sure right now], so I'm a bit confused). That made my devise helper working but there are more issues instead.
Here are three scenarios:
Spec file is spec/requests/events_spec.rb
and dont have any type
set
undefined method 'visit' for #<RSpec::ExampleGroups::Events::GETEvents:0x007ff2464d9848>
Spec file is spec/requests/events_spec.rb
and has a type: :controller
it throws an error undefined method 'events_path' for nil:NilClass
when i'm trying to use a get events_path
method(s)
Spec file is spec/features/events_spec.rb
and dont have any type
set
undefined method `get' for #<RSpec::ExampleGroups::Events::GETEvents:0x007ffb2714a968>
Spec file is spec/features/events_spec.rb
and have a type: :controller
undefined method `events_path' for nil:NilClass
I think I can find some tweaks on the internet but I'm a fresh rspec user and I feel like I'm doing something extremely wrong. And all the examples online are not related to my problem.
The code is here: https://gist.github.com/mbajur/8002303
As of Capybara 2.0, the Capybara methods (e.g. visit
) are only available by default for feature specs, not request specs or controller specs.
Similarly, the get
method is not available for feature specs, only controller and request specs.
Finally, the path helper methods are only available in request or feature specs.
Given that, your failures can be explained as follows:
You need to either:
get
which aren't intended for use with feature specsHere's some interesting background on introducing feature specs as distinct from request specs