From dd0b4d34bc7072fffcd96cff4a44e60fb3244756 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Sat, 21 Aug 2010 19:34:42 -0400 Subject: [PATCH] Update throw_symbol specs to use method instead of matcher [#1040 state:resolved] --- example_spec.rb | 4 ++++ lib/spec/matchers/throw_symbol.rb | 4 ++-- spec/spec/matchers/throw_symbol_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 example_spec.rb diff --git a/example_spec.rb b/example_spec.rb new file mode 100644 index 000000000..f5db4da39 --- /dev/null +++ b/example_spec.rb @@ -0,0 +1,4 @@ +context 'foo' do + subject { [] } + its(:size) { should == 1 } +end diff --git a/lib/spec/matchers/throw_symbol.rb b/lib/spec/matchers/throw_symbol.rb index 419418897..2e5dd62f0 100644 --- a/lib/spec/matchers/throw_symbol.rb +++ b/lib/spec/matchers/throw_symbol.rb @@ -93,8 +93,8 @@ def args # lambda { do_something_risky }.should_not throw_symbol # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky) # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit) - def throw_symbol(sym=nil) - Matchers::ThrowSymbol.new(sym) + def throw_symbol(expected_symbol = nil, expected_arg=nil) + Matchers::ThrowSymbol.new(expected_symbol, expected_arg) end end end diff --git a/spec/spec/matchers/throw_symbol_spec.rb b/spec/spec/matchers/throw_symbol_spec.rb index 3cebf1308..e6aa008e0 100644 --- a/spec/spec/matchers/throw_symbol_spec.rb +++ b/spec/spec/matchers/throw_symbol_spec.rb @@ -4,7 +4,7 @@ module Spec module Matchers describe ThrowSymbol do describe "with no args" do - let(:matcher) { ThrowSymbol.new } + let(:matcher) { throw_symbol } it "matches if any Symbol is thrown" do matcher.matches?(lambda{ throw :sym }).should be_true @@ -30,7 +30,7 @@ module Matchers end describe "with a symbol" do - let(:matcher) { ThrowSymbol.new(:sym) } + let(:matcher) { throw_symbol(:sym) } it "matches if correct Symbol is thrown" do matcher.matches?(lambda{ throw :sym }).should be_true @@ -75,7 +75,7 @@ module Matchers end describe "with a symbol and an arg" do - let(:matcher) { ThrowSymbol.new(:sym, "a") } + let(:matcher) { throw_symbol(:sym, "a") } it "matches if correct Symbol and args are thrown" do matcher.matches?(lambda{ throw :sym, "a" }).should be_true