Class: Spex::ChangedGroupCheck

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

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, #prepare, registry, #to_s, #validate!

Constructor Details

This class inherits a constructor from Spex::Check

Instance Method Details

#afterObject



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

def after
  assert File.exist?(target), "File does not exist at #{target}"
  current = current_groupname
  if to_groupname
    assert_equal to_groupname, current
  elsif active?
    assert_not_equal @before_groupname, current, "Group is still '#{@before_groupname}'"
  elsif !active?
    assert_equal @before_groupname, current, "Group changed from '#{@before_groupname}' to '#{current}'"
  end
end

#beforeObject



16
17
18
19
20
21
22
23
24
# File 'lib/spex/checks/changed_group_check.rb', line 16

def before
  assert File.exist?(target), "File does not exist at #{target}"
  if from_groupname
    assert_equal from_groupname, current_groupname
  elsif active?
    assert_not_equal to_groupname, current_groupname, "Group will not be changed; already '#{to_groupname}'"
  end
  @before_groupname = current_groupname
end