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

Avoid some stubbing in payment spec #1790

Merged

Conversation

jhawthorn
Copy link
Contributor

This stubbing no longer worked under rails 5.1 and was hiding behaviour of our system under test

Part of the work on #1788

This stubbing no longer worked under rails 5.1 and was hiding behaviour
of our system under test
Copy link
Contributor

@jordan-brough jordan-brough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one question. 👍 in any case.

payment.payment_method = gateway
payment.amount = 5
payment
Spree::Payment.create! do |payment|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - any reason not to use the payment factory here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same doubt and I noticed that in this same file payments are also created using Spree::PaymentCreate.new Service Object. Is there any reason/general rule to prefer a method or another?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer using just described_class.create in the spec for the model itself, otherwise you are testing the factory's output at the same time.

We probably shouldn't be using PaymentCreate in this file (that should be in the payment_create_spec.rb file), I suspect that's here because PaymentCreate replaced an some old payment behaviour.

@jhawthorn jhawthorn merged commit e0ac650 into solidusio:master Mar 30, 2017
@jhawthorn jhawthorn added this to the Rails 5.1 milestone Apr 26, 2017
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