Module: GraphWeaver::Testing::RSpecIntegration

Defined in:
lib/graph_weaver/rspec.rb

Class Method Summary collapse

Class Method Details

.install(rspec_config) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/graph_weaver/rspec.rb', line 32

def self.install(rspec_config)
  rspec_config.before(:suite) do
    config = GraphWeaver::Testing.config
    config.seed ||= RSpec.configuration.seed
  end

  rspec_config.before(:each) do
    config = GraphWeaver::Testing.config
    next unless config.auto_fake && config.schema

    @__graph_weaver_prior_client = GraphWeaver.client
    GraphWeaver.client = FakeClient.new(schema: config.schema)
  end

  rspec_config.after(:each) do
    config = GraphWeaver::Testing.config
    next unless config.auto_fake && config.schema

    GraphWeaver.client = @__graph_weaver_prior_client
  end
end