Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Multiple Stub Requests #216

Merged
merged 3 commits into from
Dec 9, 2023

Conversation

scudelletti
Copy link
Contributor

Hello there! 👋

Since we support multiple requests when using fixtures I thought it would be nice to support multiple requests also when using the :stub option.

This feature is quite useful in scenarios in which we need to create stubs manually or dynamically.

Usage:

  stubs = [
    [url: "http://example.com/1", body: "Stub Response 1", status_code: 200],
    [url: "http://example.com/2", body: "Stub Response 2", status_code: 404]
  ]

  use_cassette :stub, stubs do
    {:ok, response} = Finch.build(:get, "http://example.com/1") |> Finch.request(ExVCRFinch)
    assert response.status == 200
    assert response.body =~ ~r/Stub Response 1/

    {:ok, response} = Finch.build(:get, "http://example.com/2") |> Finch.request(ExVCRFinch)
    assert response.status == 404
    assert response.body =~ ~r/Stub Response 2/
  end

Thank you for your time and for maintaining this awesome library!
Please let me know if any change is required.

@scudelletti scudelletti force-pushed the ds-add-multiple-stub-support branch from 52edf26 to bbc1dbc Compare December 6, 2023 13:13
@coveralls
Copy link

Coverage Status

coverage: 90.061% (-2.8%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 89.908% (-2.9%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 89.908% (-2.9%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 89.407% (-3.5%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 90.061% (-2.8%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 88.532% (-4.3%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 87.92% (-4.9%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 88.073% (-4.8%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 88.379% (-4.5%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@coveralls
Copy link

Coverage Status

coverage: 87.994% (-4.9%) from 92.857%
when pulling bbc1dbc on scudelletti:ds-add-multiple-stub-support
into 5023de6 on parroty:master.

@parroty parroty merged commit 01cb24f into parroty:master Dec 9, 2023
11 checks passed
@parroty
Copy link
Owner

parroty commented Dec 9, 2023

Thanks!

@scudelletti scudelletti deleted the ds-add-multiple-stub-support branch December 9, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants