Class: Prospectus::Item
- Inherits:
-
Object
- Object
- Prospectus::Item
- Defined in:
- lib/prospectus/item.rb
Overview
Define item objects that defined expected vs actual state
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #actual ⇒ Object
- #expected ⇒ Object
-
#initialize(params = {}) ⇒ Item
constructor
A new instance of Item.
- #name ⇒ Object
- #noop ⇒ Object
- #prefix(value) ⇒ Object
- #to_json(_ = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
7 8 9 |
# File 'lib/prospectus/item.rb', line 7 def list @list end |
Instance Method Details
#actual ⇒ Object
35 36 37 |
# File 'lib/prospectus/item.rb', line 35 def actual @actual || raise("No actual state was loaded for #{name}") end |
#expected ⇒ Object
31 32 33 |
# File 'lib/prospectus/item.rb', line 31 def expected @expected || raise("No expected state was loaded for #{name}") end |
#name ⇒ Object
14 15 16 17 18 19 |
# File 'lib/prospectus/item.rb', line 14 def name return @name if @name @name = File.basename Dir.pwd @name << "::#{File.basename @options[:file]}" if @options[:suffix_file] @name end |
#noop ⇒ Object
26 27 28 29 |
# File 'lib/prospectus/item.rb', line 26 def noop @expected = 'noop' @actual = 'noop' end |
#prefix(value) ⇒ Object
21 22 23 24 |
# File 'lib/prospectus/item.rb', line 21 def prefix(value) raise('Name not set for sub-item') unless @name @name = value + '::' + @name end |
#to_json(_ = {}) ⇒ Object
39 40 41 |
# File 'lib/prospectus/item.rb', line 39 def to_json(_ = {}) { name: name, expected: expected, actual: actual }.to_json end |