rspec-cells icon indicating copy to clipboard operation
rspec-cells copied to clipboard

NoMethodError when using route helpers

Open erikaxel opened this issue 7 years ago • 5 comments

Hi,

Im getting a NoMethodError: undefined method `[]' for nil:NilClass in rspec-testing when using path helpers. I have included the controller via the controller-method, and tried setting the type to :cell, but it doesn't help. Using Rails 5.1 and Slim.

erikaxel avatar Nov 06 '17 14:11 erikaxel

I have the same issue

EDIT: @erikaxel I think it is because controller testing is deprecated - controller_for method always returns nil

michaldarda avatar Oct 30 '18 13:10 michaldarda

@erikaxel

Workaround for the moment is

let(:controller) { double('controller', url_options: {}) }                                                                                                  

michaldarda avatar Oct 30 '18 13:10 michaldarda

I found that it depends on the order you put cells-rails and rspec-cells into the Gemfile.

If cells-rails goes first then it works, if it's after rspec-cells then it doesn't

Which indicates that rspec-cells has an implied dependency on cells-rails.

JohnSmall avatar Jul 15 '19 14:07 JohnSmall

The order in the Gemfile matters? :fearful:

apotonick avatar Jul 18 '19 09:07 apotonick

I actually had same issue, and found out that when initializing cell object like this:

let(:cell_obj) { SomeCell.(data) }

then it does not work properly, but when I initialize it as

let(:cell_obj) { cell(SomeCell, data) }

then everything works. Maybe that's also the case for you @erikaxel

rindek avatar Oct 24 '19 09:10 rindek