File tree Expand file tree Collapse file tree 14 files changed +251
-14
lines changed Expand file tree Collapse file tree 14 files changed +251
-14
lines changed Original file line number Diff line number Diff line change @@ -112,20 +112,20 @@ jobs:
112
112
./cc-test-reporter before-build
113
113
bundle exec rspec
114
114
115
- # - run:
116
- # name: Creating CodeClimate test coverage report
117
- # command: |
118
- # ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
115
+ - run :
116
+ name : Creating CodeClimate test coverage report
117
+ command : |
118
+ ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
119
119
120
120
- store_artifacts :
121
121
name : Saving Simplecov coverage artifacts
122
122
path : ~/ruby-rspec-mock/coverage
123
123
destination : coverage
124
124
125
- # - deploy:
126
- # name: Uploading CodeClimate test coverage report
127
- # command: |
128
- # ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
125
+ - deploy :
126
+ name : Uploading CodeClimate test coverage report
127
+ command : |
128
+ ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
129
129
130
130
compatibility-ruby :
131
131
parameters :
Original file line number Diff line number Diff line change 9
9
plugins :
10
10
rubocop :
11
11
enabled : true
12
- channel : rubocop-1-65
12
+ channel : rubocop-1-66
13
13
config :
14
14
file : .circleci/linter_configs/.rubocop.yml
15
15
Original file line number Diff line number Diff line change 3
3
detectors :
4
4
IrresponsibleModule :
5
5
enabled : false
6
+
7
+ BooleanParameter :
8
+ exclude :
9
+ - RSpec::Mock::Context#respond_to_missing?
10
+
11
+ ManualDispatch :
12
+ exclude :
13
+ - RSpec::Mock::Context#method_missing
14
+ - RSpec::Mock::Context#respond_to_missing?
Original file line number Diff line number Diff line change 1
1
# Seamless migration from third-party mocks to RSpec built-in mocking framework
2
2
3
- [ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/5ea9da61ef468b8ad4c4 /maintainability )] ( https://codeclimate.com/github/mocktools/ruby-rspec-mock/maintainability )
4
- [ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/5ea9da61ef468b8ad4c4 /test_coverage )] ( https://codeclimate.com/github/mocktools/ruby-rspec-mock/test_coverage )
3
+ [ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/8a7a9ca7f590838bf02f /maintainability )] ( https://codeclimate.com/github/mocktools/ruby-rspec-mock/maintainability )
4
+ [ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/8a7a9ca7f590838bf02f /test_coverage )] ( https://codeclimate.com/github/mocktools/ruby-rspec-mock/test_coverage )
5
5
[ ![ CircleCI] ( https://circleci.com/gh/mocktools/ruby-rspec-mock/tree/master.svg?style=svg )] ( https://circleci.com/gh/mocktools/ruby-rspec-mock/tree/master )
6
6
[ ![ Gem Version] ( https://badge.fury.io/rb/rspec-mock.svg )] ( https://badge.fury.io/rb/rspec-mock )
7
7
[ ![ Downloads] ( https://img.shields.io/gem/dt/rspec-mock.svg?colorA=004d99&colorB=0073e6 )] ( https://rubygems.org/gems/rspec-mock )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Core
5
+ class Configuration
6
+ include RSpec ::Mock ::Configuration
7
+ end
8
+ end
9
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Mock
5
+ module Configuration
6
+ def rspec_mock
7
+ RSpec ::Mocks . configuration . tap do |config |
8
+ yield config if block_given?
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Mock
5
+ class Context
6
+ include RSpec ::Mocks ::ExampleMethods
7
+ include RSpec ::Matchers
8
+
9
+ def initialize ( example_group )
10
+ @example_group = example_group
11
+ end
12
+
13
+ def method_missing ( method , *args , &block )
14
+ if @example_group . respond_to? ( method )
15
+ @example_group . send ( method , *args , &block )
16
+ else
17
+ super
18
+ end
19
+ end
20
+
21
+ def respond_to_missing? ( method , include_private = false )
22
+ @example_group . respond_to? ( method , include_private ) || super
23
+ end
24
+ end
25
+ end
26
+ end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
+ require 'rspec/core'
4
+ require 'rspec/mocks'
5
+
3
6
module RSpec
4
7
module Mock
8
+ require_relative 'configuration'
9
+ require_relative 'context'
10
+ require_relative 'methods'
5
11
require_relative 'version'
6
12
end
13
+
14
+ module Core
15
+ require_relative '../core/configuration'
16
+ end
7
17
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Mock
5
+ module Methods
6
+ def rspec_mock ( &block )
7
+ return unless block_given?
8
+
9
+ RSpec ::Mocks . with_temporary_scope do
10
+ RSpec ::Mock ::Context . new ( self ) . instance_eval ( &block )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ RSpec . describe RSpec ::Mock ::Configuration do
4
+ let ( :test_class ) do
5
+ Class . new do
6
+ include RSpec ::Mock ::Configuration
7
+ end
8
+ end
9
+
10
+ let ( :instance ) { test_class . new }
11
+ let ( :mock_config ) { instance_double ( 'RSpec::Mocks::Configuration' ) }
12
+
13
+ before { allow ( RSpec ::Mocks ) . to receive ( :configuration ) . and_return ( mock_config ) }
14
+
15
+ describe '#rspec_mock' do
16
+ context 'when block is given' do
17
+ it 'yields the configuration object' do
18
+ expect ( mock_config ) . to receive ( :tap ) . and_yield ( mock_config )
19
+ expect { |block | instance . rspec_mock ( &block ) } . to yield_with_args ( mock_config )
20
+ end
21
+ end
22
+
23
+ context 'when no block is given' do
24
+ it 'returns the configuration object' do
25
+ expect ( mock_config ) . to receive ( :tap )
26
+ expect ( instance . rspec_mock ) . to be_nil
27
+ end
28
+ end
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments