solidusio-contrib / solidus_active_shipping

:package: Solidus integration for Shopify's active_shipping gem.
8 stars 22 forks source link

Improve Bogus carrier and limit stub usage #14

Closed fredericboivin closed 8 years ago

fredericboivin commented 8 years ago

Current spec is using fake classes but stubs every functions call and responses. This PR fixes the Bogus carrier / Bogus calculator so they can be used in the same manner as the live carriers / calculators

Instead of stubbing every function calls, we're just stubbing the responses when we need to raise errors or return empty/wrong response

fredericboivin commented 8 years ago

Also added a commit to make sure that the caching tests are giving the proper results. Without stubbing the carrier method of the calculator, we get different instances between the one returned by the calculator and the one we create in the test file

So if expect(carrier).not_to receive(:something), it works but only because the instance actually receiving (or not receiving) the function call is not the one we expect to (it's returned by the calculator)

fredericboivin commented 8 years ago

Addressed the feedback. rspec-activemodel-mocks is needed in the weight_limits spec so it's out of scope to remove it there after all.

And the BogusCarrier needs to include RSpec::Mocks::ExampleMethods (unless there's a better way?) because of the usage of instance_double in its find_rates method