Class: Vigia::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vigia/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vigia/config.rb', line 6

def initialize
  @host                  = nil
  @source_file           = nil
  @rspec_config_block    = nil
  @load_default_examples = true
  @internal_hosts        = []
  @headers               = {}
  @custom_examples_paths = []
  @custom_examples       = []
  @hooks                 = []
  @stderr                = $stderr
  @stdout                = $stdout
  @adapter               = Vigia::Adapters::Blueprint
  @http_client_class     = Vigia::HttpClient::RestClient
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



4
5
6
# File 'lib/vigia/config.rb', line 4

def adapter
  @adapter
end

#custom_examplesObject

Returns the value of attribute custom_examples.



3
4
5
# File 'lib/vigia/config.rb', line 3

def custom_examples
  @custom_examples
end

#custom_examples_pathsObject

Returns the value of attribute custom_examples_paths.



3
4
5
# File 'lib/vigia/config.rb', line 3

def custom_examples_paths
  @custom_examples_paths
end

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/vigia/config.rb', line 3

def headers
  @headers
end

#hooksObject

Returns the value of attribute hooks.



4
5
6
# File 'lib/vigia/config.rb', line 4

def hooks
  @hooks
end

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/vigia/config.rb', line 3

def host
  @host
end

#http_client_classObject

Returns the value of attribute http_client_class.



3
4
5
# File 'lib/vigia/config.rb', line 3

def http_client_class
  @http_client_class
end

#internal_hostsObject

Returns the value of attribute internal_hosts.



4
5
6
# File 'lib/vigia/config.rb', line 4

def internal_hosts
  @internal_hosts
end

#load_default_examplesObject

Returns the value of attribute load_default_examples.



4
5
6
# File 'lib/vigia/config.rb', line 4

def load_default_examples
  @load_default_examples
end

#rspec_config_blockObject

Returns the value of attribute rspec_config_block.



4
5
6
# File 'lib/vigia/config.rb', line 4

def rspec_config_block
  @rspec_config_block
end

#source_fileObject

Returns the value of attribute source_file.



3
4
5
# File 'lib/vigia/config.rb', line 3

def source_file
  @source_file
end

#stderrObject

Returns the value of attribute stderr.



4
5
6
# File 'lib/vigia/config.rb', line 4

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



4
5
6
# File 'lib/vigia/config.rb', line 4

def stdout
  @stdout
end

Instance Method Details

#add_custom_examples_on(filter, name) ⇒ Object



28
29
30
# File 'lib/vigia/config.rb', line 28

def add_custom_examples_on(filter, name)
  @custom_examples << { filter: filter, name: name }
end

#after_context(&block) ⇒ Object



52
53
54
# File 'lib/vigia/config.rb', line 52

def after_context(&block)
  store_hook(Vigia::Sail::Context, :after, block)
end

#after_group(&block) ⇒ Object



40
41
42
# File 'lib/vigia/config.rb', line 40

def after_group(&block)
  store_hook(Vigia::Sail::GroupInstance, :after, block)
end

#before_context(&block) ⇒ Object



48
49
50
# File 'lib/vigia/config.rb', line 48

def before_context(&block)
  store_hook(Vigia::Sail::Context, :before, block)
end

#before_group(&block) ⇒ Object



36
37
38
# File 'lib/vigia/config.rb', line 36

def before_group(&block)
  store_hook(Vigia::Sail::GroupInstance, :before, block)
end

#extend_context(&block) ⇒ Object



56
57
58
# File 'lib/vigia/config.rb', line 56

def extend_context(&block)
  store_hook(Vigia::Sail::Context, :extend, block)
end

#extend_group(&block) ⇒ Object



44
45
46
# File 'lib/vigia/config.rb', line 44

def extend_group(&block)
  store_hook(Vigia::Sail::GroupInstance, :extend, block)
end

#rspec_config(&block) ⇒ Object



32
33
34
# File 'lib/vigia/config.rb', line 32

def rspec_config(&block)
  @rspec_config_block = block
end

#store_hook(rspec_class, filter, block) ⇒ Object



60
61
62
# File 'lib/vigia/config.rb', line 60

def store_hook(rspec_class, filter, block)
  @hooks << { rspec_class: rspec_class, filter: filter,  block: block }
end

#validate!Object



22
23
24
25
26
# File 'lib/vigia/config.rb', line 22

def validate!
  raise("You have to provide a host value in config or in the Apib") unless host

  true
end