Module: Resubject::Rspec
- Defined in:
- lib/resubject/rspec.rb
Overview
RSpec configuration and helpers
This helper automatically creates ‘subject` and `template` variables for RSpec when testing your presenter.
To get this working, create a spec file in ‘spec/presenters` and require `resubject/rspec`. You only need to define the object under test by creating a `let(:object)`, like so:
Class Method Summary collapse
-
.included(base) ⇒ Object
Extend RSpec configuration for files placed in ‘spec/presenters`.
Class Method Details
.included(base) ⇒ Object
Extend RSpec configuration for files placed in ‘spec/presenters`
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/resubject/rspec.rb', line 30 def self.included(base) base.instance_eval do let(:template) do if defined? ActionView ActionView::Base.new else mock :template end end subject do described_class.new(object, template) end end end |