decent-exposure

How can I stub a controller helper method in a view spec with RSpec 3.4?

孤者浪人 提交于 2019-12-07 17:52:13
问题 I'm testing a view with RSpec (3.4 on Rails 4.2.5). And I use the decent_exposure gem in my CRUD controller. decent_exposure makes it easy to define named methods that are made available to my views and which memoize the resultant values. But I don't understand how I can stub these methods in a view spec. I tried do it according to the RSpec documentation, but it raises an error. Why doesn't it work? How can I stub the method article in the view? My controller class Account:

How can I stub a controller helper method in a view spec with RSpec 3.4?

时光毁灭记忆、已成空白 提交于 2019-12-06 03:31:01
I'm testing a view with RSpec (3.4 on Rails 4.2.5). And I use the decent_exposure gem in my CRUD controller. decent_exposure makes it easy to define named methods that are made available to my views and which memoize the resultant values. But I don't understand how I can stub these methods in a view spec. I tried do it according to the RSpec documentation, but it raises an error. Why doesn't it work? How can I stub the method article in the view? My controller class Account::ArticlesController < Account::BaseController expose(:articles) { current_user.articles } expose(:article, attributes: