Class: RSpec::Hermetic::Change

Inherits:
Struct
  • Object
show all
Defined in:
lib/rspec/hermetic/change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#afterObject

Returns the value of attribute after

Returns:

  • (Object)

    the current value of after



7
8
9
# File 'lib/rspec/hermetic/change.rb', line 7

def after
  @after
end

#beforeObject

Returns the value of attribute before

Returns:

  • (Object)

    the current value of before



7
8
9
# File 'lib/rspec/hermetic/change.rb', line 7

def before
  @before
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



7
8
9
# File 'lib/rspec/hermetic/change.rb', line 7

def key
  @key
end

#probeObject

Returns the value of attribute probe

Returns:

  • (Object)

    the current value of probe



7
8
9
# File 'lib/rspec/hermetic/change.rb', line 7

def probe
  @probe
end

Instance Method Details

#addition?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rspec/hermetic/change.rb', line 8

def addition?
  before.equal?(self.class::MISSING) && !after.equal?(self.class::MISSING)
end

#append_only?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/rspec/hermetic/change.rb', line 28

def append_only?
  return true if addition?
  return false if removal?

  append_only_value?(before, after)
end

#mutation?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rspec/hermetic/change.rb', line 16

def mutation?
  !addition? && !removal?
end

#removal?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rspec/hermetic/change.rb', line 12

def removal?
  after.equal?(self.class::MISSING) && !before.equal?(self.class::MISSING)
end

#token_candidatesObject



20
21
22
23
24
25
26
# File 'lib/rspec/hermetic/change.rb', line 20

def token_candidates
  [
    probe.to_sym,
    key.to_s.tr(".[]\"$/:-", "_").gsub(/__+/, "_").downcase.to_sym,
    "#{probe}:#{key}".to_sym
  ]
end