Class: Crspec::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/crspec/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/crspec/configuration.rb', line 13

def initialize
  @concurrency = Etc.nprocessors
  @fibers = 1
  @use_transactional_fixtures = true
  @formatter = nil
  @before_hooks = []
  @after_hooks = []
  @around_hooks = []
  @included_modules = []
  @infer_spec_type = false
  @fixture_paths = []
  @file_fixture_path = nil
end

Instance Attribute Details

#after_hooksObject (readonly)

Returns the value of attribute after_hooks.



11
12
13
# File 'lib/crspec/configuration.rb', line 11

def after_hooks
  @after_hooks
end

#around_hooksObject (readonly)

Returns the value of attribute around_hooks.



11
12
13
# File 'lib/crspec/configuration.rb', line 11

def around_hooks
  @around_hooks
end

#before_hooksObject (readonly)

Returns the value of attribute before_hooks.



11
12
13
# File 'lib/crspec/configuration.rb', line 11

def before_hooks
  @before_hooks
end

#concurrencyObject

Returns the value of attribute concurrency.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def concurrency
  @concurrency
end

#example_status_persistence_file_pathObject

Returns the value of attribute example_status_persistence_file_path.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def example_status_persistence_file_path
  @example_status_persistence_file_path
end

#fibersObject

Returns the value of attribute fibers.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def fibers
  @fibers
end

#file_fixture_pathObject



27
28
29
# File 'lib/crspec/configuration.rb', line 27

def file_fixture_path
  @file_fixture_path || File.join("spec", "fixtures", "files")
end

#fixture_pathsObject

Returns the value of attribute fixture_paths.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def fixture_paths
  @fixture_paths
end

#formatterObject

Returns the value of attribute formatter.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def formatter
  @formatter
end

#included_modulesObject (readonly)

Returns the value of attribute included_modules.



11
12
13
# File 'lib/crspec/configuration.rb', line 11

def included_modules
  @included_modules
end

#use_transactional_fixturesObject

Returns the value of attribute use_transactional_fixtures.



9
10
11
# File 'lib/crspec/configuration.rb', line 9

def use_transactional_fixtures
  @use_transactional_fixtures
end

Instance Method Details

#after(*args, **kwargs, &block) ⇒ Object



36
37
38
39
# File 'lib/crspec/configuration.rb', line 36

def after(*args, **kwargs, &block)
  reject_serial_scope!(:after, args)
  @after_hooks.unshift({ block: block, filters: args, kwfilters: kwargs })
end

#around(*args, **kwargs, &block) ⇒ Object



41
42
43
# File 'lib/crspec/configuration.rb', line 41

def around(*args, **kwargs, &block)
  @around_hooks << { block: block, filters: args, kwfilters: kwargs }
end

#before(*args, **kwargs, &block) ⇒ Object



31
32
33
34
# File 'lib/crspec/configuration.rb', line 31

def before(*args, **kwargs, &block)
  reject_serial_scope!(:before, args)
  @before_hooks << { block: block, filters: args, kwfilters: kwargs }
end

#define_derived_metadata(*args) ⇒ Object



76
77
# File 'lib/crspec/configuration.rb', line 76

def (*args)
end

#expect_with(*args) ⇒ Object



79
80
# File 'lib/crspec/configuration.rb', line 79

def expect_with(*args)
end

#filter_rails_from_backtrace!Object



73
74
# File 'lib/crspec/configuration.rb', line 73

def filter_rails_from_backtrace!
end

#include(mod, *filters, **kwfilters) ⇒ Object



45
46
47
# File 'lib/crspec/configuration.rb', line 45

def include(mod, *filters, **kwfilters)
  @included_modules << { module: mod, filters: filters, kwfilters: kwfilters }
end

#infer_spec_type?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/crspec/configuration.rb', line 53

def infer_spec_type?
  !!@infer_spec_type
end

#infer_spec_type_from_file_location!Object



49
50
51
# File 'lib/crspec/configuration.rb', line 49

def infer_spec_type_from_file_location!
  @infer_spec_type = true
end

#infer_type_for_file_path(file_path) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/crspec/configuration.rb', line 57

def infer_type_for_file_path(file_path)
  return nil unless @infer_spec_type
  case file_path.to_s
  when %r{spec/controllers/} then :controller
  when %r{spec/requests/}, %r{spec/api/} then :request
  when %r{spec/models/} then :model
  when %r{spec/helpers/} then :helper
  when %r{spec/system/} then :system
  when %r{spec/views/} then :view
  when %r{spec/components/} then :component
  when %r{spec/mailers/} then :mailer
  when %r{spec/jobs/} then :job
  when %r{spec/services/} then :service
  end
end

#mock_with(*args) ⇒ Object



82
83
# File 'lib/crspec/configuration.rb', line 82

def mock_with(*args)
end