Class: ActiveMocker::LoadedMocks::Features

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/active_mocker/loaded_mocks/features.rb

Constant Summary collapse

STUB_ACTIVE_RECORD_EXCEPTIONS =
{
  "ActiveRecord::RecordNotFound"        => ActiveMocker::RecordNotFound,
  "ActiveRecord::RecordNotUnique"       => ActiveMocker::RecordNotUnique,
  "ActiveRecord::UnknownAttributeError" => ActiveMocker::UnknownAttributeError,
}
DEFAULTS =
{
  timestamps:                    false,
  delete_all_before_example:     false,
  stub_active_record_exceptions: STUB_ACTIVE_RECORD_EXCEPTIONS,
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeFeatures

Returns a new instance of Features.



20
21
22
# File 'lib/active_mocker/loaded_mocks/features.rb', line 20

def initialize
  reset
end

Instance Method Details

#[](feature) ⇒ Object



36
37
38
# File 'lib/active_mocker/loaded_mocks/features.rb', line 36

def [](feature)
  @features[feature]
end

#disable(feature) ⇒ Object



32
33
34
# File 'lib/active_mocker/loaded_mocks/features.rb', line 32

def disable(feature)
  update(feature, false)
end

#each(&block) ⇒ Object



24
25
26
# File 'lib/active_mocker/loaded_mocks/features.rb', line 24

def each(&block)
  @features.each(&block)
end

#enable(feature) ⇒ Object



28
29
30
# File 'lib/active_mocker/loaded_mocks/features.rb', line 28

def enable(feature)
  update(feature, true)
end

#resetObject



40
41
42
# File 'lib/active_mocker/loaded_mocks/features.rb', line 40

def reset
  @features = DEFAULTS.dup
end

#to_hObject



44
45
46
# File 'lib/active_mocker/loaded_mocks/features.rb', line 44

def to_h
  @features
end