class Shoulda::Matchers::ActionController::RenderWithLayoutMatcher

@private

Public Class Methods

new(expected_layout) click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 39
def initialize(expected_layout)
  unless expected_layout.nil?
    @expected_layout = expected_layout.to_s
  end
end

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 67
def description
  description = 'render with '
  if @expected_layout.nil?
    description << 'a layout'
  else
    description << "the #{@expected_layout.inspect} layout"
  end
  description
end
failure_message() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 57
def failure_message
  "Expected #{expectation}, but #{result}"
end
Also aliased as: failure_message_for_should
failure_message_for_should()
Alias for: failure_message
failure_message_for_should_not()
failure_message_when_negated() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 62
def failure_message_when_negated
  "Did not expect #{expectation}, but #{result}"
end
in_context(context) click to toggle source

Used to provide access to layouts recorded by ActionController::TemplateAssertions in Rails 3

# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 47
def in_context(context)
  @context = context
  self
end
matches?(controller) click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 52
def matches?(controller)
  @controller = controller
  rendered_with_layout? && rendered_with_expected_layout?
end

Private Instance Methods

expectation() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 103
def expectation
  "to #{description}"
end
recorded_layouts() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 95
def recorded_layouts
  if @context
    @context.instance_variable_get(Shoulda::Matchers::RailsShim.layouts_ivar)
  else
    {}
  end
end
rendered_layouts() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 91
def rendered_layouts
  recorded_layouts.keys.compact.map { |layout| layout.sub(%r{^layouts/}, '') }
end
rendered_with_expected_layout?() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 83
def rendered_with_expected_layout?
  if @expected_layout.nil?
    true
  else
    rendered_layouts.include?(@expected_layout)
  end
end
rendered_with_layout?() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 79
def rendered_with_layout?
  !rendered_layouts.empty?
end
result() click to toggle source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 107
def result
  if rendered_with_layout?
    'rendered with ' + rendered_layouts.map(&:inspect).join(', ')
  else
    'rendered without a layout'
  end
end