Skip to content

Commit

Permalink
Sadly needed to update some tests and code so it all runs in 1.8.6 th…
Browse files Browse the repository at this point in the history
…rough 1.9.2
  • Loading branch information
gus committed Mar 11, 2011
1 parent 8eee6b1 commit 4691a61
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/riot/context_helpers.rb
Expand Up @@ -183,7 +183,7 @@ def new_assertion(scope, *args, &definition)
options = args.extract_options!
definition ||= proc { topic.send(*args) }
description = "#{scope} #{args.first}"
description << " with arguments(s): #{args.drop(1)}" if args.size > 1
description << " with arguments(s): #{args.slice(1, args.length)}" if args.size > 1
(@assertions << assertion_class.new(description, options[:negative], &definition)).last
end

Expand Down
28 changes: 16 additions & 12 deletions test/core/context/deny_test.rb
Expand Up @@ -2,48 +2,52 @@

context "Using denies" do

helper(:denial_context) do |&assertion_block|
helper(:denial_context) do |actual|
report = Riot::Context.new("Apple Jackie") do
denies("with false", &assertion_block)
denies("with false") { actual }
end.run(MockReporter.new)

[report.passes, report.failures, report.errors]
end # denial_context

asserts("result when returning false from the assertion block") do
denial_context { false }
denial_context(false)
end.equals([1,0,0])

asserts("result when returning true from the assertion block") do
denial_context { true }
denial_context(true)
end.equals([0,1,0])

asserts("result when assertion block has an exception") do
denial_context { raise Exception }
end.equals([0,0,1])
Riot::Context.new("Apple Jackie") do
denies("with false") { raise Exception }
end.run(MockReporter.new).errors
end.equals(1)

end # Using denies

context "Using should_not" do

helper(:denial_context) do |&assertion_block|
helper(:denial_context) do |actual|
report = Riot::Context.new("Apple Jackie") do
should_not("with false", &assertion_block)
should_not("with false") { actual }
end.run(MockReporter.new)

[report.passes, report.failures, report.errors]
end # denial_context

asserts("result when returning false from the assertion block") do
denial_context { false }
denial_context(false)
end.equals([1,0,0])

asserts("result when returning true from the assertion block") do
denial_context { true }
denial_context(true)
end.equals([0,1,0])

asserts("result when assertion block has an exception") do
denial_context { raise Exception }
end.equals([0,0,1])
Riot::Context.new("Apple Jackie") do
should_not("with false") { raise Exception }
end.run(MockReporter.new).errors
end.equals(1)

end # Using should_not
16 changes: 8 additions & 8 deletions test/core/runnable/negative_assertion_test.rb
Expand Up @@ -2,35 +2,35 @@

context "A negative assertion test" do

helper(:negative_assertion) do |&definition|
Riot::Assertion.new("foo", true, &definition)
helper(:negative_assertion) do |definition|
Riot::Assertion.new("foo", true) { definition }
end

asserts("response when evaluated with false result") do
negative_assertion { false }.run(Riot::Situation.new)
negative_assertion(false).run(Riot::Situation.new)
end.equals([:pass, ""])

asserts("response when evaluated with nil result") do
negative_assertion { false }.run(Riot::Situation.new)
negative_assertion(false).run(Riot::Situation.new)
end.equals([:pass, ""])

asserts("response when evaluated with true result") do
negative_assertion { true }.run(Riot::Situation.new)
negative_assertion(true).run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got true instead", nil, nil])

asserts("response when evaluated with \"bar\" result") do
negative_assertion { "bar" }.run(Riot::Situation.new)
negative_assertion("bar").run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got \"bar\" instead", nil, nil])

asserts("response when evaluated with 0 result") do
negative_assertion { 0 }.run(Riot::Situation.new)
negative_assertion(0).run(Riot::Situation.new)
end.equals([:fail, "Expected non-true but got 0 instead", nil, nil])

helper(:big_exception) { @exception ||= Exception.new("blah") }

asserts("response when evaluation errors") do
exception = big_exception # :\
negative_assertion { raise exception }.run(Riot::Situation.new)
Riot::Assertion.new("foo", true) { raise exception }.run(Riot::Situation.new)
end.equals { [:error, big_exception] }

end # A negative assertion test

0 comments on commit 4691a61

Please sign in to comment.