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

Create test helpers #2

Open
splattael opened this issue Jan 27, 2015 · 4 comments
Open

Create test helpers #2

splattael opened this issue Jan 27, 2015 · 4 comments

Comments

@splattael
Copy link
Contributor

It would be nice to streamline testing for candy check so stubbing verification gets easier.

More info to follow.

@fourcolors
Copy link

I'd also like this

@jnbt
Copy link
Owner

jnbt commented Oct 31, 2016

Let's discuss the feature-set for this test helper:

  • I expect to fake the results of CandyCheck::AppStore::Verifier and CandyCheck::PlayStore::Verifier: returning a Receipt, a VerificationFailure or raising an error.
  • Should this be done globally or per instance? Global faking would make the test look nicer, but I fear problems due to concurrency.
  • I think we need a core implementation and in a best case scenario test framework adapters.

@fourcolors
Copy link

So thoughts on this.

I think it should be similar to how the Ruby geocoder gem does it. I know this is a Rails example but here is how we implemented stubbing out geolocation request form that gem, its similar concept in that is using a google api service. In this case, we just have two services, apple and google.

module GeocodingHelpers
  def stub_location_lookup(locations)
    locations.each do |query, properties|
      Geocoder::Lookup::Test.add_stub(
        query,
        [properties.with_indifferent_access],
      )
    end
  end

  def stub_unknown_location_lookup(query)
    allow(Geocoder).to receive(:coordinates).with(query).and_return(nil)
  end
end

RSpec.configure do |config|
  config.before(:all) { Geocoder.configure(lookup: :test) }
  config.include GeocodingHelpers
end

For reference, the geolocator test app is here: https://github.com/alexreisner/geocoder_test

We could make some improvements I'm sure but might be worth looking at as a good starting point.

Also, I think if everything is written where dependency injection is requried ie: fetch libs etc, stubbing out a specific instance shouldn't be hard. It would be nice to be able to set up a 'test' mode which returns some stubbed objects of ReceiptStub and VerificationFailureStub

@jnbt
Copy link
Owner

jnbt commented Nov 2, 2016

I think this would be a step in the right direction. In detail the gem should not make assumptions about the test framework, but could be instrumented as in the given example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants