Class: Capsium::Package::Testing::FileTest

Inherits:
TestCase
  • Object
show all
Defined in:
lib/capsium/package/testing/file_test.rb,
sig/capsium/package/testing/file_test.rbs

Overview

A "file" test (05x-testing): the file must exist in the package; optionally its content must contain a string.

Instance Attribute Summary collapse

Attributes inherited from TestCase

#name

Instance Method Summary collapse

Methods inherited from TestCase

build, from_h, register, types

Constructor Details

#initialize(name:, path:, contains: nil) ⇒ FileTest

Returns a new instance of FileTest.



11
12
13
14
15
# File 'lib/capsium/package/testing/file_test.rb', line 11

def initialize(name:, path:, contains: nil)
  super(name: name)
  @path = path
  @contains = contains
end

Instance Attribute Details

#containsString? (readonly)

Returns the value of attribute contains.

Returns:

  • (String, nil)


9
10
11
# File 'lib/capsium/package/testing/file_test.rb', line 9

def contains
  @contains
end

#pathString (readonly)

Returns the value of attribute path.

Returns:

  • (String)


9
10
11
# File 'lib/capsium/package/testing/file_test.rb', line 9

def path
  @path
end

Instance Method Details

#run(context) ⇒ TestCase::Result

Parameters:

Returns:



17
18
19
20
# File 'lib/capsium/package/testing/file_test.rb', line 17

def run(context)
  problems = existence_problems(context) + contains_problems(context)
  Result.new(name: name, ok: problems.empty?, messages: problems)
end