/usr/lib/ruby/vendor_ruby/shoulda/matchers/action_controller/render_template_matcher.rb is in ruby-shoulda-matchers 1.0.0~beta2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | module Shoulda # :nodoc:
module Matchers
module ActionController # :nodoc:
# Ensures a controller rendered the given template.
#
# Example:
#
# it { should render_template(:show) }
def render_template(template)
RenderTemplateMatcher.new(template, self)
end
class RenderTemplateMatcher # :nodoc:
def initialize(template, context)
@template = template.to_s
@context = context
end
def matches?(controller)
@controller = controller
renders_template?
end
attr_reader :failure_message, :negative_failure_message
def description
"render template #{@template}"
end
def in_context(context)
@context = context
self
end
private
def renders_template?
begin
@context.send(:assert_template, @template)
@negative_failure_message = "Didn't expect to render #{@template}"
true
rescue Shoulda::Matchers::AssertionError => error
@failure_message = error.message
false
end
end
end
end
end
end
|