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

"FakeWeb.allow_net_connect = true" doesn't work with PORO/ElasticSearch #42

Open
BartlomiejSkwira opened this issue Nov 1, 2013 · 0 comments

Comments

@BartlomiejSkwira
Copy link

In my Rails project I have a utility class (plain old ruby object) which does a request to GitHub api and saves Project model. Just a moment ago I have started using ElasticSearch and my Project model has some stuff indexed. Each time I save this model a request to ElasticSearch is made on port 9200. Majority of my tests started to fail (because of the extra requests) with a message:

 FakeWeb::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: PUT http://localhost:9200/karma_tracker_test/project/236

Now when I do

FakeWeb.allow_net_connect = true
#or 
FakeWeb.allow_net_connect = %r[^https?://localhost:9200]

explicitly in a test, or in a before(:each) block in spec_helper the test still fails. But if I put the same line in my utility class just before save, the test passes

Whole code is online at https://github.com/amberbit/KarmaTracker/tree/feature/59079242_elastic_search - failing test spec/model/pivotal_tracker_projects_fetcher_spec.rb:16, failing class app/services/pivotal_tracker_projects_fetcher.rb line 18

Adding a test-related logic inside app logic feels really bad. Any way to make it more clean or is it a bug?

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

No branches or pull requests

1 participant