flexmock 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ PKG_FILES = FileList[
38
38
  ]
39
39
 
40
40
  RDOC_FILES = FileList[
41
- 'README.rdoc',
41
+ 'doc/index.rdoc',
42
42
  'CHANGES',
43
43
  'lib/**/*.rb',
44
44
  'doc/**/*.rdoc',
@@ -84,10 +84,10 @@ end
84
84
 
85
85
  # RDoc Target --------------------------------------------------------
86
86
 
87
- task :rdoc => ["README.rdoc", "html/index.html", :fixcss]
87
+ task :rdoc => ["html/index.html", :fixcss]
88
88
 
89
89
  file "html/index.html" => ["Rakefile"] + RDOC_FILES do
90
- sh "rdoc -o html --title FlexMock --line-numbers -m README.rdoc #{RDOC_FILES}"
90
+ sh "rdoc -o html --title FlexMock --line-numbers -m doc/index.rdoc #{RDOC_FILES}"
91
91
  end
92
92
 
93
93
  EXAMPLE_RB.zip(EXAMPLE_DOC).each do |source, target|
@@ -103,8 +103,8 @@ EXAMPLE_RB.zip(EXAMPLE_DOC).each do |source, target|
103
103
  end
104
104
  end
105
105
 
106
- file "README.rdoc" => ["Rakefile", "lib/flexmock/version.rb"] do
107
- ruby %{-i.bak -pe '$_.sub!(/^Version *:: *((\\d+|beta|rc)\\.)+\\d+ *$/i, "Version :: #{PKG_VERSION}")' README.rdoc} # "
106
+ file "README.md" => ["Rakefile", "lib/flexmock/version.rb"] do
107
+ ruby %{-i.bak -pe '$_.sub!(/^Version: *((\\d+|beta|rc)\\.)+\\d+ *$/i, "Version :: #{PKG_VERSION}")' README.md} # "
108
108
  end
109
109
 
110
110
  desc "Fix the Darkfish CSS so that paragraphs in lists have a bit of spacing"
data/doc/index.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ = Flex Mock -- Making Mocking Easy
2
+
3
+ FlexMock is a simple, but flexible, mock object library for Ruby unit
4
+ testing.
5
+
6
+ This is the API documentation site for flexmock. You can find the user
7
+ documentation at http://github.com/jimweirich/flexmock.
8
+
9
+ == Links
10
+
11
+ * <b>User Guide</b> -- http://github.com/jimweirich/flexmock
12
+ * <b>API Documents</b> -- http://flexmock.rubyforge.org
13
+ * <b>RubyGems</b> -- Install with: `gem install flexmock`
14
+ * <b>Source</b> -- https://github.com/jimweirich/flexmock
15
+ * <b>Bug Reports / Issue Tracking</b> -- https://github.com/jimweirich/flexmock/issues
16
+ * <b>Continuous Integration</b> -- http://travis-ci.org/#!/jimweirich/flexmock
17
+
18
+ == License
19
+
20
+ Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
21
+ All rights reserved.
22
+
23
+ Permission is granted for use, copying, modification, distribution,
24
+ and distribution of modified versions of this work as long as the
25
+ above copyright notice is included.
26
+
27
+ == Warranty
28
+
29
+ This software is provided "as is" and without any express or implied
30
+ warranties, including, without limitation, the implied warranties of
31
+ merchantibility and fitness for a particular purpose.
@@ -1,8 +1,8 @@
1
1
  = FlexMock 1.0.0 Released
2
2
 
3
3
  FlexMock is a flexible mocking library for use in unit testing and
4
- behavior specification in Ruby. Release 1.0.0 is a minor release with
5
- a few bug fixes.
4
+ behavior specification in Ruby. Release 1.0.0 is a major release with
5
+ some nice features and bug fixes.
6
6
 
7
7
  == Changes in 1.0.0
8
8
 
@@ -0,0 +1,165 @@
1
+ = FlexMock 1.0.4 Released
2
+
3
+ FlexMock is a flexible mocking library for use in unit testing and
4
+ behavior specification in Ruby. Release 1.0.3 is a minor release with
5
+ a few bug fixes.
6
+
7
+ == Changes in 1.0.4
8
+
9
+ === Features
10
+
11
+ * Add spy capability.
12
+
13
+ == Changes in 1.0.3
14
+
15
+ === Features
16
+
17
+ * Better error messages when a mock is called the incorrect number of
18
+ times
19
+
20
+ * Better stack output when validations fail during teardown.
21
+
22
+ == Changes in 1.0.2
23
+
24
+ === Bug Fixes
25
+
26
+ * Quick definitions now obey base class restrictions
27
+
28
+ == Changes in 1.0.1
29
+
30
+ === Features
31
+
32
+ * Better Ruby 1.8 compatibility
33
+
34
+ == Changes in 1.0.0
35
+
36
+ === Features
37
+
38
+ * Mocks may now have a base class that limits what methods may be
39
+ mocked. This allows early detection of outdated mock setups when the
40
+ methods in the class are refactored.
41
+
42
+ * Spy assertions are now allowed. The verification of the calling of
43
+ mocked methods may now be done in the "then" portion of the test,
44
+ after the code under test has been run. This allows for much more
45
+ natural Given/When/Then style testing.
46
+
47
+ * A custom assert method (assert_spy_called) has been added to make
48
+ spy assertions easy when using Test::Unit or MiniTest.
49
+
50
+ * An RSpec matcher (have_received) has been added to make spy
51
+ assertions easy when using RSpec.
52
+
53
+ === Bug Fixes
54
+
55
+ * Now correctly handling the mocking of meta-programmed methods.
56
+
57
+ * Using the documented +singleton_methods+ method.
58
+
59
+ * Accidently trying to partial mock a regular mock is now a no-op.
60
+
61
+ == What is FlexMock?
62
+
63
+ FlexMock is a flexible framework for creating mock object for testing.
64
+ When running unit tests, it is often desirable to use isolate the
65
+ objects being tested from the "real world" by having them interact
66
+ with simplified test objects. Sometimes these test objects simply
67
+ return values when called, other times they verify that certain
68
+ methods were called with particular arguments in a particular order.
69
+
70
+ FlexMock makes creating these test objects easy.
71
+
72
+ === Features
73
+
74
+ * Easy integration with both Test::Unit and RSpec. Mocks created with the
75
+ flexmock method are automatically verified at the end of the test or
76
+ example.
77
+
78
+ * A fluent interface that allows mock behavior to be specified very
79
+ easily.
80
+
81
+ * A "record mode" where an existing implementation can record its
82
+ interaction with a mock for later validation against a new
83
+ implementation.
84
+
85
+ * Easy mocking of individual methods in existing, non-mock objects.
86
+
87
+ * Easy mocking of chains of method calls.
88
+
89
+ * The ability to cause classes to instantiate test instances (instead of real
90
+ instances) for the duration of a test.
91
+
92
+ === Example
93
+
94
+ Suppose you had a Dog object that wagged a tail when it was happy.
95
+ Something like this:
96
+
97
+ class Dog
98
+ def initialize(a_tail)
99
+ @tail = a_tail
100
+ end
101
+ def happy
102
+ @tail.wag
103
+ end
104
+ end
105
+
106
+ To test the +Dog+ class without a real +Tail+ object (perhaps because
107
+ real +Tail+ objects activate servos in some robotic equipment), you
108
+ can do something like this:
109
+
110
+ RSpec.configure do |config|
111
+ config.mock_with :flexmock
112
+ end
113
+
114
+ describe Dog do
115
+ it "wags its tail when happy" do
116
+ tail = flexmock("tail")
117
+ tail.should_receive(:wag).once
118
+ dog = Dog.new(tail)
119
+ dog.happy
120
+ end
121
+ end
122
+
123
+ FlexMock will automatically verify that the mocked tail object received the
124
+ message +wag+ exactly one time. If it doesn't, the test will not pass.
125
+
126
+ Here's the same thing using the new spy support:
127
+
128
+ describe Dog do
129
+ it "wags its tail when happy" do
130
+ tail = flexmock("tail")
131
+ dog = Dog.new(tail)
132
+ dog.happy
133
+ tail.should have_received(:wag)
134
+ end
135
+ end
136
+
137
+ This style works particularly well with the rspec-given library.
138
+
139
+ require 'rspec/given'
140
+
141
+ describe Dog do
142
+ context "when the dog is happy" do
143
+ Given(:tail) { flexmock(:on, Tail) }
144
+ Given(:dog) { Dog.new(tail) }
145
+
146
+ When { dog.happy }
147
+
148
+ Then { tail.should have_received(:wag) }
149
+ end
150
+ end
151
+
152
+ See the FlexMock documentation at http://flexmock.rubyforge.org for details on
153
+ specifying arguments and return values on mocked methods, as well as a simple
154
+ technique for mocking tail objects when the Dog class creates the tail objects
155
+ directly.
156
+
157
+ == Availability
158
+
159
+ You can make sure you have the latest version with a quick RubyGems command:
160
+
161
+ gem install flexmock (you may need root/admin privileges)
162
+
163
+ You will find documentation at: http://flexmock.rubyforge.org.
164
+
165
+ -- Jim Weirich
@@ -0,0 +1,144 @@
1
+ = FlexMock 1.1.0 Released
2
+
3
+ FlexMock is a flexible mocking library for use in unit testing and
4
+ behavior specification in Ruby. Release 1.1.0 is a minor release with
5
+ a few bug fixes and some small features.
6
+
7
+ == Changes in 1.1.0
8
+
9
+ === Features
10
+
11
+ * Add block support to pass_thru.
12
+
13
+ == Changes in 1.0.0
14
+
15
+ === Features
16
+
17
+ * Mocks may now have a base class that limits what methods may be
18
+ mocked. This allows early detection of outdated mock setups when the
19
+ methods in the class are refactored.
20
+
21
+ * Spy assertions are now allowed. The verification of the calling of
22
+ mocked methods may now be done in the "then" portion of the test,
23
+ after the code under test has been run. This allows for much more
24
+ natural Given/When/Then style testing.
25
+
26
+ * A custom assert method (assert_spy_called) has been added to make
27
+ spy assertions easy when using Test::Unit or MiniTest.
28
+
29
+ * An RSpec matcher (have_received) has been added to make spy
30
+ assertions easy when using RSpec.
31
+
32
+ === Bug Fixes
33
+
34
+ * Now correctly handling the mocking of meta-programmed methods.
35
+
36
+ * Using the documented +singleton_methods+ method.
37
+
38
+ * Accidently trying to partial mock a regular mock is now a no-op.
39
+
40
+ == What is FlexMock?
41
+
42
+ FlexMock is a flexible framework for creating mock object for testing.
43
+ When running unit tests, it is often desirable to use isolate the
44
+ objects being tested from the "real world" by having them interact
45
+ with simplified test objects. Sometimes these test objects simply
46
+ return values when called, other times they verify that certain
47
+ methods were called with particular arguments in a particular order.
48
+
49
+ FlexMock makes creating these test objects easy.
50
+
51
+ === Features
52
+
53
+ * Easy integration with both Test::Unit and RSpec. Mocks created with the
54
+ flexmock method are automatically verified at the end of the test or
55
+ example.
56
+
57
+ * A fluent interface that allows mock behavior to be specified very
58
+ easily.
59
+
60
+ * A "record mode" where an existing implementation can record its
61
+ interaction with a mock for later validation against a new
62
+ implementation.
63
+
64
+ * Easy mocking of individual methods in existing, non-mock objects.
65
+
66
+ * Easy mocking of chains of method calls.
67
+
68
+ * The ability to cause classes to instantiate test instances (instead of real
69
+ instances) for the duration of a test.
70
+
71
+ === Example
72
+
73
+ Suppose you had a Dog object that wagged a tail when it was happy.
74
+ Something like this:
75
+
76
+ class Dog
77
+ def initialize(a_tail)
78
+ @tail = a_tail
79
+ end
80
+ def happy
81
+ @tail.wag
82
+ end
83
+ end
84
+
85
+ To test the +Dog+ class without a real +Tail+ object (perhaps because
86
+ real +Tail+ objects activate servos in some robotic equipment), you
87
+ can do something like this:
88
+
89
+ RSpec.configure do |config|
90
+ config.mock_with :flexmock
91
+ end
92
+
93
+ describe Dog do
94
+ it "wags its tail when happy" do
95
+ tail = flexmock("tail")
96
+ tail.should_receive(:wag).once
97
+ dog = Dog.new(tail)
98
+ dog.happy
99
+ end
100
+ end
101
+
102
+ FlexMock will automatically verify that the mocked tail object received the
103
+ message +wag+ exactly one time. If it doesn't, the test will not pass.
104
+
105
+ Here's the same thing using the new spy support:
106
+
107
+ describe Dog do
108
+ it "wags its tail when happy" do
109
+ tail = flexmock("tail")
110
+ dog = Dog.new(tail)
111
+ dog.happy
112
+ tail.should have_received(:wag)
113
+ end
114
+ end
115
+
116
+ This style works particularly well with the rspec-given library.
117
+
118
+ require 'rspec/given'
119
+
120
+ describe Dog do
121
+ context "when the dog is happy" do
122
+ Given(:tail) { flexmock(:on, Tail) }
123
+ Given(:dog) { Dog.new(tail) }
124
+
125
+ When { dog.happy }
126
+
127
+ Then { tail.should have_received(:wag) }
128
+ end
129
+ end
130
+
131
+ See the FlexMock documentation at http://flexmock.rubyforge.org for details on
132
+ specifying arguments and return values on mocked methods, as well as a simple
133
+ technique for mocking tail objects when the Dog class creates the tail objects
134
+ directly.
135
+
136
+ == Availability
137
+
138
+ You can make sure you have the latest version with a quick RubyGems command:
139
+
140
+ gem install flexmock (you may need root/admin privileges)
141
+
142
+ You will find documentation at: http://flexmock.rubyforge.org.
143
+
144
+ -- Jim Weirich
@@ -0,0 +1,150 @@
1
+ = FlexMock 1.2.0 Released
2
+
3
+ FlexMock is a flexible mocking library for use in unit testing and
4
+ behavior specification in Ruby. Release 1.2.0 is a minor release with
5
+ a few bug fixes and some simple features.
6
+
7
+ == Changes in 1.2.0
8
+
9
+ === Features
10
+
11
+ * Add auto configure by requiring 'flexmock/rspec/configure'.
12
+
13
+ == Changes in 1.1.0
14
+
15
+ === Features
16
+
17
+ * Add block support to pass_thru.
18
+
19
+ == Changes in 1.0.0
20
+
21
+ === Features
22
+
23
+ * Mocks may now have a base class that limits what methods may be
24
+ mocked. This allows early detection of outdated mock setups when the
25
+ methods in the class are refactored.
26
+
27
+ * Spy assertions are now allowed. The verification of the calling of
28
+ mocked methods may now be done in the "then" portion of the test,
29
+ after the code under test has been run. This allows for much more
30
+ natural Given/When/Then style testing.
31
+
32
+ * A custom assert method (assert_spy_called) has been added to make
33
+ spy assertions easy when using Test::Unit or MiniTest.
34
+
35
+ * An RSpec matcher (have_received) has been added to make spy
36
+ assertions easy when using RSpec.
37
+
38
+ === Bug Fixes
39
+
40
+ * Now correctly handling the mocking of meta-programmed methods.
41
+
42
+ * Using the documented +singleton_methods+ method.
43
+
44
+ * Accidently trying to partial mock a regular mock is now a no-op.
45
+
46
+ == What is FlexMock?
47
+
48
+ FlexMock is a flexible framework for creating mock object for testing.
49
+ When running unit tests, it is often desirable to use isolate the
50
+ objects being tested from the "real world" by having them interact
51
+ with simplified test objects. Sometimes these test objects simply
52
+ return values when called, other times they verify that certain
53
+ methods were called with particular arguments in a particular order.
54
+
55
+ FlexMock makes creating these test objects easy.
56
+
57
+ === Features
58
+
59
+ * Easy integration with both Test::Unit and RSpec. Mocks created with the
60
+ flexmock method are automatically verified at the end of the test or
61
+ example.
62
+
63
+ * A fluent interface that allows mock behavior to be specified very
64
+ easily.
65
+
66
+ * A "record mode" where an existing implementation can record its
67
+ interaction with a mock for later validation against a new
68
+ implementation.
69
+
70
+ * Easy mocking of individual methods in existing, non-mock objects.
71
+
72
+ * Easy mocking of chains of method calls.
73
+
74
+ * The ability to cause classes to instantiate test instances (instead of real
75
+ instances) for the duration of a test.
76
+
77
+ === Example
78
+
79
+ Suppose you had a Dog object that wagged a tail when it was happy.
80
+ Something like this:
81
+
82
+ class Dog
83
+ def initialize(a_tail)
84
+ @tail = a_tail
85
+ end
86
+ def happy
87
+ @tail.wag
88
+ end
89
+ end
90
+
91
+ To test the +Dog+ class without a real +Tail+ object (perhaps because
92
+ real +Tail+ objects activate servos in some robotic equipment), you
93
+ can do something like this:
94
+
95
+ RSpec.configure do |config|
96
+ config.mock_with :flexmock
97
+ end
98
+
99
+ describe Dog do
100
+ it "wags its tail when happy" do
101
+ tail = flexmock("tail")
102
+ tail.should_receive(:wag).once
103
+ dog = Dog.new(tail)
104
+ dog.happy
105
+ end
106
+ end
107
+
108
+ FlexMock will automatically verify that the mocked tail object received the
109
+ message +wag+ exactly one time. If it doesn't, the test will not pass.
110
+
111
+ Here's the same thing using the new spy support:
112
+
113
+ describe Dog do
114
+ it "wags its tail when happy" do
115
+ tail = flexmock("tail")
116
+ dog = Dog.new(tail)
117
+ dog.happy
118
+ tail.should have_received(:wag)
119
+ end
120
+ end
121
+
122
+ This style works particularly well with the rspec-given library.
123
+
124
+ require 'rspec/given'
125
+
126
+ describe Dog do
127
+ context "when the dog is happy" do
128
+ Given(:tail) { flexmock(:on, Tail) }
129
+ Given(:dog) { Dog.new(tail) }
130
+
131
+ When { dog.happy }
132
+
133
+ Then { tail.should have_received(:wag) }
134
+ end
135
+ end
136
+
137
+ See the FlexMock documentation at http://flexmock.rubyforge.org for details on
138
+ specifying arguments and return values on mocked methods, as well as a simple
139
+ technique for mocking tail objects when the Dog class creates the tail objects
140
+ directly.
141
+
142
+ == Availability
143
+
144
+ You can make sure you have the latest version with a quick RubyGems command:
145
+
146
+ gem install flexmock (you may need root/admin privileges)
147
+
148
+ You will find documentation at: http://flexmock.rubyforge.org.
149
+
150
+ -- Jim Weirich