Skip to content

Commit

Permalink
Merge pull request thumblemonks#37 from Mon-Ouie/fix/inspect
Browse files Browse the repository at this point in the history
Using #inspect rather than #to_s for assertions made with arguments
  • Loading branch information
Justin Knowlden committed Aug 14, 2011
2 parents adda91d + 61a0546 commit e79fd5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/riot/context_helpers.rb
Expand Up @@ -81,7 +81,7 @@ def teardown(&definition)
# asserts(:size).equals(2)
#
# Or with arguments:
#
#
# asserts(:foo,1,2).equals(3)
#
# Passing a Symbol to +asserts+ enables this behaviour. For more information on
Expand Down Expand Up @@ -178,12 +178,12 @@ def denies_topic(what="that it")
denies(what) { topic }
end
private

def new_assertion(scope, *args, &definition)
options = args.extract_options!
definition ||= proc { topic.send(*args) }
description = "#{scope} #{args.first}"
description << " with arguments(s): #{args.slice(1, args.length)}" if args.size > 1
description << " with arguments(s): #{args.slice(1, args.length).inspect}" if args.size > 1
(@assertions << assertion_class.new(description, options[:negative], &definition)).last
end

Expand Down
8 changes: 4 additions & 4 deletions test/core/reports/dot_matrix_reporter_test.rb
Expand Up @@ -16,7 +16,7 @@
end
asserts_topic('puts a dot').matches('.')
end

context 'with a failing test' do
setup do
Riot::Context.new('whatever') do
Expand All @@ -25,12 +25,12 @@
topic.results(100)
@out.string
end

asserts_topic('puts an F').matches('F')
asserts_topic("puts the full context + assertion name").matches('whatever asserts nope!')
asserts_topic("puts the failure reason").matches(/Expected .* but got false instead/)
end

context 'with an error test' do
setup do
Riot::Context.new('whatever') do
Expand All @@ -39,7 +39,7 @@
topic.results(100)
@out.string
end

asserts_topic('puts an E').matches('E')
asserts_topic('puts the full context + assertion name').matches('whatever asserts bang')
asserts_topic('puts the exception message').matches('BOOM')
Expand Down

0 comments on commit e79fd5f

Please sign in to comment.