At some point in my test, this will be called:
Event.delay.create!(
event_type: Event::EventType::FOOD_SUBSCRIPTION_STARTED,
description: 'Automatically populated',
app_context: "iphone"
)
and then this:
Event.delay.create!(
event_type: Event::EventType::FOOD_SUBSCRIPTION_COMPLETED,
description: 'Automatically populated',
app_context: "iphone"
)
So I have to handle the delay and handle the different arguments.
I have this so far:
it 'logs events' do
allow(Event).to receive(:delay).and_return(Event)
expect(Event).to receive(:create!).with(hash_including(
app_context: app_context,
event_type: Event::EventType::FOOD_SUBSCRIPTION_STARTED))
subject
end
I am also trying this:
let(:first_event) { class_double('Event').as_stubbed_const(:transfer_nested_constants => true) }
let(:second_event) { class_double('Event').as_stubbed_const(:transfer_nested_constants => true) }
it 'logs events' do
allow(Event).to receive(:delay).and_return(first_event)
expect(first_event).to receive(:create!).with(hash_including(
app_context: app_context,
event_type: Event::EventType::FOOD_SUBSCRIPTION_STARTED)).ordered
expect(first_event).to receive(:create!).with(hash_including(
app_context: app_context,
event_type: Event::EventType::FOOD_SUBSCRIPTION_COMPLETED)).ordered
subject
end
Nothing works. What can I do?
Aucun commentaire:
Enregistrer un commentaire