flexmock 2.3.6 → 2.3.8

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
- SHA1:
3
- metadata.gz: 10c81d85395c9cb8d2f2ec418fa925152082a699
4
- data.tar.gz: 2602ebd6fb2d2b77b6627ba42b1fbbadb31b6854
2
+ SHA256:
3
+ metadata.gz: 55dadc89381c542f0d6f81c9484b4febc6adf1ef2b8292a504d60406e4c6f915
4
+ data.tar.gz: 80eb120f913a93d90f855442ab0bf8fc13bbec222279dec77340979a8cc8f024
5
5
  SHA512:
6
- metadata.gz: d68327dfd946bf6119291610513fd3a98718b031fc98742e5641177f78f51b10398fcb676832e61737cbf68b447de6cb0b726fa8fdc1b6e27591ab672826febc
7
- data.tar.gz: 93bd5f2683c1bf3250986d82fbcce88afdd4f7f6866eb76a926ade7c07f27b9ea71759ddc864c58371cff9e984813fb1cef990c4dac663bd3d027e6f971531b7
6
+ metadata.gz: 8afcf774571ed28b0e90b631ebfb88e91812c9494f2bef4c3b1d36dc4726514c7fb21ff22f6c9accd5331f214a5f5f12826b5d1d07a6868fb39a6154d016a0f7
7
+ data.tar.gz: 7b3bf8f227f97efb5e4a6cb8d80d9e5ef4a2c1f29e8978fadb95597b419010f1abeaf8650bdbc533389fd09746aeae597fc97447ec2b7e46507f36cff180dc58
@@ -0,0 +1,32 @@
1
+ name: Unit Tests
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: ["2.7", "2.6", "2.5"]
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
17
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
18
+ # uses: ruby/setup-ruby@v1
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ - name: Configure bundler without 'vscode'
23
+ run: bundle config set --local without vscode
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rake test
28
+ env:
29
+ GIT_AUTHOR_NAME: flexmock CI Git Identity
30
+ GIT_AUTHOR_EMAIL: flexmock@github.actions
31
+ GIT_COMMITTER_NAME: flexmock CI Git Identity
32
+ GIT_COMMITTER_EMAIL: flexmock@github.actions
data/.travis.yml CHANGED
@@ -1,19 +1,32 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - '2.0'
5
- - 2.1.10
6
- - 2.2.5
7
- - 2.3.1
8
- - 2.4.0
3
+ - 2.2
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
7
+ - 2.6
8
+ - 2.7
9
9
  - ruby-head
10
- - jruby-9.1.5.0
11
10
 
12
11
  matrix:
12
+ include:
13
+ - rvm: jruby-9.1.17.0
14
+ jdk: openjdk8
15
+ name: "JRuby 9.1"
16
+ - rvm: jruby-9.2.11.1
17
+ jdk: openjdk11
18
+ name: "JRuby 9.2"
19
+
13
20
  allow_failures:
14
21
  - rvm: ruby-head
22
+ # Revisit when fixing https://github.com/jruby/jruby/issues/4678
23
+ - name: "JRuby 9.2"
15
24
  fast_finish: true
16
25
 
26
+ env:
27
+ global:
28
+ - JRUBY_OPTS="--debug"
29
+
17
30
  script:
18
31
  - rake test
19
32
  - rake test_rspec
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Flex Mock -- Making Mocking Easy
2
2
 
3
3
  [![Build Status](https://travis-ci.org/doudou/flexmock.svg?branch=master)](https://travis-ci.org/doudou/flexmock)
4
- [![Gem Version](https://badge.fury.io/rb/flexmock.svg)](http://badge.fury.io/rb/flexmock)
4
+ [![Gem Version](https://badge.fury.io/rb/flexmock.svg)](https://badge.fury.io/rb/flexmock)
5
5
  [![Coverage Status](https://coveralls.io/repos/doudou/flexmock/badge.svg?branch=master&service=github)](https://coveralls.io/github/doudou/flexmock?branch=master)
6
- [![Documentation](http://b.repl.ca/v1/yard-docs-blue.png)](http://rubydoc.info/gems/flexmock/frames)
6
+ [![API Documentation](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/gems/flexmock/frames)
7
7
 
8
8
  FlexMock is a simple, but flexible, mock object library for Ruby unit
9
9
  testing.
data/doc/index.rdoc CHANGED
@@ -4,20 +4,20 @@ FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
6
  This is the API documentation site for flexmock. You can find the user
7
- documentation at http://github.com/jimweirich/flexmock
7
+ documentation at http://github.com/doudou/flexmock
8
8
 
9
9
  == Links
10
10
 
11
- * <b>User Guide</b> -- http://github.com/jimweirich/flexmock
12
- * <b>API Documents</b> -- http://flexmock.rubyforge.org
11
+ * <b>User Guide</b> -- http://github.com/doudou/flexmock
13
12
  * <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
13
+ * <b>Source</b> -- https://github.com/doudou/flexmock
14
+ * <b>Bug Reports / Issue Tracking</b> -- https://github.com/doudou/flexmock/issues
15
+ * <b>Continuous Integration</b> -- http://travis-ci.org/#!/doudou/flexmock
17
16
 
18
17
  == License
19
18
 
20
19
  Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
20
+ Copyright 2013-2020 by Sylvain Joyeux (sylvain.joyeux@m4x.org)
21
21
  All rights reserved.
22
22
 
23
23
  Permission is granted for use, copying, modification, distribution,
data/flexmock.gemspec CHANGED
@@ -10,13 +10,13 @@ spec = Gem::Specification.new do |s|
10
10
  interface is simple, it is very flexible.
11
11
  }
12
12
 
13
- s.required_ruby_version = ">= 2.0"
13
+ s.required_ruby_version = ">= 2.2"
14
14
 
15
15
  s.license = 'MIT'
16
16
 
17
17
  #### Dependencies and requirements.
18
18
 
19
- s.add_development_dependency 'minitest'
19
+ s.add_development_dependency 'minitest', ">= 5.0"
20
20
  s.add_development_dependency 'rake'
21
21
  s.add_development_dependency 'simplecov', '>= 0.11.0'
22
22
  s.add_development_dependency 'coveralls'
File without changes
File without changes
data/lib/flexmock/base.rb CHANGED
File without changes
data/lib/flexmock/core.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -98,7 +98,11 @@ class FlexMock
98
98
  end
99
99
 
100
100
  def assertion_failed_error
101
- MiniTest::Assertion
101
+ if defined?(::Minitest)
102
+ ::Minitest::Assertion
103
+ else
104
+ MiniTest::Assertion
105
+ end
102
106
  end
103
107
 
104
108
  def check_failed_error
File without changes
data/lib/flexmock/noop.rb CHANGED
File without changes
@@ -99,21 +99,14 @@ class FlexMock
99
99
  :invoke_original
100
100
  ]
101
101
 
102
- attr_reader :method_definitions
103
-
104
102
  # Initialize a PartialMockProxy object.
105
103
  def initialize(obj, mock, safe_mode, parent: nil)
106
104
  @obj = obj
107
105
  @mock = mock
108
106
  @proxy_definition_module = nil
107
+ @parent = parent
109
108
  @initialize_override = nil
110
109
 
111
- if parent
112
- @method_definitions = parent.method_definitions.dup
113
- else
114
- @method_definitions = {}
115
- end
116
-
117
110
  unless safe_mode
118
111
  add_mock_method(:should_receive)
119
112
  MOCK_METHODS.each do |sym|
@@ -175,9 +168,33 @@ class FlexMock
175
168
  flexmock_invoke_original(m, args)
176
169
  end
177
170
 
171
+ # Whether the given method's original definition has been stored
172
+ def find_original_method(m)
173
+ it = @obj.method(m)
174
+ while it && (it.owner != @proxy_definition_module)
175
+ it = it.super_method
176
+ end
177
+
178
+ return unless it
179
+ while it && it.owner.kind_of?(ProxyDefinitionModule)
180
+ it = it.super_method
181
+ end
182
+ it
183
+ rescue NameError => e
184
+ raise unless e.name == m
185
+ end
186
+
187
+ # Whether the given method's original definition has been stored
188
+ def original_method(m)
189
+ unless (m = find_original_method(m))
190
+ raise ArgumentError, "no original method for #{m}"
191
+ end
192
+ m
193
+ end
194
+
178
195
  # Whether the given method's original definition has been stored
179
196
  def has_original_method?(m)
180
- @method_definitions.has_key?(m)
197
+ find_original_method(m)
181
198
  end
182
199
 
183
200
  # Whether the given method is already being proxied
@@ -188,12 +205,12 @@ class FlexMock
188
205
 
189
206
  def flexmock_define_expectation(location, *args)
190
207
  EXP_BUILDER.parse_should_args(self, args) do |method_name|
191
- if !has_proxied_method?(method_name) && !has_original_method?(method_name)
192
- hide_existing_method(method_name)
208
+ if !has_proxied_method?(method_name)
209
+ define_proxy_method(method_name)
193
210
  end
194
211
  ex = @mock.flexmock_define_expectation(location, method_name)
195
212
  if FlexMock.partials_verify_signatures
196
- if existing_method = @method_definitions[method_name]
213
+ if (existing_method = find_original_method(method_name))
197
214
  ex.with_signature_matching(existing_method)
198
215
  end
199
216
  end
@@ -207,7 +224,6 @@ class FlexMock
207
224
  end
208
225
 
209
226
  def add_mock_method(method_name)
210
- stow_existing_definition(method_name)
211
227
  proxy_module_eval do
212
228
  define_method(method_name) { |*args, &block|
213
229
  proxy = __flexmock_proxy or
@@ -316,12 +332,12 @@ class FlexMock
316
332
  # Invoke the original definition of method on the object supported by
317
333
  # the stub.
318
334
  def flexmock_invoke_original(method, args)
319
- if original_method = @method_definitions[method]
335
+ if (original_method = find_original_method(method))
320
336
  if Proc === args.last
321
337
  block = args.last
322
338
  args = args[0..-2]
323
339
  end
324
- original_method.bind(@obj).call(*args, &block)
340
+ original_method.call(*args, &block)
325
341
  else
326
342
  @obj.__send__(:method_missing, method, *args, &block)
327
343
  end
@@ -394,11 +410,14 @@ class FlexMock
394
410
  target_singleton_class.class_eval(*args, &block)
395
411
  end
396
412
 
413
+ class ProxyDefinitionModule < Module
414
+ end
415
+
397
416
  # Evaluate a block into the module we use to define the proxy methods
398
417
  def proxy_module_eval(*args, &block)
399
418
  if !@proxy_definition_module
400
419
  obj = @obj
401
- @proxy_definition_module = m = Module.new do
420
+ @proxy_definition_module = m = ProxyDefinitionModule.new do
402
421
  define_method("__flexmock_proxy") do
403
422
  if box = obj.instance_variable_get(:@flexmock_proxy)
404
423
  box.proxy
@@ -417,19 +436,7 @@ class FlexMock
417
436
  # not a singleton, all we need to do is override it with our own
418
437
  # singleton.
419
438
  def hide_existing_method(method_name)
420
- existing_method = stow_existing_definition(method_name)
421
439
  define_proxy_method(method_name)
422
- existing_method
423
- end
424
-
425
- # Stow the existing method definition so that it can be recovered
426
- # later.
427
- def stow_existing_definition(method_name)
428
- if !@method_definitions.has_key?(method_name)
429
- @method_definitions[method_name] = target_class_eval { instance_method(method_name) }
430
- end
431
- @method_definitions[method_name]
432
- rescue NameError
433
440
  end
434
441
 
435
442
  # Define a proxy method that forwards to our mock object. The
File without changes
File without changes
File without changes
@@ -68,7 +68,7 @@ class FlexMock
68
68
  def assertion_failed_error
69
69
  defined?(Test::Unit::AssertionFailedError) ?
70
70
  Test::Unit::AssertionFailedError :
71
- MiniTest::Assertion
71
+ Minitest::Assertion
72
72
  end
73
73
 
74
74
  def check_failed_error
@@ -30,8 +30,8 @@ class FlexMock
30
30
  end
31
31
  end
32
32
 
33
- if defined?(MiniTest)
34
- module MiniTest
33
+ if defined?(Minitest)
34
+ module Minitest
35
35
  class Unit
36
36
  class TestCase
37
37
  FlexMock::GenericTestCase.define_extensions_on(self)
File without changes
@@ -1,3 +1,3 @@
1
1
  class FlexMock
2
- VERSION = "2.3.6"
2
+ VERSION = "2.3.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexmock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
4
+ version: 2.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-02 00:00:00.000000000 Z
12
+ date: 2023-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '5.0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '5.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +76,7 @@ extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
78
  - ".autotest"
79
+ - ".github/workflows/test.yml"
79
80
  - ".gitignore"
80
81
  - ".togglerc"
81
82
  - ".travis.yml"
@@ -178,15 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
179
  requirements:
179
180
  - - ">="
180
181
  - !ruby/object:Gem::Version
181
- version: '2.0'
182
+ version: '2.2'
182
183
  required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  requirements:
184
185
  - - ">="
185
186
  - !ruby/object:Gem::Version
186
187
  version: '0'
187
188
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.5.1
189
+ rubygems_version: 3.1.6
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Simple and Flexible Mock Objects for Testing