Class: GraphWeaver::Testing::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_weaver/testing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/graph_weaver/testing.rb', line 44

def initialize
  @overrides = {}
  @seed = nil
  @list_size = 1..3
  @null_chance = 0.0
  @mode = nil # auto
  @schema = nil
  @cassette_dir = "spec/cassettes"
  # explicit opt-in: swapping every example onto a fake is too
  # surprising to be a default — a little friction beats unexpected
  # behavior (the schema still auto-locates once you opt in)
  @auto_fake = false
  # GRAPHWEAVER_RECORD=1 rspec ...  -> Cassette.use re-records
  @record = !ENV["GRAPHWEAVER_RECORD"].to_s.empty?
  # anonymize responses as they're recorded (needs config.schema)
  @anonymize = false
end

Instance Attribute Details

#anonymizeObject

Returns the value of attribute anonymize.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def anonymize
  @anonymize
end

#auto_fakeObject

Returns the value of attribute auto_fake.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def auto_fake
  @auto_fake
end

#cassette_dirObject

Returns the value of attribute cassette_dir.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def cassette_dir
  @cassette_dir
end

#list_sizeObject

Returns the value of attribute list_size.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def list_size
  @list_size
end

#modeObject

Returns the value of attribute mode.



42
43
44
# File 'lib/graph_weaver/testing.rb', line 42

def mode
  @mode
end

#null_chanceObject

Returns the value of attribute null_chance.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def null_chance
  @null_chance
end

#overridesObject

Returns the value of attribute overrides.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def overrides
  @overrides
end

#recordObject

Returns the value of attribute record.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def record
  @record
end

#schemaObject

the explicitly configured schema, else the conventional dump (SchemaLoader.locate at GraphWeaver.schema_path) — nil when neither exists, which quietly disables auto_fake



65
66
67
# File 'lib/graph_weaver/testing.rb', line 65

def schema
  @schema ||= GraphWeaver::SchemaLoader.locate
end

#seedObject

Returns the value of attribute seed.



39
40
41
# File 'lib/graph_weaver/testing.rb', line 39

def seed
  @seed
end