Class: Spex::ModifiedCheck

Inherits:
FileCheck show all
Defined in:
lib/spex/checks/modified_check.rb

Overview

With no option, just verifies a change occurs

Instance Attribute Summary

Attributes inherited from Check

#options, #target

Instance Method Summary collapse

Methods inherited from FileCheck

#kind, #kind_name

Methods inherited from Check

[], #active?, as, each, example, examples, #initialize, option, options, registry, #to_s, #validate!

Constructor Details

This class inherits a constructor from Spex::Check

Instance Method Details

#afterObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/spex/checks/modified_check.rb', line 28

def after
  assert File.exist?(target), "File does not exist at '#{target}'"
  checksum = current_checksum
  if active?
    assert_not_equal @before_checksum, checksum, "Checksum did not change"
    check_added_and_removed if options[:added] || options[:removed]
  else
    assert_equal @before_checksum, checksum, "Checksum changed"
  end
end

#beforeObject



24
25
26
# File 'lib/spex/checks/modified_check.rb', line 24

def before
  assert File.exist?(target), "File does not exist at '#{target}'"
end

#prepareObject



19
20
21
22
# File 'lib/spex/checks/modified_check.rb', line 19

def prepare
  track_checksum!
  track_contents! if options[:added] || options[:removed]
end