aboutsummaryrefslogtreecommitdiffstats
path: root/spec/mspec/lib/mspec/expectations/should.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec/expectations/should.rb')
-rw-r--r--spec/mspec/lib/mspec/expectations/should.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/mspec/lib/mspec/expectations/should.rb b/spec/mspec/lib/mspec/expectations/should.rb
new file mode 100644
index 0000000000..f6d83053f5
--- /dev/null
+++ b/spec/mspec/lib/mspec/expectations/should.rb
@@ -0,0 +1,29 @@
+class Object
+ NO_MATCHER_GIVEN = Object.new
+
+ def should(matcher = NO_MATCHER_GIVEN)
+ MSpec.expectation
+ MSpec.actions :expectation, MSpec.current.state
+ unless matcher.equal? NO_MATCHER_GIVEN
+ unless matcher.matches? self
+ expected, actual = matcher.failure_message
+ SpecExpectation.fail_with(expected, actual)
+ end
+ else
+ SpecPositiveOperatorMatcher.new(self)
+ end
+ end
+
+ def should_not(matcher = NO_MATCHER_GIVEN)
+ MSpec.expectation
+ MSpec.actions :expectation, MSpec.current.state
+ unless matcher.equal? NO_MATCHER_GIVEN
+ if matcher.matches? self
+ expected, actual = matcher.negative_failure_message
+ SpecExpectation.fail_with(expected, actual)
+ end
+ else
+ SpecNegativeOperatorMatcher.new(self)
+ end
+ end
+end