Skip to content

Make tests not to rely on the network #293

Closed
@sauloperez

Description

@sauloperez

When running the test suite in the local machine this is what I get:

➜  timeoverflow (develop) b rspec spec                                                                                                    ✱

Randomized with seed 64581
.....................................................................F.....................................*..........

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) User.actives should list users with active members
     # No reason given
     # ./spec/models/user_spec.rb:59


Failures:

  1) OffersController GET #index (search) populates an array of offers
     Failure/Error: Offer.__elasticsearch__.create_index!(force: true)
     
     Faraday::ConnectionFailed:
       Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)
     # ./spec/controllers/offers_controller_spec.rb:38:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Errno::ECONNREFUSED:
     #   Connection refused - connect(2) for "localhost" port 9200
     #   ./spec/controllers/offers_controller_spec.rb:38:in `block (3 levels) in <top (required)>'

Deprecation Warnings:

Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /home/pau/dev/timeoverflow/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.5.2/lib/active_support/dependencies.rb:274:in `require'.


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

1 deprecation warning total

Finished in 10.99 seconds (files took 4.4 seconds to load)
118 examples, 1 failure, 1 pending

Failed examples:

rspec ./spec/controllers/offers_controller_spec.rb:46 # OffersController GET #index (search) populates an array of offers

Randomized with seed 64581

We should fix the tests not to rely on the network. This makes the test suite brittle. We can consider taking a look at https://github.com/bblimke/webmock. It might the tool for this job.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions