From b061f9f40dc8a29d34ddb3e74427b244bbcf0aa8 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Fri, 8 May 2009 00:37:12 -0700 Subject: [PATCH] remove unnecessary conditionals (tip from Jarmo Pertman) --- foo.rb | 7 +++++++ lib/spec/example/subject.rb | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 foo.rb diff --git a/foo.rb b/foo.rb new file mode 100644 index 000000000..5f40e0d94 --- /dev/null +++ b/foo.rb @@ -0,0 +1,7 @@ +require 'spec' + +describe "thing" do + it "does something" do + subject.should == self + end +end \ No newline at end of file diff --git a/lib/spec/example/subject.rb b/lib/spec/example/subject.rb index 1507ddcad..34f8239ea 100644 --- a/lib/spec/example/subject.rb +++ b/lib/spec/example/subject.rb @@ -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 @@ -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