Permalink
Browse files

Updated Manifest.

Signed-off-by: Jeremy McAnally <jeremymcanally@gmail.com>
  • Loading branch information...
1 parent 822a3ec commit a2de3d65fa031f1f3915aee2fd69bd95e3526340 @mhennemeyer mhennemeyer committed with Feb 10, 2009
Showing with 11 additions and 20 deletions.
  1. +1 −0 Manifest.txt
  2. +4 −14 lib/matchy/expectation_builder.rb
  3. +2 −2 lib/matchy/modals.rb
  4. +4 −4 test/test_expectation_builder.rb
View
@@ -13,6 +13,7 @@ config/hoe.rb
config/requirements.rb
lib/matchy.rb
lib/matchy/version.rb
+lib/matchy/expectation_builder
lib/matchy/modals.rb
lib/matchy/def_matcher.rb
lib/matchy/matcher_builder.rb
@@ -1,19 +1,9 @@
module Matchy
module ExpectationBuilder
- def self.build_expectation(type, exp, obj)
- if exp
- match_expectation(exp, (type == :should), obj)
- else
- return Matchy::Expectations::OperatorExpectation.new(obj, (type == :should))
- end
- end
-
- def self.match_expectation(expectation, match, obj)
- if expectation.matches?(obj) != match
- expectation.fail!(match)
- else
- expectation.pass!(match)
- end
+ def self.build_expectation(match, exp, obj)
+ return Matchy::Expectations::OperatorExpectation.new(obj, match) unless exp
+
+ (exp.matches?(obj) != match) ? exp.fail!(match) : exp.pass!(match)
end
end
end
View
@@ -9,7 +9,7 @@ module Modals
# lambda { raise "u r doomed" }.should raise_error
#
def should(expectation = nil)
- Matchy::ExpectationBuilder.build_expectation(:should, expectation, self)
+ Matchy::ExpectationBuilder.build_expectation(true, expectation, self)
end
alias :will :should
@@ -23,7 +23,7 @@ def should(expectation = nil)
# lambda { "savd bai da bell" }.should_not raise_error
#
def should_not(expectation = nil)
- Matchy::ExpectationBuilder.build_expectation(:should_not, expectation, self)
+ Matchy::ExpectationBuilder.build_expectation(false, expectation, self)
end
alias :will_not :should_not
@@ -7,22 +7,22 @@ def setup
end
def test_should
- exp = Matchy::ExpectationBuilder.build_expectation(:should, nil, @obj)
+ exp = Matchy::ExpectationBuilder.build_expectation(true, nil, @obj)
exp.send(:==, @obj)
end
def test_should_fails
- expect_1 = Matchy::ExpectationBuilder.build_expectation(:should, nil, 1)
+ expect_1 = Matchy::ExpectationBuilder.build_expectation(true, nil, 1)
lambda {expect_1.send(:==, 2)}.should raise_error
end
def test_should_not
- exp = Matchy::ExpectationBuilder.build_expectation(:should_not, nil, @obj)
+ exp = Matchy::ExpectationBuilder.build_expectation(false, nil, @obj)
exp.send(:==, 1)
end
def test_should_not_fails
- expect_not_1 = Matchy::ExpectationBuilder.build_expectation(:should_not, nil, 1)
+ expect_not_1 = Matchy::ExpectationBuilder.build_expectation(false, nil, 1)
lambda {expect_not_1.send(:==, 1)}.should raise_error
end
end

0 comments on commit a2de3d6

Please sign in to comment.