Skip to content
Closed
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
3 changes: 2 additions & 1 deletion lib/faraday/adapter/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ def to_s
end
end

def initialize(app, stubs = nil, &block)
def initialize(app, stubs_or_options = nil, &block)
super(app)
stubs = stubs_or_options.is_a?(Hash) ? stubs_or_options[:stubs] : stubs_or_options
@stubs = stubs || Stubs.new
configure(&block) if block
end
Expand Down
8 changes: 8 additions & 0 deletions spec/faraday/adapter/test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@

let(:response) { connection.get('/hello') }

it 'can receive stubs as a positional argument' do
expect(described_class.new(dummy_rack_app, stubs).stubs).to be stubs
end

it 'can receive stubs as a keyword argument' do
expect(described_class.new(dummy_rack_app, stubs: stubs).stubs).to be stubs
end

context 'with simple path sets status' do
subject { response.status }

Expand Down
4 changes: 4 additions & 0 deletions spec/support/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ def big_string
kb = 1024
(32..126).map(&:chr).cycle.take(50 * kb).join
end

def dummy_rack_app
->(_env) { [200, { 'content-type' => 'text/plain' }, ['Hello World']] }
end
end
end
Loading