mocha 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3182f55b0e553eb0559fee7df5f5fd71f824e219480715de2f35e7bfacb5d9b2
4
- data.tar.gz: 485677b5a3628ccee3730274697f27defb4fc087cc838d7c4ec8dac4e3cd589d
3
+ metadata.gz: 77366bffa410729ac6089097db85ded323e74d1ec7bc6eb0ea13ae4a18b44eac
4
+ data.tar.gz: f9f3c89bbc29393e99ec62e0d1395ed4fa4863d0f790d24bbe6be3537450e4c1
5
5
  SHA512:
6
- metadata.gz: 1f782e0791e221f18081e35a298a039b96afd7a06caf4177a3d117e3803ee2165d9cd5dd6c19edde9334fda7dea973c105a5c3fe7070810dd0e7229901df056f
7
- data.tar.gz: 8adf5cf18b21d7039c7c8f10b4c7a49ba4a215d9351cdd89a04d7a4371eda9863727b08e5bdbb240d92dd6cc93555306b13501370ecdadd4b6a74368213851c5
6
+ metadata.gz: 91e277be3c868ef2f6655016a53f040835b8e9d6390c789b6f047be72e9b96726865eefcb161b86d0f8e89ead1c58e9adbf1a1cbcdf9cba8a0f0b536de86222d
7
+ data.tar.gz: 4b7bf751e350762a5a3d9cd17fbe1a590ff5122a718417b75304fa86f8323b20652a24584cedabd859395aeef004402e57c70c15cd88746032659b0d9df4cccf
data/CONTRIBUTING.md CHANGED
@@ -3,5 +3,5 @@
3
3
  * Make your changes in a branch.
4
4
  * Add/modify/remove tests as appropriate.
5
5
  * Open a pull request based on a branch on your fork.
6
- * Wait for your pull request build to pass on [Travis CI](https://travis-ci.com/github/freerange/mocha/pull_requests).
6
+ * Wait for your pull request build to pass on [Circle CI](https://app.circleci.com/pipelines/github/freerange/mocha).
7
7
  * Pull requests with failing tests will not be accepted.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Mocha [![Build Status](https://travis-ci.com/freerange/mocha.svg?branch=main)](https://travis-ci.com/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha) [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=mocha&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=mocha&package-manager=bundler&version-scheme=semver)
1
+ ## Mocha [![CircleCI status of freerange/mocha](https://circleci.com/gh/freerange/mocha.svg?style=shield&circle-token=bc1f6576c77da43ec58badde9273fa4eb1d7f53a)](https://app.circleci.com/pipelines/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha) [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=mocha&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=mocha&package-manager=bundler&version-scheme=semver)
2
2
 
3
3
  ### Description
4
4
 
@@ -323,7 +323,7 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contri
323
323
  * Update the RELEASE.md file with a summary of changes
324
324
  * Bump the version in `lib/mocha/version.rb`
325
325
  * Commit & push to GitHub
326
- * Check Travis CI build is passing - https://travis-ci.com/github/freerange/mocha
326
+ * Check CircleCI build is passing - https://app.circleci.com/pipelines/github/freerange/mocha
327
327
 
328
328
  * Sign in to Google Analytics - https://analytics.google.com/analytics/web/
329
329
  * Find the web property ID for floehopper (625523) > Mocha Documentation (UA-625523-7)
data/RELEASE.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### External changes
6
+
7
+ * Add `ParameterMatchers#has_keys` - thanks to @cstyles for #512 (18d8104)
8
+ * Fix misleading exception message in `ParameterMatchers#has_entry` - thanks to @cstyles for #513 (9c4ef13)
9
+ * Only add dependency on rubocop if we're actually going to use it (f2f879f)
10
+ * Fix rake dependency constraints for older Ruby versions (7ce5f29)
11
+
12
+ ### Internal changes
13
+
14
+ * Check documentation can be generated as part of CircleCI build (b30d9a9)
15
+ * Add --fail-on-warning option to yard rake task (53a6ee3)
16
+ * Add a weekly scheduled build to the CircleCI build (fd2a4c6)
17
+ * Add Ruby v1.8 to the CircleCI build matrix (818ca03)
18
+ * Add API token to fix CircleCI badge in README (607c5aa)
19
+ * Provide wrapped option for #mocha_inspect on hashes & arrays (d8f44bc)
20
+ * Use CircleCI instead of TravisCI for automated builds (c98c6ec)
21
+ * Switch to newer default Travis CI build env (c78f75c)
22
+ * Use latest Ruby versions in Travis CI builds (9e0043a)
23
+ * Use latest JRuby v9.2.18 in Travis CI builds (8c99a1b)
24
+ * Use consistent JRuby versions in Travis CI builds (0f849aa)
25
+ * Use more recent version of JRuby in Travis CI build matrix (58653db)
26
+
3
27
  ## 1.12.0
4
28
 
5
29
  ### External changes
data/Rakefile CHANGED
@@ -138,7 +138,7 @@ if ENV['MOCHA_GENERATE_DOCS']
138
138
 
139
139
  desc 'Generate documentation'
140
140
  YARD::Rake::YardocTask.new('yardoc' => 'docs_environment') do |task|
141
- task.options = ['--title', "Mocha #{Mocha::VERSION}"]
141
+ task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
142
142
  end
143
143
 
144
144
  task 'checkout_docs_cname' do
data/lib/mocha/inspect.rb CHANGED
@@ -11,14 +11,16 @@ module Mocha
11
11
  end
12
12
 
13
13
  module ArrayMethods
14
- def mocha_inspect
15
- "[#{collect(&:mocha_inspect).join(', ')}]"
14
+ def mocha_inspect(wrapped = true)
15
+ unwrapped = collect(&:mocha_inspect).join(', ')
16
+ wrapped ? "[#{unwrapped}]" : unwrapped
16
17
  end
17
18
  end
18
19
 
19
20
  module HashMethods
20
- def mocha_inspect
21
- "{#{collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')}}"
21
+ def mocha_inspect(wrapped = true)
22
+ unwrapped = collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')
23
+ wrapped ? "{#{unwrapped}}" : unwrapped
22
24
  end
23
25
  end
24
26
 
@@ -13,6 +13,7 @@ require 'mocha/parameter_matchers/equals'
13
13
  require 'mocha/parameter_matchers/has_entry'
14
14
  require 'mocha/parameter_matchers/has_entries'
15
15
  require 'mocha/parameter_matchers/has_key'
16
+ require 'mocha/parameter_matchers/has_keys'
16
17
  require 'mocha/parameter_matchers/has_value'
17
18
  require 'mocha/parameter_matchers/includes'
18
19
  require 'mocha/parameter_matchers/instance_of'
@@ -42,20 +42,10 @@ module Mocha
42
42
  #
43
43
  def has_entry(*options) # rubocop:disable Naming/PredicateName
44
44
  case options.length
45
+ when 0
46
+ raise ArgumentError, 'No arguments. Expecting at least one.'
45
47
  when 1
46
- case options[0]
47
- when Hash
48
- case options[0].length
49
- when 0
50
- raise ArgumentError, 'Argument has no entries.'
51
- when 1
52
- key, value = options[0].first
53
- else
54
- raise ArgumentError, 'Argument has multiple entries. Use Mocha::ParameterMatchers#has_entries instead.'
55
- end
56
- else
57
- raise ArgumentError, 'Argument is not a Hash.'
58
- end
48
+ key, value = parse_option(options[0])
59
49
  when 2
60
50
  key, value = options
61
51
  else
@@ -85,5 +75,24 @@ module Mocha
85
75
  "has_entry(#{@key.mocha_inspect} => #{@value.mocha_inspect})"
86
76
  end
87
77
  end
78
+
79
+ private
80
+
81
+ # @private
82
+ def parse_option(option)
83
+ case option
84
+ when Hash
85
+ case option.length
86
+ when 0
87
+ raise ArgumentError, 'Argument has no entries.'
88
+ when 1
89
+ option.first
90
+ else
91
+ raise ArgumentError, 'Argument has multiple entries. Use Mocha::ParameterMatchers#has_entries instead.'
92
+ end
93
+ else
94
+ raise ArgumentError, 'Argument is not a Hash.'
95
+ end
96
+ end
88
97
  end
89
98
  end
@@ -0,0 +1,53 @@
1
+ require 'mocha/parameter_matchers/base'
2
+
3
+ module Mocha
4
+ module ParameterMatchers
5
+ # Matches +Hash+ containing +keys+.
6
+ #
7
+ # @param [*Array<Object>] keys expected keys.
8
+ # @return [HasKeys] parameter matcher.
9
+ #
10
+ # @see Expectation#with
11
+ #
12
+ # @example Actual parameter contains entry with expected keys.
13
+ # object = mock()
14
+ # object.expects(:method_1).with(has_keys(:key_1, :key_2))
15
+ # object.method_1(:key_1 => 1, :key_2 => 2, :key_3 => 3)
16
+ # # no error raised
17
+ #
18
+ # @example Actual parameter does not contain all expected keys.
19
+ # object = mock()
20
+ # object.expects(:method_1).with(has_keys(:key_1, :key_2))
21
+ # object.method_1(:key_2 => 2)
22
+ # # error raised, because method_1 was not called with Hash containing key: :key_1
23
+ #
24
+ def has_keys(*keys) # rubocop:disable Naming/PredicateName
25
+ HasKeys.new(*keys)
26
+ end
27
+
28
+ # Parameter matcher which matches when actual parameter contains +Hash+ with all expected keys.
29
+ class HasKeys < Base
30
+ # @private
31
+ def initialize(*keys)
32
+ raise ArgumentError, 'No arguments. Expecting at least one.' if keys.empty?
33
+
34
+ @keys = keys
35
+ end
36
+
37
+ # @private
38
+ def matches?(available_parameters)
39
+ parameter = available_parameters.shift
40
+ return false unless parameter.respond_to?(:keys)
41
+
42
+ @keys.map(&:to_matcher).all? do |matcher|
43
+ parameter.keys.any? { |key| matcher.matches?([key]) }
44
+ end
45
+ end
46
+
47
+ # @private
48
+ def mocha_inspect
49
+ "has_keys(#{@keys.mocha_inspect(false)})"
50
+ end
51
+ end
52
+ end
53
+ end
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '1.12.0'.freeze
2
+ VERSION = '1.13.0'.freeze
3
3
  end
data/mocha.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
15
15
  s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|test)/}) }
17
17
  end
18
- s.files.delete('.travis.yml')
18
+ s.files.delete('.circleci/config.yml')
19
19
  s.files.delete('.gitignore')
20
20
 
21
21
  s.homepage = 'https://mocha.jamesmead.org'
@@ -30,18 +30,22 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
30
30
  end
31
31
  end
32
32
 
33
- if RUBY_VERSION >= '1.9.3'
34
- s.add_development_dependency('rake')
33
+ if RUBY_VERSION < '1.9.3'
34
+ s.add_development_dependency 'rake', '~> 10.0'
35
+ elsif RUBY_VERSION < '2'
36
+ s.add_development_dependency 'rake', '~> 12.2.1'
37
+ elsif RUBY_VERSION < '2.2'
38
+ s.add_development_dependency 'rake', '~> 12.3.3'
35
39
  else
36
- # Rake >= v11 does not support Ruby < v1.9.3 so use
37
- s.add_development_dependency('rake', '~> 10.0')
40
+ s.add_development_dependency 'rake'
38
41
  end
42
+
39
43
  s.add_development_dependency('introspection', '~> 0.0.1')
40
44
  if RUBY_VERSION >= '2.2.0'
41
45
  # No test libraries in standard library
42
46
  s.add_development_dependency('minitest')
43
47
  end
44
- if RUBY_VERSION >= '1.9.2'
48
+ if RUBY_VERSION >= '2.2.0'
45
49
  s.add_development_dependency('rubocop', '<= 0.58.2')
46
50
  end
47
51
  if ENV['MOCHA_GENERATE_DOCS']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -85,21 +85,7 @@ files:
85
85
  - README.md
86
86
  - RELEASE.md
87
87
  - Rakefile
88
- - bin/build-matrix
89
- - gemfiles/Gemfile.minitest.1.3.0
90
- - gemfiles/Gemfile.minitest.1.4.0
91
- - gemfiles/Gemfile.minitest.1.4.1
92
- - gemfiles/Gemfile.minitest.1.4.2
93
- - gemfiles/Gemfile.minitest.2.0.0
94
- - gemfiles/Gemfile.minitest.2.0.1
95
- - gemfiles/Gemfile.minitest.2.11.0
96
- - gemfiles/Gemfile.minitest.2.11.2
97
- - gemfiles/Gemfile.minitest.2.3.0
98
- - gemfiles/Gemfile.minitest.5.11.3
99
88
  - gemfiles/Gemfile.minitest.latest
100
- - gemfiles/Gemfile.test-unit.2.0.0
101
- - gemfiles/Gemfile.test-unit.2.0.1
102
- - gemfiles/Gemfile.test-unit.2.0.3
103
89
  - gemfiles/Gemfile.test-unit.latest
104
90
  - init.rb
105
91
  - lib/mocha.rb
@@ -174,6 +160,7 @@ files:
174
160
  - lib/mocha/parameter_matchers/has_entries.rb
175
161
  - lib/mocha/parameter_matchers/has_entry.rb
176
162
  - lib/mocha/parameter_matchers/has_key.rb
163
+ - lib/mocha/parameter_matchers/has_keys.rb
177
164
  - lib/mocha/parameter_matchers/has_value.rb
178
165
  - lib/mocha/parameter_matchers/includes.rb
179
166
  - lib/mocha/parameter_matchers/instance_methods.rb
data/bin/build-matrix DELETED
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'yaml'
4
- require 'set'
5
- require 'English'
6
-
7
- def execute(*commands)
8
- commands.each do |command|
9
- system(command)
10
- next if $CHILD_STATUS.success?
11
- message = [
12
- 'Executing shell command failed.',
13
- " Command: #{command}",
14
- " Status: #{$CHILD_STATUS.exitstatus}"
15
- ].join("\n")
16
- raise message
17
- end
18
- end
19
-
20
- def reset_bundle
21
- execute(
22
- 'rm -rf .bundle/gems',
23
- 'rm -rf gemfiles/.bundle/gems',
24
- 'rm -f *.lock',
25
- 'rm -f gemfiles/*.lock'
26
- )
27
- end
28
-
29
- def with_rbenv(command)
30
- %{export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; #{command}}
31
- end
32
-
33
- def run(ruby_version, gemfile, task = 'test')
34
- ENV['RBENV_VERSION'] = ruby_version
35
- ENV['BUNDLE_GEMFILE'] = gemfile
36
- ENV['MOCHA_OPTIONS'] = 'debug'
37
- reset_bundle
38
- execute(
39
- with_rbenv("bundle install --gemfile=#{gemfile}"),
40
- with_rbenv("bundle exec rake #{task}")
41
- )
42
- end
43
-
44
- AVAILABLE_RUBY_VERSIONS = `rbenv versions --bare`.split("\n")
45
-
46
- travis_config = YAML.safe_load(File.read('.travis.yml'))
47
- build_configs = travis_config['matrix']['include']
48
- travis_config['rvm'].each do |ruby_version|
49
- travis_config['gemfile'].each do |gemfile|
50
- travis_config['env'].each do |env|
51
- build_configs << { 'rvm' => ruby_version, 'gemfile' => gemfile, 'env' => env }
52
- end
53
- end
54
- end
55
-
56
- missing_ruby_versions = Set.new
57
-
58
- build_configs.each do |config|
59
- ruby_version = config['rvm']
60
- gemfile = config['gemfile']
61
- environment_variables = Hash[*config['env'].split.flat_map { |e| e.split('=') }]
62
- original_environment_variables = {}
63
- begin
64
- environment_variables.each do |k, v|
65
- original_environment_variables[k] = ENV[k]
66
- ENV[k] = v
67
- end
68
- if AVAILABLE_RUBY_VERSIONS.include?(ruby_version)
69
- puts
70
- puts "Ruby v#{ruby_version}; Gemfile path: #{gemfile}; Environment: #{environment_variables}"
71
- run(ruby_version, gemfile)
72
- else
73
- missing_ruby_versions << ruby_version
74
- end
75
- ensure
76
- original_environment_variables.each do |k, v|
77
- ENV[k] = v
78
- end
79
- end
80
- end
81
-
82
- puts "Missing Ruby versions: #{missing_ruby_versions.to_a.join(', ')}"
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "1.3.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "1.4.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "1.4.1"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "1.4.2"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "2.0.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "2.0.1"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "2.11.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "2.11.2"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "2.3.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "minitest", "5.11.3"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "test-unit", "2.0.0"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "test-unit", "2.0.1"
7
- end
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec :path=>"../"
4
-
5
- group :development do
6
- gem "test-unit", "2.0.3"
7
- end