Permalink
Browse files

added examples and support for more mocha methods

git-svn-id: http://expectations.rubyforge.org/svn/trunk@55 6f265639-962f-4d85-a13b-3090ac0aa348
  • Loading branch information...
1 parent c9781fd commit 9dda6505339a1c909b1491bb36ff4a0a3b63d340 jaycfields committed Mar 7, 2008
Showing with 32 additions and 4 deletions.
  1. +1 −3 lib/expectations/suite.rb
  2. +1 −1 rakefile.rb
  3. +30 −0 test/successes_test.rb
@@ -1,8 +1,6 @@
class Expectations::Suite
- def mock
- Mocha::Mock.new
- end
+ include Mocha::Standalone
def xml(string)
Expectations::XmlString.new(string)
View
@@ -46,7 +46,7 @@
expect NoMethodError do
Object.invalid_method_call
end."
- s.version = "0.2.2"
+ s.version = "0.2.3"
s.author = 'Jay Fields'
s.description = "A lightweight unit testing framework. Tests (expectations) will be written as follows
expect 2 do
View
@@ -18,6 +18,18 @@
phone.dial("2125551212")
end
+ # Behavior based test using a stub
+ expect stub.to.receive(:dial).with("2125551212").times(2) do |phone|
+ phone.dial("2125551212")
+ phone.dial("2125551212")
+ end
+
+ # Behavior based test using a stub_everything
+ expect stub_everything.to.receive(:dial).with("2125551212").times(2) do |phone|
+ phone.dial("2125551212")
+ phone.dial("2125551212")
+ end
+
# Behavior based test on a concrete mock
expect Object.to.receive(:deal) do
Object.deal
@@ -100,4 +112,22 @@ def save(arg)
instance.save(1)
end
+ # this is normally defined in the file specific to the class
+ klass = Class.new do
+ attr_accessor :started
+ end
+ # State based fluent interface boolean test using to be
+ expect klass.new.to.be.started do |process|
+ process.started = true
+ end
+
+ # this is normally defined in the file specific to the class
+ klass = Class.new do
+ attr_accessor :finished
+ end
+ # State based fluent interface boolean test using to have
+ expect klass.new.to.have.finished do |process|
+ process.finished = true
+ end
+
end

0 comments on commit 9dda650

Please sign in to comment.