Class: CIAT::TestElement

Inherits:
Object
  • Object
show all
Includes:
IO
Defined in:
lib/ciat/test_element.rb

Constant Summary

Constants included from IO

IO::OUTPUT_FOLDER, IO::REPORT_FILENAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IO

#read_file, #write_file

Constructor Details

#initialize(name, filename, content) ⇒ TestElement

Returns a new instance of TestElement.



11
12
13
14
15
# File 'lib/ciat/test_element.rb', line 11

def initialize(name, filename, content)
  @name = name
  @filename = filename
  @content = content
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/ciat/test_element.rb', line 9

def filename
  @filename
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/ciat/test_element.rb', line 8

def name
  @name
end

Instance Method Details

#as_fileObject



36
37
38
39
40
41
# File 'lib/ciat/test_element.rb', line 36

def as_file
  if @content
    write_file(@filename, @content)
  end
  @filename
end

#contentObject



32
33
34
# File 'lib/ciat/test_element.rb', line 32

def content
  @content ||= read_file(@filename)
end

#describeObject



24
25
26
# File 'lib/ciat/test_element.rb', line 24

def describe
  yaml_entry["description"]
end

#templateObject



17
18
19
20
21
22
# File 'lib/ciat/test_element.rb', line 17

def template
  if yaml_entry.nil?
    raise "Need entry for #{name.to_s} in data/elements.yml"
  end
  File.join("elements", yaml_entry["template"])
end

#yaml_entryObject



28
29
30
# File 'lib/ciat/test_element.rb', line 28

def yaml_entry
  [name.to_s]
end