Class: Stringup::CreatesFileAssertion

Inherits:
FileAssertion show all
Defined in:
lib/stringup/assertions/creates_file_assertion.rb

Instance Method Summary collapse

Methods inherited from FileAssertion

#initialize, #kind, #kind_name

Methods inherited from Assertion

[], assertion, each, registry

Constructor Details

This class inherits a constructor from Stringup::FileAssertion

Instance Method Details

#after(test_case) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/stringup/assertions/creates_file_assertion.rb', line 9

def after(test_case)
  test_case.assert File.exist?(@path), "File was not created at #{@path}"
  case kind
  when :file
    test_case.assert File.file?(@path), "File created at #{@path} is not a regular file"
  when :directory
    test_case.assert File.file?(@path), "File created at #{@path} is not a directory"
  end
end

#before(test_case) ⇒ Object



5
6
7
# File 'lib/stringup/assertions/creates_file_assertion.rb', line 5

def before(test_case)
  test_case.assert !File.exist?(@path), "File already exists at #{@path}"
end

#describe_should_at(event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/stringup/assertions/creates_file_assertion.rb', line 19

def describe_should_at(event)
  case event
  when :before
    "not find #{kind_name} at `#{@path}`"
  when :after
    "have created #{kind_name} at `#{@path}`"
  else
    super
  end
end