mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
convert build_message to sprintf
This commit is contained in:
parent
6548fc6617
commit
9699eeb496
1 changed files with 5 additions and 9 deletions
|
@ -73,9 +73,8 @@ module ActionController
|
||||||
when NilClass, String, Symbol
|
when NilClass, String, Symbol
|
||||||
options = options.to_s if Symbol === options
|
options = options.to_s if Symbol === options
|
||||||
rendered = @templates
|
rendered = @templates
|
||||||
msg = build_message(message,
|
msg = message || sprintf("expecting <%s> but rendering with <%s>",
|
||||||
"expecting <?> but rendering with <?>",
|
options, rendered.keys)
|
||||||
options, rendered.keys.join(', '))
|
|
||||||
assert_block(msg) do
|
assert_block(msg) do
|
||||||
if options
|
if options
|
||||||
rendered.any? { |t,num| t.match(options) }
|
rendered.any? { |t,num| t.match(options) }
|
||||||
|
@ -85,8 +84,7 @@ module ActionController
|
||||||
end
|
end
|
||||||
when Hash
|
when Hash
|
||||||
if expected_layout = options[:layout]
|
if expected_layout = options[:layout]
|
||||||
msg = build_message(message,
|
msg = message || sprintf("expecting layout <%s> but action rendered <%s>",
|
||||||
"expecting layout <?> but action rendered <?>",
|
|
||||||
expected_layout, @layouts.keys)
|
expected_layout, @layouts.keys)
|
||||||
|
|
||||||
case expected_layout
|
case expected_layout
|
||||||
|
@ -107,13 +105,11 @@ module ActionController
|
||||||
end
|
end
|
||||||
elsif expected_count = options[:count]
|
elsif expected_count = options[:count]
|
||||||
actual_count = @partials[expected_partial]
|
actual_count = @partials[expected_partial]
|
||||||
msg = build_message(message,
|
msg = message || sprintf("expecting %s to be rendered %s time(s) but rendered %s time(s)",
|
||||||
"expecting ? to be rendered ? time(s) but rendered ? time(s)",
|
|
||||||
expected_partial, expected_count, actual_count)
|
expected_partial, expected_count, actual_count)
|
||||||
assert(actual_count == expected_count.to_i, msg)
|
assert(actual_count == expected_count.to_i, msg)
|
||||||
else
|
else
|
||||||
msg = build_message(message,
|
msg = message || sprintf("expecting partial <%s> but action rendered <%s>",
|
||||||
"expecting partial <?> but action rendered <?>",
|
|
||||||
options[:partial], @partials.keys)
|
options[:partial], @partials.keys)
|
||||||
assert_includes @partials, expected_partial, msg
|
assert_includes @partials, expected_partial, msg
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue