Git Product home page Git Product logo

Comments (5)

redox avatar redox commented on August 28, 2024

I think the stubs needs to be loaded in every test

Hmmm, maybe that's because you disable the mocking in a helper file or something required in every single test file?

In such case, the require should be done there as well.

The key difference is that I do load instead of require. Unfortunately doing load 'algolia/webmock' did not just work so I had to use $LOADED_FEATURES.find{|x| x.include?("algolia/version.rb") }.gsub("version.rb", "webmock.rb") to find the file and load it.

Yes, not very convenient :/

from algoliasearch-client-ruby.

paneq avatar paneq commented on August 28, 2024

In such case, the require should be done there as well.

How would that help if the require is only executed once and that's the point of using require over load ?

As to our setup, rails_helper has:

  config.before(:each) do |example|
    WebMock.disable_net_connect!(allow_localhost: true, allow: "localhost:9200")
  end

  config.after(:each) do |example|
    WebMock.allow_net_connect!
  end

from algoliasearch-client-ruby.

redox avatar redox commented on August 28, 2024

So should we wrap all the stubs in a method you would call in your config.before to setup everything?

Something like: Algolia::WebMock.enable! ?

from algoliasearch-client-ruby.

paneq avatar paneq commented on August 28, 2024

@redox sounds like a good approach.

from algoliasearch-client-ruby.

mintuhouse avatar mintuhouse commented on August 28, 2024

I am facing a similar issue. What is a recommended way to mock all algolia requests across the test suite?

from algoliasearch-client-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.