Releases: nepalez/fixturama
Releases · nepalez/fixturama
Bug fixes
Support PORO object <de>serialization
Use object()
method to serialize/deserialize PORO objects in a fixture:
# target.yml
---
number: <%= object(be_positive) %>
RSpec.describe "example" do
subject { { number: 42 } }
# no explicit parameters are needed to send `be_positive`
let(:target) { load_fixture "target.yml" }
it { is_expected.to match(target) }
end
In versions v0.4.1 and below, the same feature required sending data explicitly:
---
number: <%= positive %>
RSpec.describe "example" do
# ...
let(:target) { load_fixture "target.yml", positive: be_positive }
# ...
end
Update dependency from hashie
v0.4.1 Bump v0.4.1
Support stubbing of environment variables
---
- env: DEFAULT_EMAIL
value: foo@example.com
Support arguments of exceptions to be risen
---
- class: API
chain: get_product
arguments:
- 1
actions:
- raise: API::NotFoundError
arguments:
- "Cannot find product by id: 1"
This would raise the following exception instance:
API::NotFoundError.new("Cannot find product by id: 1")
Support single-source changes with `call_fixture`
# ./changes.yml
---
- type: user
params:
id: 1
- const: DEFAULT_USER_ID
value: 1
- url: https://example.com/users/default
method: get
responses:
- body:
id: 1
name: Andrew
before { call_fixture "#{__dir__}/changes.yml" }
Support stubbing of http requests
---
- url: https://example.com/foo
method: delete
headers:
Content-Language: en_US
basic_auth:
user: foo
password: bar
responses:
- status: 200 # for the first call
- status: 404 # for the other calls
Support stubbing of arbitrary objects
---
- object: Rails.application
chain: env
actions:
- return: production
In addition, this release adds support for partially defined key arguments during object/class stubbing.
See details at the CHANGELOG
Support serialization of arbitrary ruby objects
---
:account: <%= user %>
let(:user) { FactoryBot.create :user }
subject { load_fixture "#{__dir__}/output.yml", user: user }
# The `user` object has been bound via ERB
it { is_expected.to eq account: user }
Support stubbing of constants
Use the following syntax in "stubbing" fixtures:
---
- const: TIMEOUT
value: 10