Class: PufferPages::Rspec::Matchers::RenderPage
- Inherits:
-
RSpec::Matchers::BuiltIn::BaseMatcher
- Object
- RSpec::Matchers::BuiltIn::BaseMatcher
- PufferPages::Rspec::Matchers::RenderPage
- Defined in:
- lib/puffer_pages/rspec/matchers/render_page.rb
Instance Attribute Summary collapse
-
#drops ⇒ Object
readonly
Returns the value of attribute drops.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(scope, page = nil) ⇒ RenderPage
constructor
A new instance of RenderPage.
- #matches?(controller_or_request) ⇒ Boolean
- #with_drops(*drops, &block) ⇒ Object
Constructor Details
#initialize(scope, page = nil) ⇒ RenderPage
Returns a new instance of RenderPage.
7 8 9 10 11 12 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 7 def initialize scope, page = nil @scope = scope @page = page @page = PufferPages::Page.find_page(page) if page.is_a?(String) @drops ||= { values: {}, names: [], manual: [] } end |
Instance Attribute Details
#drops ⇒ Object (readonly)
Returns the value of attribute drops.
5 6 7 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 5 def drops @drops end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 5 def page @page end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
5 6 7 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 5 def scope @scope end |
Instance Method Details
#description ⇒ Object
44 45 46 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 44 def description "render page #{}" end |
#failure_message_for_should ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 27 def = '' << "expected action to render #{}\n" << "with drops #{}\n" if with_drops? if with_drops? && !drops_conformity rendered_drops = scope.puffer_pages_render[rendered_page].first[:drops] << "but available drops are: #{PP.pp rendered_drops, ''}" else << "but #{rendered_page ? "`/#{rendered_page.location}`" : 'nothing'} was rendered" end end |
#failure_message_for_should_not ⇒ Object
40 41 42 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 40 def "expected action not to render #{} but `/#{rendered_page.location}` was rendered" end |
#matches?(controller_or_request) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 14 def matches? controller_or_request scope.get :index if controller_or_request.is_a?(ActionController::Base) rendered_page && (!with_page? || page_conformity) && (!with_drops? || drops_conformity) end |
#with_drops(*drops, &block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/puffer_pages/rspec/matchers/render_page.rb', line 20 def with_drops *drops, &block @drops[:values].merge! drops. @drops[:names].concat(drops.flatten).uniq! @drops[:manual].push block if block self end |