Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
remove unnecessary conditionals (tip from Jarmo Pertman)
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed May 8, 2009
1 parent 92c1ed8 commit b061f9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 7 additions & 0 deletions foo.rb
@@ -0,0 +1,7 @@
require 'spec'

describe "thing" do
it "does something" do
subject.should == self
end
end
12 changes: 2 additions & 10 deletions lib/spec/example/subject.rb
Expand Up @@ -76,11 +76,7 @@ def subject
# it { should be_eligible_to_vote }
# end
def should(matcher=nil)
if matcher
subject.should(matcher)
else
subject.should
end
subject.should(matcher)
end

# Just like +should+, +should_not+ delegates to the subject (implicit or
Expand All @@ -92,11 +88,7 @@ def should(matcher=nil)
# it { should_not be_eligible_to_vote }
# end
def should_not(matcher=nil)
if matcher
subject.should_not(matcher)
else
subject.should_not
end
subject.should_not(matcher)
end
end
end
Expand Down

0 comments on commit b061f9f

Please sign in to comment.