dradis-mediawiki 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +16 -0
  3. data/.github/pull_request_template.md +36 -0
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +51 -0
  6. data/CONTRIBUTING.md +3 -0
  7. data/Gemfile +23 -0
  8. data/LICENSE +339 -0
  9. data/README.md +32 -0
  10. data/Rakefile +1 -0
  11. data/dradis-mediawiki.gemspec +31 -0
  12. data/lib/dradis-mediawiki.rb +2 -0
  13. data/lib/dradis/plugins/mediawiki.rb +10 -0
  14. data/lib/dradis/plugins/mediawiki/engine.rb +17 -0
  15. data/lib/dradis/plugins/mediawiki/filters.rb +68 -0
  16. data/lib/dradis/plugins/mediawiki/gem_version.rb +21 -0
  17. data/lib/dradis/plugins/mediawiki/version.rb +9 -0
  18. data/lib/tasks/thorfile.rb +17 -0
  19. data/spec/spec_helper.rb +22 -0
  20. data/spec/wiki_import_spec.rb +18 -0
  21. data/test/vendor/mocha-0.9.5/COPYING +3 -0
  22. data/test/vendor/mocha-0.9.5/MIT-LICENSE +7 -0
  23. data/test/vendor/mocha-0.9.5/README +37 -0
  24. data/test/vendor/mocha-0.9.5/README.dradis +4 -0
  25. data/test/vendor/mocha-0.9.5/RELEASE +269 -0
  26. data/test/vendor/mocha-0.9.5/Rakefile +207 -0
  27. data/test/vendor/mocha-0.9.5/lib/mocha.rb +49 -0
  28. data/test/vendor/mocha-0.9.5/lib/mocha/any_instance_method.rb +55 -0
  29. data/test/vendor/mocha-0.9.5/lib/mocha/argument_iterator.rb +21 -0
  30. data/test/vendor/mocha-0.9.5/lib/mocha/backtrace_filter.rb +17 -0
  31. data/test/vendor/mocha-0.9.5/lib/mocha/cardinality.rb +95 -0
  32. data/test/vendor/mocha-0.9.5/lib/mocha/central.rb +27 -0
  33. data/test/vendor/mocha-0.9.5/lib/mocha/change_state_side_effect.rb +19 -0
  34. data/test/vendor/mocha-0.9.5/lib/mocha/class_method.rb +87 -0
  35. data/test/vendor/mocha-0.9.5/lib/mocha/configuration.rb +60 -0
  36. data/test/vendor/mocha-0.9.5/lib/mocha/deprecation.rb +22 -0
  37. data/test/vendor/mocha-0.9.5/lib/mocha/exception_raiser.rb +17 -0
  38. data/test/vendor/mocha-0.9.5/lib/mocha/expectation.rb +476 -0
  39. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_error.rb +15 -0
  40. data/test/vendor/mocha-0.9.5/lib/mocha/expectation_list.rb +50 -0
  41. data/test/vendor/mocha-0.9.5/lib/mocha/in_state_ordering_constraint.rb +19 -0
  42. data/test/vendor/mocha-0.9.5/lib/mocha/inspect.rb +67 -0
  43. data/test/vendor/mocha-0.9.5/lib/mocha/instance_method.rb +16 -0
  44. data/test/vendor/mocha-0.9.5/lib/mocha/is_a.rb +9 -0
  45. data/test/vendor/mocha-0.9.5/lib/mocha/logger.rb +15 -0
  46. data/test/vendor/mocha-0.9.5/lib/mocha/metaclass.rb +13 -0
  47. data/test/vendor/mocha-0.9.5/lib/mocha/method_matcher.rb +21 -0
  48. data/test/vendor/mocha-0.9.5/lib/mocha/mini_test_adapter.rb +50 -0
  49. data/test/vendor/mocha-0.9.5/lib/mocha/mock.rb +200 -0
  50. data/test/vendor/mocha-0.9.5/lib/mocha/mockery.rb +181 -0
  51. data/test/vendor/mocha-0.9.5/lib/mocha/module_method.rb +16 -0
  52. data/test/vendor/mocha-0.9.5/lib/mocha/multiple_yields.rb +20 -0
  53. data/test/vendor/mocha-0.9.5/lib/mocha/names.rb +53 -0
  54. data/test/vendor/mocha-0.9.5/lib/mocha/no_yields.rb +11 -0
  55. data/test/vendor/mocha-0.9.5/lib/mocha/object.rb +187 -0
  56. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers.rb +27 -0
  57. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/all_of.rb +42 -0
  58. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_of.rb +47 -0
  59. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/any_parameters.rb +40 -0
  60. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/anything.rb +33 -0
  61. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/base.rb +15 -0
  62. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/equals.rb +42 -0
  63. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entries.rb +45 -0
  64. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_entry.rb +56 -0
  65. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_key.rb +42 -0
  66. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/has_value.rb +42 -0
  67. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/includes.rb +40 -0
  68. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/instance_of.rb +42 -0
  69. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/is_a.rb +42 -0
  70. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/kind_of.rb +42 -0
  71. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/not.rb +42 -0
  72. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/object.rb +15 -0
  73. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/optionally.rb +55 -0
  74. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/regexp_matches.rb +43 -0
  75. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/responds_with.rb +43 -0
  76. data/test/vendor/mocha-0.9.5/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
  77. data/test/vendor/mocha-0.9.5/lib/mocha/parameters_matcher.rb +37 -0
  78. data/test/vendor/mocha-0.9.5/lib/mocha/pretty_parameters.rb +28 -0
  79. data/test/vendor/mocha-0.9.5/lib/mocha/return_values.rb +31 -0
  80. data/test/vendor/mocha-0.9.5/lib/mocha/sequence.rb +42 -0
  81. data/test/vendor/mocha-0.9.5/lib/mocha/single_return_value.rb +17 -0
  82. data/test/vendor/mocha-0.9.5/lib/mocha/single_yield.rb +18 -0
  83. data/test/vendor/mocha-0.9.5/lib/mocha/standalone.rb +166 -0
  84. data/test/vendor/mocha-0.9.5/lib/mocha/state_machine.rb +91 -0
  85. data/test/vendor/mocha-0.9.5/lib/mocha/stubbing_error.rb +16 -0
  86. data/test/vendor/mocha-0.9.5/lib/mocha/test_case_adapter.rb +103 -0
  87. data/test/vendor/mocha-0.9.5/lib/mocha/unexpected_invocation.rb +18 -0
  88. data/test/vendor/mocha-0.9.5/lib/mocha/yield_parameters.rb +31 -0
  89. data/test/vendor/mocha-0.9.5/lib/mocha_standalone.rb +2 -0
  90. data/test/vendor/mocha-0.9.5/lib/stubba.rb +4 -0
  91. data/test/wiki_import_test.rb +106 -0
  92. metadata +249 -0
@@ -0,0 +1,32 @@
1
+ # MediaWiki add-on for Dradis
2
+
3
+ [![Build Status](https://secure.travis-ci.org/dradis/dradis-mediawiki.png?branch=master)](http://travis-ci.org/dradis/dradis-mediawiki) [![Code Climate](https://codeclimate.com/github/dradis/dradis-mediawiki.png)](https://codeclimate.com/github/dradis/dradis-mediawiki.png)
4
+
5
+
6
+ A simple wrapper around the MediaWiki API to connect it to the Dradis Framework.
7
+
8
+ The idea is to be able to use a MediaWiki as a library of re-usable report entries for your projects.
9
+
10
+ The add-on performs a text search against the WikiMedia API. See http://www.mediawiki.org/wiki/API for further reference.
11
+
12
+ The add-on requires [Dradis CE](https://dradisframework.org/) > 3.0, or [Dradis Pro](https://dradisframework.com/pro/).
13
+
14
+
15
+ ## More information
16
+
17
+ See the Dradis Framework's [README.md](https://github.com/dradis/dradisframework/blob/master/README.md)
18
+
19
+
20
+ ## Contributing
21
+
22
+ See the Dradis Framework's [CONTRIBUTING.md](https://github.com/dradis/dradisframework/blob/master/CONTRIBUTING.md)
23
+
24
+
25
+ ## License
26
+
27
+ Dradis Framework and all its components are released under [GNU General Public License version 2.0](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.
28
+
29
+
30
+ ## Feature requests and bugs
31
+
32
+ Please use the [Dradis Framework issue tracker](https://github.com/dradis/dradis-ce/issues) for add-on improvements and bug reports.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'dradis/plugins/mediawiki/version'
3
+ version = Dradis::Plugins::Mediawiki::VERSION::STRING
4
+
5
+ # Describe your gem and declare its dependencies:
6
+ Gem::Specification.new do |spec|
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.name = 'dradis-mediawiki'
9
+ spec.version = version
10
+ spec.summary = 'MediaWiki add-on for the Dradis Framework.'
11
+ spec.description = 'Use a MediaWiki instance as source of re-usable issue entries for Dradis Framework.'
12
+
13
+ spec.license = 'GPL-2'
14
+
15
+ spec.authors = ['Daniel Martin']
16
+ spec.email = ['etd@nomejortu.com']
17
+ spec.homepage = 'http://dradisframework.org'
18
+
19
+ spec.files = `git ls-files`.split($\)
20
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+
23
+ # By not including Rails as a dependency, we can use the gem with different
24
+ # versions of Rails (a sure recipe for disaster, I'm sure), which is needed
25
+ # until we bump Dradis Pro to 4.1.
26
+ # s.add_dependency 'rails', '~> 4.1.1'
27
+ spec.add_dependency 'dradis-plugins', '~> 3.0'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.6'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ end
@@ -0,0 +1,2 @@
1
+ require 'net/http'
2
+ require 'dradis/plugins/mediawiki'
@@ -0,0 +1,10 @@
1
+ module Dradis
2
+ module Plugins
3
+ module Mediawiki
4
+ end
5
+ end
6
+ end
7
+
8
+ require 'dradis/plugins/mediawiki/engine'
9
+ require 'dradis/plugins/mediawiki/filters'
10
+ require 'dradis/plugins/mediawiki/version'
@@ -0,0 +1,17 @@
1
+ module Dradis::Plugins::Mediawiki
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Dradis::Plugins::Mediawiki
4
+
5
+ include ::Dradis::Plugins::Base
6
+ provides :import
7
+ description 'Import entries from an external MediaWiki'
8
+
9
+ addon_settings :wikiimport do
10
+ settings.default_fields = 'Title,Impact,Probability,Description,Recommendation'
11
+ settings.default_host = 'localhost'
12
+ settings.default_path = 'mediawiki/api.php'
13
+ settings.default_port = 443
14
+ settings.default_scheme = 'http(s)'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,68 @@
1
+ module Dradis::Plugins::Mediawiki::Filters
2
+ class FullTextSearch < Dradis::Plugins::Import::Filters::Base
3
+ def query(params={})
4
+ results = []
5
+
6
+ host = Dradis::Plugins::Mediawiki::Engine.settings.host
7
+ path = Dradis::Plugins::Mediawiki::Engine.settings.path
8
+ port = Dradis::Plugins::Mediawiki::Engine.settings.port
9
+ scheme = Dradis::Plugins::Mediawiki::Engine.settings.scheme
10
+
11
+ port = (scheme == 'https' ? 443 : 80) if port.blank?
12
+
13
+ begin
14
+ # Parameters required by MediaWiki API
15
+ # http://localhost/mediawiki-1.21.1/api.php?action=query&prop=revisions&generator=search&gsrwhat=text&gsrsearch=Directory&rvprop=content&format=xml
16
+ filter_params = {
17
+ action: 'query',
18
+ prop: 'revisions',
19
+ generator: 'search',
20
+ gsrwhat: 'text',
21
+ gsrsearch: CGI::escape(params[:query]), # user query
22
+ rvprop: 'content',
23
+ format: 'xml'
24
+ }
25
+
26
+ # Get the results over HTTP
27
+ Net::HTTP.start(host, port, use_ssl: scheme == 'https') do |http|
28
+ res = http.get("#{path}?#{filter_params.to_query}")
29
+ xml_doc = Nokogiri::XML( res.body )
30
+ results += xml_doc.xpath('api/query/pages/page').map do |xml_page|
31
+ Dradis::Plugins::Import::Result.new(
32
+ title: xml_page[:title],
33
+ description: fields_from_wikitext(xml_page.at_xpath('revisions/rev').text())
34
+ )
35
+ end
36
+ end
37
+
38
+ #rescue Exception => e
39
+ # records << {
40
+ # :title => 'Error fetching records',
41
+ # :description => e.message + "\n\n\n" +
42
+ # "This error can be cause by a configuration " +
43
+ # "issue (i.e. dradis not finding the MediaWiki instance). " +
44
+ # "Please review the configuration settings located at:\n\n" +
45
+ # "./server/vendor/plugins/wiki_import/lib/wiki_import/filters.rb"
46
+ # }
47
+ end
48
+
49
+ return results
50
+ end
51
+
52
+ private
53
+ # WikiMedia has its own formatting, and there are some tweaks we need to do
54
+ # to addapt it to standard dradis convention.
55
+ def fields_from_wikitext(wikitext)
56
+ fields = Dradis::Plugins::Mediawiki::Engine::settings.fields
57
+
58
+ dradis_fields = wikitext
59
+ fields = fields.split(',')
60
+ fields.each do |f|
61
+ dradis_fields.sub!( /=+#{f}=+/, "#[#{f}]#" )
62
+ end
63
+ return dradis_fields
64
+ end
65
+ end
66
+ end
67
+
68
+ Dradis::Plugins::Import::Filters.add :mediawiki, :full_text_search, Dradis::Plugins::Mediawiki::Filters::FullTextSearch
@@ -0,0 +1,21 @@
1
+ module Dradis
2
+ module Plugins
3
+ module Mediawiki
4
+
5
+ # Returns the version of the currently loaded Mediawiki plugin as a <tt>Gem::Version</tt>
6
+ def self.gem_version
7
+ Gem::Version.new VERSION::STRING
8
+ end
9
+
10
+ module VERSION
11
+ MAJOR = 3
12
+ MINOR = 18
13
+ TINY = 0
14
+ PRE = nil
15
+
16
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'gem_version'
2
+
3
+ module Dradis::Plugins::Mediawiki
4
+ # Returns the version of the currently loaded Mediawiki as a
5
+ # <tt>Gem::Version</tt>.
6
+ def self.version
7
+ gem_version
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ class MediawikiTasks < Thor
2
+ namespace "dradis:plugins:wiki"
3
+
4
+ desc "search QUERY", "perform a general search against a remote MediaWiki"
5
+ def search(query)
6
+ require 'config/environment'
7
+
8
+ results = Dradis::Plugins::Mediawiki::Filters::FullTextSearch.new.query(query: query)
9
+
10
+ puts "Wiki Search\n==========="
11
+ puts "#{results.size} results"
12
+
13
+ results.each do |record|
14
+ puts "#{record.title}\n\t#{record.description}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../../../../config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+
5
+ # Requires supporting ruby files with custom matchers and macros, etc,
6
+ # in spec/support/ and its subdirectories.
7
+ # require 'support/fixture_loader'
8
+
9
+ RSpec.configure do |config|
10
+
11
+ # uncomment to use :focus => true to run a single Spec
12
+ # config.filter_run :focus => true
13
+
14
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
15
+ # examples within a transaction, remove the following line or assign false
16
+ # instead of true.
17
+ config.use_transactional_fixtures = true
18
+
19
+ config.before(:suite) do
20
+ Configuration.create(:name=>'revision', :value=>'0')
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe WikiImport do
4
+ let(:source){ "=Title=\nEigen titel\n\n=Impact=\nbla\n\n=Reccommendation=\nniets\n\n\n=Description=\nleeg" }
5
+ let(:result){ "#[Title]#\nEigen titel\n\n#[Impact]#\nbla\n\n#[Reccommendation]#\nniets\n\n\n#[Description]#\nleeg" }
6
+
7
+ it "parses wiki markup to Dradis fields" do
8
+ config = Configuration.create(:name=>'wikiimport:fields', :value=>'Title,Impact,Reccommendation,Description')
9
+ WikiImport::fields_from_wikitext(source).should eq(result)
10
+ config.destroy
11
+ end
12
+
13
+ it "strips whitespace from the wikiimport:fields setting" do
14
+ config = Configuration.create(:name=>'wikiimport:fields', :value=>'Title, Impact,Reccommendation ,Description')
15
+ WikiImport::fields_from_wikitext(source).should eq(result)
16
+ config.destroy
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ Copyright Revieworld Ltd. 2006
2
+
3
+ You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt) or under the MIT license (see MIT-LICENSE file).
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2006 Revieworld Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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.