diff --git a/lib/riot/context_helpers.rb b/lib/riot/context_helpers.rb index 434ceb9..bec4c0f 100644 --- a/lib/riot/context_helpers.rb +++ b/lib/riot/context_helpers.rb @@ -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 diff --git a/test/core/context/deny_test.rb b/test/core/context/deny_test.rb index 0a20954..150245a 100644 --- a/test/core/context/deny_test.rb +++ b/test/core/context/deny_test.rb @@ -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 diff --git a/test/core/runnable/negative_assertion_test.rb b/test/core/runnable/negative_assertion_test.rb index 7d76ec6..1d26d81 100644 --- a/test/core/runnable/negative_assertion_test.rb +++ b/test/core/runnable/negative_assertion_test.rb @@ -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