Skip to content

Commit

Permalink
Update throw_symbol specs to use method instead of matcher
Browse files Browse the repository at this point in the history
[#1040 state:resolved]
  • Loading branch information
dchelimsky committed Aug 21, 2010
1 parent 4e42338 commit dd0b4d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions example_spec.rb
@@ -0,0 +1,4 @@
context 'foo' do
subject { [] }
its(:size) { should == 1 }
end
4 changes: 2 additions & 2 deletions lib/spec/matchers/throw_symbol.rb
Expand Up @@ -93,8 +93,8 @@ def args
# lambda { do_something_risky }.should_not throw_symbol # 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)
# lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit) # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit)
def throw_symbol(sym=nil) def throw_symbol(expected_symbol = nil, expected_arg=nil)
Matchers::ThrowSymbol.new(sym) Matchers::ThrowSymbol.new(expected_symbol, expected_arg)
end end
end end
end end
6 changes: 3 additions & 3 deletions spec/spec/matchers/throw_symbol_spec.rb
Expand Up @@ -4,7 +4,7 @@ module Spec
module Matchers module Matchers
describe ThrowSymbol do describe ThrowSymbol do
describe "with no args" do describe "with no args" do
let(:matcher) { ThrowSymbol.new } let(:matcher) { throw_symbol }


it "matches if any Symbol is thrown" do it "matches if any Symbol is thrown" do
matcher.matches?(lambda{ throw :sym }).should be_true matcher.matches?(lambda{ throw :sym }).should be_true
Expand All @@ -30,7 +30,7 @@ module Matchers
end end


describe "with a symbol" do describe "with a symbol" do
let(:matcher) { ThrowSymbol.new(:sym) } let(:matcher) { throw_symbol(:sym) }


it "matches if correct Symbol is thrown" do it "matches if correct Symbol is thrown" do
matcher.matches?(lambda{ throw :sym }).should be_true matcher.matches?(lambda{ throw :sym }).should be_true
Expand Down Expand Up @@ -75,7 +75,7 @@ module Matchers
end end


describe "with a symbol and an arg" do 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 it "matches if correct Symbol and args are thrown" do
matcher.matches?(lambda{ throw :sym, "a" }).should be_true matcher.matches?(lambda{ throw :sym, "a" }).should be_true
Expand Down

0 comments on commit dd0b4d3

Please sign in to comment.