Skip to content

Commit

Permalink
Merge pull request #112 from ChrisBr/cb/make-spec-helper-available
Browse files Browse the repository at this point in the history
Move RSpec helper to lib directory
  • Loading branch information
hennevogel authored May 13, 2020
2 parents 32bafcc + b598235 commit b51ea56
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.dirname(__FILE__) + "/test_client")
require_relative "../test_client"
require "launchy"

module InfluxDB
Expand All @@ -25,11 +25,24 @@ def save_and_open_metrics
::Launchy.open(file_path)
end

private

def metrics
TestClient.metrics
end

RSpec.configure do |config|
config.before :each do
InfluxDB::Rails.instance_variable_set :@configuration, nil
InfluxDB::Rails.configure

allow(InfluxDB::Rails).to receive(:client).and_return(InfluxDB::Rails::TestClient.new)
allow_any_instance_of(InfluxDB::Rails::Configuration)
.to receive(:ignored_environments).and_return(%w[development])

InfluxDB::Rails::TestClient.metrics.clear
end

config.include InfluxDB::Rails::Matchers
end
end
end
end
File renamed without changes.
14 changes: 1 addition & 13 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "active_support"
require File.expand_path(File.dirname(__FILE__) + "/support/matchers")
require_relative "../lib/influxdb/rails/helpers/rspec_matchers"
require File.expand_path(File.dirname(__FILE__) + "/support/broken_client")

ENV["RAILS_ENV"] ||= "test"
Expand Down Expand Up @@ -29,23 +29,11 @@
# use expect syntax
config.disable_monkey_patching!

# reset configuration for each spec
config.before :each do
InfluxDB::Rails.instance_variable_set :@configuration, nil
InfluxDB::Rails.configure

allow(InfluxDB::Rails).to receive(:client).and_return(InfluxDB::Rails::TestClient.new)
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development])

InfluxDB::Rails::TestClient.metrics.clear
end

config.after(:each) do
travel_back
end

config.include ActiveSupport::Testing::TimeHelpers
config.include ActiveJob::TestHelper
config.include InfluxDB::Rails::Matchers
config.include InfluxDB::Rails::BrokenClient
end
2 changes: 0 additions & 2 deletions spec/support/broken_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require File.expand_path(File.dirname(__FILE__) + "/test_client")

module InfluxDB
module Rails
module BrokenClient
Expand Down

0 comments on commit b51ea56

Please sign in to comment.