Skip to content

Commit b51ea56

Browse files
authored
Merge pull request #112 from ChrisBr/cb/make-spec-helper-available
Move RSpec helper to lib directory
2 parents 32bafcc + b598235 commit b51ea56

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

spec/support/matchers.rb renamed to lib/influxdb/rails/helpers/rspec_matchers.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path(File.dirname(__FILE__) + "/test_client")
1+
require_relative "../test_client"
22
require "launchy"
33

44
module InfluxDB
@@ -25,11 +25,24 @@ def save_and_open_metrics
2525
::Launchy.open(file_path)
2626
end
2727

28-
private
29-
3028
def metrics
3129
TestClient.metrics
3230
end
31+
32+
RSpec.configure do |config|
33+
config.before :each do
34+
InfluxDB::Rails.instance_variable_set :@configuration, nil
35+
InfluxDB::Rails.configure
36+
37+
allow(InfluxDB::Rails).to receive(:client).and_return(InfluxDB::Rails::TestClient.new)
38+
allow_any_instance_of(InfluxDB::Rails::Configuration)
39+
.to receive(:ignored_environments).and_return(%w[development])
40+
41+
InfluxDB::Rails::TestClient.metrics.clear
42+
end
43+
44+
config.include InfluxDB::Rails::Matchers
45+
end
3346
end
3447
end
3548
end

spec/spec_helper.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
22
$LOAD_PATH.unshift(File.dirname(__FILE__))
33
require "active_support"
4-
require File.expand_path(File.dirname(__FILE__) + "/support/matchers")
4+
require_relative "../lib/influxdb/rails/helpers/rspec_matchers"
55
require File.expand_path(File.dirname(__FILE__) + "/support/broken_client")
66

77
ENV["RAILS_ENV"] ||= "test"
@@ -29,23 +29,11 @@
2929
# use expect syntax
3030
config.disable_monkey_patching!
3131

32-
# reset configuration for each spec
33-
config.before :each do
34-
InfluxDB::Rails.instance_variable_set :@configuration, nil
35-
InfluxDB::Rails.configure
36-
37-
allow(InfluxDB::Rails).to receive(:client).and_return(InfluxDB::Rails::TestClient.new)
38-
allow_any_instance_of(InfluxDB::Rails::Configuration).to receive(:ignored_environments).and_return(%w[development])
39-
40-
InfluxDB::Rails::TestClient.metrics.clear
41-
end
42-
4332
config.after(:each) do
4433
travel_back
4534
end
4635

4736
config.include ActiveSupport::Testing::TimeHelpers
4837
config.include ActiveJob::TestHelper
49-
config.include InfluxDB::Rails::Matchers
5038
config.include InfluxDB::Rails::BrokenClient
5139
end

spec/support/broken_client.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require File.expand_path(File.dirname(__FILE__) + "/test_client")
2-
31
module InfluxDB
42
module Rails
53
module BrokenClient

0 commit comments

Comments
 (0)