Skip to content

Commit

Permalink
Prevent kwargs warnings when building swapped-in handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dgholz committed May 8, 2020
1 parent 6d41c57 commit 385cd6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/faraday/rack_builder.rb
Expand Up @@ -131,7 +131,7 @@ def locked?
insert(index + 1, *args, &block)
end

def swap(index, *args, &block)
ruby2_keywords def swap(index, *args, &block)
raise_if_locked
index = assert_index(index)
@handlers.delete_at(index)
Expand Down
9 changes: 9 additions & 0 deletions spec/faraday/rack_builder_spec.rb
Expand Up @@ -328,5 +328,14 @@ def initialize(app, name:)
).to_stderr
expect(rock.name).to eq('Rocky')
end

it 'adds a handler with options passed to swap' do
subject.insert 0, rock_handler, name: 'Flint'
subject.swap 0, rock_handler, name: 'Chert'
expect { rock }.to_not output(
/warning: Using the last argument as keyword parameters is deprecated/
).to_stderr
expect(rock.name).to eq('Chert')
end
end
end

0 comments on commit 385cd6d

Please sign in to comment.