trailblazer / rspec-cells

Spec your Cells.
http://cells.rubyforge.org
MIT License
62 stars 48 forks source link

NoMethodError when using route helpers #85

Open erikaxel opened 7 years ago

erikaxel commented 7 years ago

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.

michaldarda commented 6 years ago

I have the same issue

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

michaldarda commented 6 years ago

@erikaxel

Workaround for the moment is

let(:controller) { double('controller', url_options: {}) }                                                                                                  
JohnSmall commented 5 years ago

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.

apotonick commented 5 years ago

The order in the Gemfile matters? :fearful:

rindek commented 5 years ago

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