flexmock 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +6 -0
- data/Rakefile +1 -1
- data/doc/releases/flexmock-0.8.5.rdoc +95 -0
- data/lib/flexmock/argument_matchers.rb +0 -1
- metadata +4 -2
data/CHANGES
CHANGED
data/Rakefile
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
= FlexMock 0.8.5 Released
|
2
|
+
|
3
|
+
FlexMock is a flexible mocking library for use in unit testing and
|
4
|
+
behavior specification in Ruby. Release 0.8.5 is a minor release with
|
5
|
+
a few bug fixes.
|
6
|
+
|
7
|
+
== Bug Fixes in 0.8.5
|
8
|
+
|
9
|
+
* Fixed warning about a void context.
|
10
|
+
* hsh() argument matcher now reports its matching constraints in error
|
11
|
+
messages.
|
12
|
+
|
13
|
+
== What is FlexMock?
|
14
|
+
|
15
|
+
FlexMock is a flexible framework for creating mock object for testing. When
|
16
|
+
running unit tests, it is often desirable to use isolate the objects being
|
17
|
+
tested from the "real world" by having them interact with simplified test
|
18
|
+
objects. Sometimes these test objects simply return values when called, other
|
19
|
+
times they verify that certain methods were called with particular arguments
|
20
|
+
in a particular order.
|
21
|
+
|
22
|
+
FlexMock makes creating these test objects easy.
|
23
|
+
|
24
|
+
=== Features
|
25
|
+
|
26
|
+
* Easy integration with both Test::Unit and RSpec. Mocks created with the
|
27
|
+
flexmock method are automatically verified at the end of the test or
|
28
|
+
example.
|
29
|
+
|
30
|
+
* A fluent interface that allows mock behavior to be specified very
|
31
|
+
easily.
|
32
|
+
|
33
|
+
* A "record mode" where an existing implementation can record its
|
34
|
+
interaction with a mock for later validation against a new
|
35
|
+
implementation.
|
36
|
+
|
37
|
+
* Easy mocking of individual methods in existing, non-mock objects.
|
38
|
+
|
39
|
+
* Easy mocking of chains of method calls.
|
40
|
+
|
41
|
+
* The ability to cause classes to instantiate test instances (instead of real
|
42
|
+
instances) for the duration of a test.
|
43
|
+
|
44
|
+
=== Example
|
45
|
+
|
46
|
+
Suppose you had a Dog object that wagged a tail when it was happy.
|
47
|
+
Something like this:
|
48
|
+
|
49
|
+
class Dog
|
50
|
+
def initialize(a_tail)
|
51
|
+
@tail = a_tail
|
52
|
+
end
|
53
|
+
def happy
|
54
|
+
@tail.wag
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
To test the +Dog+ class without a real +Tail+ object (perhaps because
|
59
|
+
real +Tail+ objects activate servos in some robotic equipment), you
|
60
|
+
can do something like this:
|
61
|
+
|
62
|
+
require 'test/unit'
|
63
|
+
require 'flexmock/test_unit'
|
64
|
+
|
65
|
+
class TestDog < Test::Unit::TestCase
|
66
|
+
def test_dog_wags_tail_when_happy
|
67
|
+
tail = flexmock("tail")
|
68
|
+
tail.should_receive(:wag).once
|
69
|
+
dog = Dog.new(tail)
|
70
|
+
dog.happy
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
FlexMock will automatically verify that the mocked tail object received the
|
75
|
+
message +wag+ exactly one time. If it doesn't, the test will not pass.
|
76
|
+
|
77
|
+
See the FlexMock documentation at http://flexmock.rubyforge.org for details on
|
78
|
+
specifying arguments and return values on mocked methods, as well as a simple
|
79
|
+
technique for mocking tail objects when the Dog class creates the tail objects
|
80
|
+
directly.
|
81
|
+
|
82
|
+
== Availability
|
83
|
+
|
84
|
+
You can make sure you have the latest version with a quick RubyGems command:
|
85
|
+
|
86
|
+
gem install flexmock (you may need root/admin privileges)
|
87
|
+
|
88
|
+
Otherwise, you can get it from the more traditional places:
|
89
|
+
|
90
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=170
|
91
|
+
|
92
|
+
You will find documentation at: http://flexmock.rubyforge.org.
|
93
|
+
|
94
|
+
-- Jim Weirich
|
95
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-10 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -40,6 +40,7 @@ extra_rdoc_files:
|
|
40
40
|
- doc/releases/flexmock-0.8.2.rdoc
|
41
41
|
- doc/releases/flexmock-0.8.3.rdoc
|
42
42
|
- doc/releases/flexmock-0.8.4.rdoc
|
43
|
+
- doc/releases/flexmock-0.8.5.rdoc
|
43
44
|
files:
|
44
45
|
- CHANGES
|
45
46
|
- Rakefile
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- doc/releases/flexmock-0.8.2.rdoc
|
112
113
|
- doc/releases/flexmock-0.8.3.rdoc
|
113
114
|
- doc/releases/flexmock-0.8.4.rdoc
|
115
|
+
- doc/releases/flexmock-0.8.5.rdoc
|
114
116
|
has_rdoc: true
|
115
117
|
homepage: http://flexmock.rubyforge.org
|
116
118
|
post_install_message:
|