dradis-mediawiki 3.6.0

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.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.md +3 -0
  4. data/CONTRIBUTING.md +3 -0
  5. data/Gemfile +23 -0
  6. data/LICENSE +339 -0
  7. data/README.md +32 -0
  8. data/Rakefile +1 -0
  9. data/dradis-mediawiki.gemspec +31 -0
  10. data/lib/dradis/plugins/mediawiki/engine.rb +18 -0
  11. data/lib/dradis/plugins/mediawiki/filters.rb +65 -0
  12. data/lib/dradis/plugins/mediawiki/gem_version.rb +21 -0
  13. data/lib/dradis/plugins/mediawiki/version.rb +9 -0
  14. data/lib/dradis/plugins/mediawiki.rb +10 -0
  15. data/lib/dradis-mediawiki.rb +1 -0
  16. data/lib/tasks/thorfile.rb +17 -0
  17. data/spec/spec_helper.rb +22 -0
  18. data/spec/wiki_import_spec.rb +18 -0
  19. data/test/vendor/mocha-0.9.5/COPYING +3 -0
  20. data/test/vendor/mocha-0.9.5/MIT-LICENSE +7 -0
  21. data/test/vendor/mocha-0.9.5/README +37 -0
  22. data/test/vendor/mocha-0.9.5/README.dradis +4 -0
  23. data/test/vendor/mocha-0.9.5/RELEASE +269 -0
  24. data/test/vendor/mocha-0.9.5/Rakefile +207 -0
  25. data/test/vendor/mocha-0.9.5/lib/mocha/any_instance_method.rb +55 -0
  26. data/test/vendor/mocha-0.9.5/lib/mocha/argument_iterator.rb +21 -0
  27. data/test/vendor/mocha-0.9.5/lib/mocha/backtrace_filter.rb +17 -0
  28. data/test/vendor/mocha-0.9.5/lib/mocha/cardinality.rb +95 -0
  29. data/test/vendor/mocha-0.9.5/lib/mocha/central.rb +27 -0
  30. data/test/vendor/mocha-0.9.5/lib/mocha/change_state_side_effect.rb +19 -0
  31. data/test/vendor/mocha-0.9.5/lib/mocha/class_method.rb +87 -0
  32. data/test/vendor/mocha-0.9.5/lib/mocha/configuration.rb +60 -0
  33. data/test/vendor/mocha-0.9.5/lib/mocha/deprecation.rb +22 -0
  34. data/test/vendor/mocha-0.9.5/lib/mocha/exception_raiser.rb +17 -0
  35. data/test/vendor/mocha-0.9.5/lib/mocha/expectation.rb +476 -0
  36. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_error.rb +15 -0
  37. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_list.rb +50 -0
  38. data/test/vendor/mocha-0.9.5/lib/mocha/in_state_ordering_constraint.rb +19 -0
  39. data/test/vendor/mocha-0.9.5/lib/mocha/inspect.rb +67 -0
  40. data/test/vendor/mocha-0.9.5/lib/mocha/instance_method.rb +16 -0
  41. data/test/vendor/mocha-0.9.5/lib/mocha/is_a.rb +9 -0
  42. data/test/vendor/mocha-0.9.5/lib/mocha/logger.rb +15 -0
  43. data/test/vendor/mocha-0.9.5/lib/mocha/metaclass.rb +13 -0
  44. data/test/vendor/mocha-0.9.5/lib/mocha/method_matcher.rb +21 -0
  45. data/test/vendor/mocha-0.9.5/lib/mocha/mini_test_adapter.rb +50 -0
  46. data/test/vendor/mocha-0.9.5/lib/mocha/mock.rb +200 -0
  47. data/test/vendor/mocha-0.9.5/lib/mocha/mockery.rb +181 -0
  48. data/test/vendor/mocha-0.9.5/lib/mocha/module_method.rb +16 -0
  49. data/test/vendor/mocha-0.9.5/lib/mocha/multiple_yields.rb +20 -0
  50. data/test/vendor/mocha-0.9.5/lib/mocha/names.rb +53 -0
  51. data/test/vendor/mocha-0.9.5/lib/mocha/no_yields.rb +11 -0
  52. data/test/vendor/mocha-0.9.5/lib/mocha/object.rb +187 -0
  53. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/all_of.rb +42 -0
  54. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_of.rb +47 -0
  55. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_parameters.rb +40 -0
  56. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/anything.rb +33 -0
  57. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/base.rb +15 -0
  58. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/equals.rb +42 -0
  59. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entries.rb +45 -0
  60. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entry.rb +56 -0
  61. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_key.rb +42 -0
  62. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_value.rb +42 -0
  63. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/includes.rb +40 -0
  64. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/instance_of.rb +42 -0
  65. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/is_a.rb +42 -0
  66. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/kind_of.rb +42 -0
  67. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/not.rb +42 -0
  68. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/object.rb +15 -0
  69. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/optionally.rb +55 -0
  70. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/regexp_matches.rb +43 -0
  71. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/responds_with.rb +43 -0
  72. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
  73. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers.rb +27 -0
  74. data/test/vendor/mocha-0.9.5/lib/mocha/parameters_matcher.rb +37 -0
  75. data/test/vendor/mocha-0.9.5/lib/mocha/pretty_parameters.rb +28 -0
  76. data/test/vendor/mocha-0.9.5/lib/mocha/return_values.rb +31 -0
  77. data/test/vendor/mocha-0.9.5/lib/mocha/sequence.rb +42 -0
  78. data/test/vendor/mocha-0.9.5/lib/mocha/single_return_value.rb +17 -0
  79. data/test/vendor/mocha-0.9.5/lib/mocha/single_yield.rb +18 -0
  80. data/test/vendor/mocha-0.9.5/lib/mocha/standalone.rb +166 -0
  81. data/test/vendor/mocha-0.9.5/lib/mocha/state_machine.rb +91 -0
  82. data/test/vendor/mocha-0.9.5/lib/mocha/stubbing_error.rb +16 -0
  83. data/test/vendor/mocha-0.9.5/lib/mocha/test_case_adapter.rb +103 -0
  84. data/test/vendor/mocha-0.9.5/lib/mocha/unexpected_invocation.rb +18 -0
  85. data/test/vendor/mocha-0.9.5/lib/mocha/yield_parameters.rb +31 -0
  86. data/test/vendor/mocha-0.9.5/lib/mocha.rb +49 -0
  87. data/test/vendor/mocha-0.9.5/lib/mocha_standalone.rb +2 -0
  88. data/test/vendor/mocha-0.9.5/lib/stubba.rb +4 -0
  89. data/test/wiki_import_test.rb +106 -0
  90. metadata +248 -0
@@ -0,0 +1,37 @@
1
+ = Mocha
2
+
3
+ Mocha is a library for mocking and stubbing using a syntax like that of JMock[http://www.jmock.org].
4
+
5
+ It can be used with many testing frameworks e.g. Test::Unit[http://www.ruby-doc.org/core/classes/Test/Unit.html], RSpec[http://rspec.info/], test/spec[http://chneukirchen.org/repos/testspec/README], expectations[http://expectations.rubyforge.org/], Dust[http://dust.rubyforge.org/], MiniTest[http://rubyforge.org/projects/bfts] and even JtestR[http://jtestr.codehaus.org/].
6
+
7
+ Mocha provides a unified, simple and readable syntax for both traditional mocking and partial mocking.
8
+
9
+ Mocha was harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my (then) colleagues Ben[http://www.techbelly.com/], Chris[http://chrisroos.co.uk] and Paul[http://po-ru.com].
10
+
11
+ == Download and Installation
12
+
13
+ Install the gem with the following command...
14
+
15
+ $ gem install mocha
16
+
17
+ Or install the Rails[http://www.rubyonrails.org] plugin...
18
+
19
+ $ script/plugin install git://github.com/floehopper/mocha.git
20
+
21
+ Or download Mocha...
22
+
23
+ http://rubyforge.org/frs/?group_id=1917
24
+
25
+ == Examples
26
+
27
+ * Quick Start - {Usage Examples}[link:examples/misc.html]
28
+ * Traditional mocking - {Star Trek Example}[link:examples/mocha.html]
29
+ * Setting expectations on real classes - {Order Example}[link:examples/stubba.html]
30
+ * More examples on {Floehopper's Blog}[http://blog.floehopper.org]
31
+ * {Mailing List Archives}[http://groups.google.com/group/mocha-developer]
32
+
33
+ == License
34
+
35
+ Copyright Revieworld Ltd. 2006
36
+
37
+ You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
@@ -0,0 +1,4 @@
1
+ examples/ and test/ folder have been removed from the original distro. Please
2
+ find the full package at:
3
+
4
+ http://rubyforge.org/frs/?group_id=1917
@@ -0,0 +1,269 @@
1
+ = 0.9.5 (93cad010345ce5d68f31422cfc32ed9dd6de13ec)
2
+ * Fixed Lighthouse bug #32 - stub_everything should mean mock responds to anything.
3
+ * Added Expectation#twice to improve readability. Tthanks to pull request from Celestino Gomes.
4
+ * In Ruby 1.9, requiring 'test/unit' loads a thin wrapper around MiniTest and Test::Unit::TestCase ends up inheriting from MiniTest::Unit::TestCase. So we need to avoid including the Mocha modules more than once to avoid nasty consequences. Thanks to Matthias Hennemeyer for help with this.
5
+ * Ruby 1.9 includes rake, but not rake/contrib. For the moment I've moved the sshpublisher require into the only rake task that needs it, so that I can at least run the tests in Ruby 1.9. It looks like I will need to build a rake/contrib gem or similar to get this working properly - http://intertwingly.net/blog/2008/01/07/Rake-Contrib-for-1-9
6
+
7
+ = 0.9.4 (8a59c6ff0f99f34b02bd99f19536a7893be2b340)
8
+ * Added mocha.gemspec file generated with Chad Woolley's new rake task, so that a floehopper-mocha gem will get built on GitHub.
9
+ * Add rake task to update mocha.gemspec with unique version, which will cause gem to be auto-built on github
10
+ * As Tobias Crawley correctly pointed out in feature request #23055 "stubs(with_hash) not working with existing object" [1], following the principle of least surprise, it should be possible to call ObjectMethods#expects & ObjectMethods#stubs with a Hash of method_names vs return_values like you can with Mock#expects & Mock#stubs. I've also updated & improved the docs to reflect the changes. [1] http://rubyforge.org/tracker/index.php?func=detail&aid=23055&group_id=1917&atid=7480
11
+ * Removed deprecated gem autorequire.
12
+
13
+ = 0.9.3 (8219bb2d2881c8529c93fc21e97a11d01203c759)
14
+ * Added support for MiniTest thanks to Jeff Smick.
15
+ * Fixed a possible bug with some of the non-default Configuration options relating to the argument to Object#respond_to?
16
+ * As per Jay Fields recommendations [1] and with further impetus from a talk at Ruby Manor, any methods added to core classes are now added by including a module. This means that Mocha is a better citizen of the Ruby world and it's behaviour is more easily extended. [1] http://blog.jayfields.com/2008/07/ruby-underuse-of-modules.html & http://blog.jayfields.com/2008/07/ruby-redefine-method-behavior.html
17
+ * Removed deprecated gem autorequire.
18
+
19
+ = 0.9.2 (r355)
20
+ * Improved documentation to address [#22530] 'Mock methods with multiple return values not possible?'
21
+ * respond_with parameter matcher was not available in tests.
22
+ * Patch [#22630] Fix for a bug in running Rails tests with Ruby 1.8.7. Array#flatten was being called which in turn was checking whether each element responded to #to_ary. This check was using the two parameter version of #respond_to?, but Mock was only defining a one parameter version.
23
+
24
+ = 0.9.1 (r349)
25
+
26
+ * Fixed bug #21465 - expects & stubs should support method names as strings (as well as symbols) or fail fast. Convert all expectation method names to a symbol in case they were supplied as a string.
27
+ * By removing Mock#unexpected_method_called we reduce the number of methods vulnerable to the problem that surfaced in bug #21563.
28
+ * Fix bug #21563 - stubbing 'verified?' method is unsafe. Instance method names on the Mock class should be more obscure.
29
+ * Performance improvement. StubbaExampleTest goes twice as fast on my local machine.
30
+ * Added primitive performance test to default rake task.
31
+ * Fix format of case statements which don't work in Ruby 1.9 and make others consistent.
32
+ * There is no point in running (potentially expensive) checks if configuration is set to allow such checks to fail. This is a relatively quick fix in response to Chris McGrath's performance problems.
33
+ * Fix for bug #21161 - 'uninitialized constant Deprecation in stubba.rb'.
34
+ * It's more readable to talk about 'once' and 'twice' rather than '1 time' and '2 times'.
35
+ * Fix bug #20883 - never should raise when called to prevent follow up errors. Fail fast when there are no matching invokable expectations and handle the stub_everything case sensibly. This might not be entirely backwards compatible, but I think the benefits outweigh the risks. The most likely change is that a test that was already failing will now fail faster, which doesn't seem so awful.
36
+
37
+ = 0.9.0 (r316)
38
+
39
+ * Configurable warnings or errors
40
+ * when a method on a non-public method is stubbed
41
+ * when a method on a non-existent method is stubbed
42
+ * when a method on a non-mock object is stubbed
43
+ * when a method is stubbed unnecessarily (i.e. the stubbed method is not called during the test)
44
+
45
+ * Improved error messages
46
+ * User-friendly list of unsatisfied expectations, satisfied expectations and state machines.
47
+ * Improved readability of cardinality description.
48
+ * Display sensible failure message for any_instance expectations e.g. "#<AnyInstance:Foo>.bar - expected calls: 1, actual calls: 0"
49
+
50
+ * Parameter matchers
51
+ * New to this release
52
+ * optionally (allows matching of optional parameters if available)
53
+ * yaml_equivalent (allows matching of YAML that represents the specified object)
54
+ * responds_with (tests the quack not the duck)
55
+ * Nesting of parameter matchers is now supported.
56
+
57
+ * Optional block passed into mock initializer is evaluated in the context of the new mock instance and can be used as a shortcut to set up expectations.
58
+
59
+ * Added JMock-style sequences for constraining the order of expected invocations. See Standalone#sequence and Expectation#in_sequence.
60
+
61
+ * Added JMock-style states for constraining the order of expected invocations. See Standalone#states, Expectation#then, Expectation#when and StateMachine.
62
+
63
+ * Compatibility with versions of Ruby
64
+ * Compatibility with Ruby v1.9. All test errors and warnings fixed.
65
+ * Nasty fix so that TestCaseAdaptor works consistently with earlier versions of Test::Unit as well as more recent versions.
66
+ * Added platform to gem specification to avoid bug in rubygems 0.9.5 - see http://www.dcmanges.com/blog/rubygems-0-9-5-platform-bug and http://rubygems.org/read/chapter/20#platform.
67
+ * Make ExpectationRaiser deal with subclasses of Interrupt which seem to need a message supplied in the raise statement in Ruby 1.8.6 (but not 1.8.4 or 1.9). Not sure this is really Mocha's responsibility.
68
+
69
+ * Added deprecation warning in stubba.rb which is no longer needed and will be removed.
70
+
71
+ * Supply positioning information to evals to improve any error messages. See http://ola-bini.blogspot.com/2008/01/ruby-antipattern-using-eval-without.html
72
+
73
+ * Bug fixes
74
+ * 18914 in revision 296 - http://rubyforge.org/tracker/index.php?func=detail&aid=18914&group_id=1917&atid=7477
75
+ * 18917 in revision 295 - http://rubyforge.org/tracker/index.php?func=detail&aid=18917&group_id=1917&atid=7477
76
+ * 18336 in revision 287 - http://rubyforge.org/tracker/index.php?func=detail&aid=18336&group_id=1917&atid=7477
77
+ * 17835 in revision 255 - http://rubyforge.org/tracker/index.php?func=detail&aid=17835&group_id=1917&atid=7477
78
+ * 17412 in revision 242 - http://rubyforge.org/tracker/index.php?func=detail&aid=17412&group_id=1917&atid=7477
79
+ * 15977 in revision 198 - http://rubyforge.org/tracker/index.php?func=detail&aid=15977&group_id=1917&atid=7477
80
+ * 11885 in revision 156 - http://rubyforge.org/tracker/index.php?func=detail&aid=11885&group_id=1917&atid=7477
81
+
82
+ = 0.5.5 (r167)
83
+
84
+ - Renamed Matches parameter matcher to RegexpMatches for clarity.
85
+ - Added noframes tag to rdoc index to assist Google.
86
+
87
+ = 0.5.4 (r166)
88
+
89
+ - Added matches parameter matcher for matching regular expressions.
90
+
91
+ = 0.5.3 (r165)
92
+
93
+ - Attempt to fix packaging problems by switching to newer version (1.15.1) of gnutar and setting COPY_EXTENDED_ATTRIBUTES_DISABLE environment variable.
94
+ - Removed unused ExpectationSequenceError exception.
95
+ - Added instance_of and kind_of parameter matchers.
96
+ - Added Google Webmaster meta tag to rdoc template header.
97
+ - Put Google Webmaster meta tag in the right header i.e. the one for the index page.
98
+
99
+ = 0.5.2 (r159)
100
+
101
+ - Fix bug 11885 - "never doesn't work with stub_everything" submitted by Alexander Lang. In fixing this bug, also fixed undiscoverd bug where expected & actual invocation counts were being incorrectly reported which seems to have been introduced when fixes were added for invocation dispatch (see MockedMethodDispatchAcceptanceTest).
102
+ - Previously when an expectation did not allow more invocations, it was treated as not matching. Now we prefer matching expectations which allow more invocations, but still match expectations which cannot allow more invocations. I think this may be overcomplicating things, but let's see how it goes.
103
+
104
+ = 0.5.1 (r149)
105
+
106
+ - Fixed bug #11583 "Mocha 0.5.0 throwing unexpected warnings". Also switched on ruby warning for all rake test tasks. Fixed majority of warnings, but some left to fix.
107
+
108
+ = 0.5.0 (r147)
109
+
110
+ - Parameter Matchers - I’ve added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
111
+
112
+ object = mock()
113
+ object.expects(:method).with(has_key('key_1'))
114
+ object.method('key_1' => 1, 'key_2' => 2)
115
+ # no verification error raised
116
+
117
+ object = mock()
118
+ object.expects(:method).with(has_key('key_1'))
119
+ object.method('key_2' => 2)
120
+ # verification error raised, because method was not called with Hash containing key: 'key_1'
121
+
122
+ - Values Returned and Exceptions Raised on Consecutive Invocations - Allow multiple calls to Expectation#returns and Expectation#raises to build up a sequence of responses to invocations on the mock. Added syntactic sugar method Expectation#then to allow more readable expectations.
123
+
124
+ object = mock()
125
+ object.stubs(:method).returns(1, 2).then.raises(Exception).then.returns(4)
126
+ object.method # => 1
127
+ object.method # => 2
128
+ object.method # => raises exception of class Exception
129
+ object.method # => 4
130
+
131
+ - Yields on Consecutive Invocations - Allow multiple calls to yields on single expectation to allow yield parameters to be specified for consecutive invocations.
132
+
133
+ object = mock()
134
+ object.stubs(:method).yields(1, 2).then.yields(3)
135
+ object.method { |*values| p values } # => [1, 2]
136
+ object.method { |*values| p values } # => [3]
137
+
138
+ - Multiple Yields on Single Invocation - Added Expectation#multiple_yields to allow a mocked or stubbed method to yield multiple times for a single invocation.
139
+
140
+ object = mock()
141
+ object.stubs(:method).multiple_yields([1, 2], [3])
142
+ object.method { |*values| p values } # => [1, 2] # => [3]
143
+
144
+ - Invocation Dispatch - Expectations were already being matched in reverse order i.e. the most recently defined one was being found first. This is still the case, but we now stop matching an expectation when its maximum number of expected invocations is reached. c.f. JMock v1. A stub will never stop matching by default. Hopefully this means we can soon get rid of the need to pass a Proc to Expectation#returns.
145
+
146
+ object = mock()
147
+ object.stubs(:method).returns(2)
148
+ object.expects(:method).once.returns(1)
149
+ object.method # => 1
150
+ object.method # => 2
151
+ object.method # => 2
152
+ # no verification error raised
153
+
154
+ # The following should still work...
155
+
156
+ Time.stubs(:now).returns(Time.parse('Mon Jan 01 00:00:00 UTC 2007'))
157
+ Time.now # => Mon Jan 01 00:00:00 UTC 2007
158
+ Time.stubs(:now).returns(Time.parse('Thu Feb 01 00:00:00 UTC 2007'))
159
+ Time.now # => Thu Feb 01 00:00:00 UTC 2007
160
+
161
+ - Deprecate passing an instance of Proc to Expectation#returns.
162
+ - Explicitly include all Rakefile dependencies in project.
163
+ - Fixed old Stubba example.
164
+ - Fix so that it is possible for a stubbed method to raise an Interrupt exception without a message in Ruby 1.8.6
165
+ - Added responds_like and quacks_like.
166
+ - Capture standard object methods before Mocha adds any.
167
+ - Added Expectation#once method to make interface less surprising.
168
+ - Use Rake::TestTask to run tests. Created three separate tasks to run unit, integration & acceptance tests. Split inspect_test into one file per TestCase. Deleted superfluous all_tests file.
169
+ - Fiddled with mocha_inspect and tests to give more sensible results on x86 platform.
170
+ - Fixed bug #7834 "infinite_range.rb makes incorrect assumption about to_f" logged by James Moore.
171
+
172
+ = 0.4.0 (r92)
173
+
174
+ - Allow naming of mocks (patch from Chris Roos).
175
+ - Specify multiple return values for consecutive calls.
176
+ - Improved consistency of expectation error messages.
177
+ - Allow mocking of Object instance methods e.g. kind_of?, type.
178
+ - Provide aliased versions of #expects and #stubs to allow mocking of these methods.
179
+ - Added at_least, at_most, at_most_once methods to expectation.
180
+ - Allow expects and stubs to take a hash of method and return values.
181
+ - Eliminate warning: "instance variable @yield not initialized" (patch from Xavier Shay).
182
+ - Restore instance methods on partial mocks (patch from Chris Roos).
183
+ - Allow stubbing of a method with non-word characters in its name (patch from Paul Battley).
184
+ - Removed coupling to Test::Unit.
185
+ - Allow specified exception instance to be raised (patch from Chris Roos).
186
+ - Make mock object_id appear in hex like normal Ruby inspect (patch from Paul Battley).
187
+ - Fix path to object.rb in rdoc rake task (patch from Tomas Pospisek).
188
+ - Reverse order in which expectations are matched, so that last expectation is matched first. This allows e.g. a call to #stubs to be effectively overridden by a call to #expects (patch from Tobias Lutke).
189
+ - Stubba & SmartTestCase modules incorporated into Mocha module so only need to require 'mocha' - no longer need to require 'stubba'.
190
+ - AutoMocha removed.
191
+
192
+ = 0.3.3
193
+
194
+ - Quick bug fix to restore instance methods on partial mocks (for Kevin Clark).
195
+
196
+ = 0.3.2
197
+
198
+ - Examples added.
199
+
200
+ = 0.3.1
201
+
202
+ - Dual licensing with MIT license added.
203
+
204
+ = 0.3.0
205
+
206
+ * Rails plugin.
207
+ * Auto-verify for expectations on concrete classes.
208
+ * Include each expectation verification in the test result assertion count.
209
+ * Filter out noise from assertion backtraces.
210
+ * Point assertion backtrace to line where failing expectation was created.
211
+ * New yields method for expectations.
212
+ * Create stubs which stub all method calls.
213
+ * Mocks now respond_to? expected methods.
214
+
215
+ = 0.2.1
216
+
217
+ * Rename MochaAcceptanceTest::Rover#move method to avoid conflict with Rake (in Ruby 1.8.4 only?)
218
+
219
+ = 0.2.0
220
+
221
+ * Small change to SetupAndTeardown#teardown_stubs suggested by Luke Redpath (http://www.lukeredpath.co.uk) to allow use of Stubba with RSpec (http://rspec.rubyforge.org).
222
+ * Reorganized directory structure and extracted addition of setup and teardown methods into SmartTestCase mini-library.
223
+ * Addition of auto-verify for Mocha (but not Stubba). This means there is more significance in the choice of expects or stubs in that any expects on a mock will automatically get verified.
224
+
225
+ So instead of...
226
+
227
+ wotsit = Mocha.new
228
+ wotsit.expects(:thingummy).with(5).returns(10)
229
+ doobrey = Doobrey.new(wotsit)
230
+ doobrey.hoojamaflip
231
+ wotsit.verify
232
+
233
+ you need to do...
234
+
235
+ wotsit = mock()
236
+ wotsit.expects(:thingummy).with(5).returns(10)
237
+ doobrey = Doobrey.new(wotsit)
238
+ doobrey.hoojamaflip
239
+ # no need to verify
240
+
241
+ There are also shortcuts as follows...
242
+
243
+ instead of...
244
+
245
+ wotsit = Mocha.new
246
+ wotsit.expects(:thingummy).returns(10)
247
+ wotsit.expects(:summat).returns(25)
248
+
249
+ you can have...
250
+
251
+ wotsit = mock(:thingummy => 5, :summat => 25)
252
+
253
+ and instead of...
254
+
255
+ wotsit = Mocha.new
256
+ wotsit.stubs(:thingummy).returns(10)
257
+ wotsit.stubs(:summat).returns(25)
258
+
259
+ you can have...
260
+
261
+ wotsit = stub(:thingummy => 5, :summat => 25)
262
+
263
+ = 0.1.2
264
+
265
+ * Minor tweaks
266
+
267
+ = 0.1.1
268
+
269
+ * Initial release.
@@ -0,0 +1,207 @@
1
+ require 'rubygems'
2
+ require 'rake/rdoctask'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/testtask'
5
+
6
+ module Mocha
7
+ VERSION = "0.9.5"
8
+ end
9
+
10
+ desc "Run all tests"
11
+ task 'default' => ['test:units', 'test:acceptance', 'test:performance']
12
+
13
+ namespace 'test' do
14
+
15
+ unit_tests = FileList['test/unit/**/*_test.rb']
16
+ acceptance_tests = FileList['test/acceptance/*_test.rb']
17
+
18
+ desc "Run unit tests"
19
+ Rake::TestTask.new('units') do |t|
20
+ t.libs << 'test'
21
+ t.test_files = unit_tests
22
+ t.verbose = true
23
+ t.warning = true
24
+ end
25
+
26
+ desc "Run acceptance tests"
27
+ Rake::TestTask.new('acceptance') do |t|
28
+ t.libs << 'test'
29
+ t.test_files = acceptance_tests
30
+ t.verbose = true
31
+ t.warning = true
32
+ end
33
+
34
+ # require 'rcov/rcovtask'
35
+ # Rcov::RcovTask.new('coverage') do |t|
36
+ # t.libs << 'test'
37
+ # t.test_files = unit_tests + acceptance_tests
38
+ # t.verbose = true
39
+ # t.warning = true
40
+ # t.rcov_opts << '--sort coverage'
41
+ # t.rcov_opts << '--xref'
42
+ # end
43
+
44
+ desc "Run performance tests"
45
+ task 'performance' do
46
+ require 'test/acceptance/stubba_example_test'
47
+ require 'test/acceptance/mocha_example_test'
48
+ iterations = 1000
49
+ puts "\nBenchmarking with #{iterations} iterations..."
50
+ [MochaExampleTest, StubbaExampleTest].each do |test_case|
51
+ puts "#{test_case}: #{benchmark_test_case(test_case, iterations)} seconds."
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ def benchmark_test_case(klass, iterations)
58
+ require 'test/unit/ui/console/testrunner'
59
+ require 'benchmark'
60
+ time = Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, Test::Unit::UI::SILENT) } }
61
+ end
62
+
63
+ desc 'Generate RDoc'
64
+ Rake::RDocTask.new('rdoc') do |task|
65
+ task.main = 'README'
66
+ task.title = "Mocha #{Mocha::VERSION}"
67
+ task.rdoc_dir = 'doc'
68
+ task.template = File.expand_path(File.join(File.dirname(__FILE__), "templates", "html_with_google_analytics"))
69
+ task.rdoc_files.include(
70
+ 'README',
71
+ 'RELEASE',
72
+ 'COPYING',
73
+ 'MIT-LICENSE',
74
+ 'agiledox.txt',
75
+ 'lib/mocha/standalone.rb',
76
+ 'lib/mocha/mock.rb',
77
+ 'lib/mocha/expectation.rb',
78
+ 'lib/mocha/object.rb',
79
+ 'lib/mocha/parameter_matchers.rb',
80
+ 'lib/mocha/parameter_matchers',
81
+ 'lib/mocha/state_machine.rb',
82
+ 'lib/mocha/configuration.rb',
83
+ 'lib/mocha/stubbing_error.rb'
84
+ )
85
+ end
86
+
87
+ desc "Generate all documentation"
88
+ task 'generate_docs' => ['clobber_rdoc', 'rdoc', 'examples', 'agiledox.txt']
89
+
90
+ desc "Upload RDoc to RubyForge"
91
+ task 'publish_docs' do
92
+ require 'rake/contrib/sshpublisher'
93
+ Rake::SshDirPublisher.new("jamesmead@rubyforge.org", "/var/www/gforge-projects/mocha", "doc").upload
94
+ end
95
+
96
+ desc "Generate agiledox-like documentation for tests"
97
+ file 'agiledox.txt' do
98
+ File.open('agiledox.txt', 'w') do |output|
99
+ tests = FileList['test/**/*_test.rb']
100
+ tests.each do |file|
101
+ m = %r".*/([^/].*)_test.rb".match(file)
102
+ output << m[1]+" should:\n"
103
+ test_definitions = File::readlines(file).select {|line| line =~ /.*def test.*/}
104
+ test_definitions.sort.each do |definition|
105
+ m = %r"test_(should_)?(.*)".match(definition)
106
+ output << " - "+m[2].gsub(/_/," ") << "\n"
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ desc "Convert example ruby files to syntax-highlighted html"
113
+ task 'examples' do
114
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "vendor", "coderay-0.7.4.215", "lib"))
115
+ require 'coderay'
116
+ mkdir_p 'doc/examples'
117
+ File.open('doc/examples/coderay.css', 'w') do |output|
118
+ output << CodeRay::Encoders[:html]::CSS.new.stylesheet
119
+ end
120
+ ['mocha', 'stubba', 'misc'].each do |filename|
121
+ File.open("doc/examples/#{filename}.html", 'w') do |file|
122
+ file << "<html>"
123
+ file << "<head>"
124
+ file << %q(<link rel="stylesheet" media="screen" href="coderay.css" type="text/css">)
125
+ file << "</head>"
126
+ file << "<body>"
127
+ file << CodeRay.scan_file("examples/#{filename}.rb").html.div
128
+ file << "</body>"
129
+ file << "</html>"
130
+ end
131
+ end
132
+ end
133
+
134
+ Gem.manage_gems if Gem::RubyGemsVersion < '1.2.0'
135
+
136
+ def build_specification(version = Mocha::VERSION)
137
+ Gem::Specification.new do |s|
138
+ s.name = "mocha"
139
+ s.summary = "Mocking and stubbing library"
140
+ s.version = version
141
+ s.platform = Gem::Platform::RUBY
142
+ s.author = 'James Mead'
143
+ s.description = <<-EOF
144
+ Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.
145
+ EOF
146
+ s.email = 'mocha-developer@googlegroups.com'
147
+ s.homepage = 'http://mocha.rubyforge.org'
148
+ s.rubyforge_project = 'mocha'
149
+
150
+ s.has_rdoc = true
151
+ s.extra_rdoc_files = ['README', 'COPYING']
152
+ s.rdoc_options << '--title' << 'Mocha' << '--main' << 'README' << '--line-numbers'
153
+
154
+ s.add_dependency('rake')
155
+ s.files = FileList['{lib,test,examples}/**/*.rb', '[A-Z]*'].exclude('TODO').to_a
156
+ end
157
+ end
158
+
159
+ specification = build_specification
160
+
161
+ Rake::GemPackageTask.new(specification) do |package|
162
+ package.need_zip = true
163
+ package.need_tar = true
164
+ end
165
+
166
+ desc 'Generate updated gemspec with unique version, which will cause gem to be auto-built on github.'
167
+ task :update_gemspec do
168
+ File.open('mocha.gemspec', 'w') do |output|
169
+ output << build_specification(Mocha::VERSION + '.' + Time.now.strftime('%Y%m%d%H%M%S')).to_ruby
170
+ end
171
+ end
172
+
173
+ task 'verify_user' do
174
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
175
+ end
176
+
177
+ task 'verify_password' do
178
+ raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
179
+ end
180
+
181
+ desc "Publish package files on RubyForge."
182
+ task 'publish_packages' => ['verify_user', 'verify_password', 'clobber_package', 'package'] do
183
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "vendor", "meta_project-0.4.15", "lib"))
184
+ require 'meta_project'
185
+ require 'rake/contrib/xforge'
186
+ release_files = FileList[
187
+ "pkg/mocha-#{Mocha::VERSION}.gem",
188
+ "pkg/mocha-#{Mocha::VERSION}.tgz",
189
+ "pkg/mocha-#{Mocha::VERSION}.zip"
190
+ ]
191
+
192
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new('mocha')) do |release|
193
+ release.user_name = ENV['RUBYFORGE_USER']
194
+ release.password = ENV['RUBYFORGE_PASSWORD']
195
+ release.files = release_files.to_a
196
+ release.release_name = "Mocha #{Mocha::VERSION}"
197
+ release.release_changes = ''
198
+ release.release_notes = ''
199
+ end
200
+ end
201
+
202
+ desc "Do a full release."
203
+ task 'release' => ['default', 'generate_docs', 'publish_packages', 'publish_docs', 'update_gemspec'] do
204
+ puts
205
+ puts "*** Remember to commit newly generated gemspec after release ***"
206
+ puts
207
+ end
@@ -0,0 +1,55 @@
1
+ require 'mocha/class_method'
2
+
3
+ module Mocha
4
+
5
+ class AnyInstanceMethod < ClassMethod
6
+
7
+ def unstub
8
+ remove_new_method
9
+ restore_original_method
10
+ stubbee.any_instance.reset_mocha
11
+ end
12
+
13
+ def mock
14
+ stubbee.any_instance.mocha
15
+ end
16
+
17
+ def hide_original_method
18
+ if method_exists?(method)
19
+ begin
20
+ stubbee.send(:alias_method, hidden_method, method)
21
+ rescue NameError
22
+ # deal with nasties like ActiveRecord::Associations::AssociationProxy
23
+ end
24
+ end
25
+ end
26
+
27
+ def define_new_method
28
+ stubbee.class_eval("def #{method}(*args, &block); self.class.any_instance.mocha.method_missing(:#{method}, *args, &block); end", __FILE__, __LINE__)
29
+ end
30
+
31
+ def remove_new_method
32
+ stubbee.send(:remove_method, method)
33
+ end
34
+
35
+ def restore_original_method
36
+ if method_exists?(hidden_method)
37
+ begin
38
+ stubbee.send(:alias_method, method, hidden_method)
39
+ stubbee.send(:remove_method, hidden_method)
40
+ rescue NameError
41
+ # deal with nasties like ActiveRecord::Associations::AssociationProxy
42
+ end
43
+ end
44
+ end
45
+
46
+ def method_exists?(method)
47
+ return true if stubbee.public_instance_methods(false).include?(method)
48
+ return true if stubbee.protected_instance_methods(false).include?(method)
49
+ return true if stubbee.private_instance_methods(false).include?(method)
50
+ return false
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,21 @@
1
+ module Mocha
2
+
3
+ class ArgumentIterator
4
+
5
+ def initialize(argument)
6
+ @argument = argument
7
+ end
8
+
9
+ def each(&block)
10
+ if @argument.is_a?(Hash) then
11
+ @argument.each do |method_name, return_value|
12
+ block.call(method_name, return_value)
13
+ end
14
+ else
15
+ block.call(@argument)
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,17 @@
1
+ module Mocha
2
+
3
+ class BacktraceFilter
4
+
5
+ LIB_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), "..")) + File::SEPARATOR
6
+
7
+ def initialize(lib_directory = LIB_DIRECTORY)
8
+ @lib_directory = lib_directory
9
+ end
10
+
11
+ def filtered(backtrace)
12
+ backtrace.reject { |location| Regexp.new(@lib_directory).match(File.expand_path(location)) }
13
+ end
14
+
15
+ end
16
+
17
+ end