Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins:
- rubocop-performance

require:
- rubocop-rake
- rubocop-rspec
- rubocop-rspec_rails
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log

## v1.3.1 (Jun 10, 2025)

### Misc

- [#1096](https://github.com/ryz310/my_api_client/pull/1096) Stubs `instance_reader` and `instance_writer` on the `class_attribute` ([@ryz310](https://github.com/ryz310))

## v1.3.0 (Jun 10, 2025)

### Feature
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
my_api_client (1.3.0)
my_api_client (1.3.1)
activesupport (>= 6.1.0)
faraday (>= 0.17.1)
jsonpath
Expand Down
3 changes: 2 additions & 1 deletion lib/my_api_client/rspec/stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def stub_api_client_all(klass, **actions_and_options)
# @return [InstanceDouble]
# Returns a spy object of the stubbed ApiClient.
def stub_api_client(klass, **actions_and_options)
instance = instance_double(klass)
instance = instance_double(klass, logger: klass.logger, 'logger=': nil,
error_handlers: klass.error_handlers)
actions_and_options.each { |action, options| stubbing(instance, action, options) }
instance
end
Expand Down
2 changes: 1 addition & 1 deletion lib/my_api_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module MyApiClient
VERSION = '1.3.0'
VERSION = '1.3.1'
end
16 changes: 16 additions & 0 deletions spec/lib/my_api_client/rspec/stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ def request_all
end

describe '#stub_api_client' do
describe 'class_attribute' do
let(:api_client) { stub_api_client(example_api_client) }

it 'stubs #logger' do
expect(api_client.logger).to eq example_api_client.logger
end

it 'stubs #logger=' do
expect { api_client.logger = Logger.new($stdout) }.not_to raise_error
end

it 'stubs #error_handlers' do
expect(api_client.error_handlers).to eq example_api_client.error_handlers
end
end

context 'when use Proc' do
let(:api_client) do
stub_api_client(
Expand Down
Loading