sr
12/22/2023, 12:54 PMtest or development?
bundle exec rake pact:verify
rake aborted!
KeyError: key not found: "RAILS_ENV"
2. The API request in the consumer pact is a GET request to get foo/123. How do I ensure this id and associated data will exist in the database? (either test or dev). Surely I don't create this data but if I need do how is this done? I was under the impression that Provider simply pulls down the contract and runs it against an instance of the app. Since this will run on CI then I assume it will run against test and out sqlite3 db?sr
01/05/2024, 2:25 PMWARN: Ignoring unsupported combine AND for path
in terms of ensuring the test data is there, I am using the provider_states_for and inserting into the test database.
The only way I can get this to work is by using the:
setup_do
... // using factorybot to create the item in sqlite3
end
if i tried to use:
provider_state "there is a foo named test foo" do
set_up do
.. // using factorybot to create the item in sqlite3
end
end
it never works, the code in the provider state never gets called. I assumed it was some naming issue, in that the providerState field in the pact contract json needed to match the provider_state in the provider rb file. Both are exactly called there is a foo named test foo so i am not sure what the issue could be?
The pact provider and consumer names also match up and are the same in the json file and the pact_helper.rb etc
i am using the pact 1.64.0 ruby gem.
``````Yousaf Nabi (pactflow.io)
sr
01/09/2024, 11:42 AMprovider_state is not working? I have to use the base state to setup the data, but this is less than ideal.
No matter what I try, the provider_state block never gets executedsr
01/09/2024, 11:48 AMrequire 'factory_bot_rails'
include FactoryBot::Syntax::Methods
Pact.provider_states_for 'GEB' do
provider_state "there is an Thing named Test Thing" do
set_up do
Thing.delete_by(id: 1)
create(:thing, id: 1, name: 'Test Thing', postal_addresses: [create(:postal_address, country_id: 1, postal_zip_code: "abc123")])
end
tear_down do
# Any tear down steps to clean up the provider state
end
end
provider_state "a thing does not exist" do
no_op # If there's nothing to do because the state name is more for documentation purposes,
# you can use no_op to imply this.
end
end