Class: Spectre::Subject
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#specs ⇒ Object
readonly
Returns the value of attribute specs.
Instance Method Summary collapse
- #add_spec(desc, tags, data, block, context, file, line) ⇒ Object
-
#initialize(desc) ⇒ Subject
constructor
A new instance of Subject.
- #to_h ⇒ Object
Constructor Details
#initialize(desc) ⇒ Subject
Returns a new instance of Subject.
81 82 83 84 85 |
# File 'lib/spectre.rb', line 81 def initialize desc @desc = desc @specs = [] @name = desc.downcase.gsub(/[^a-z0-9]+/, '_') end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
79 80 81 |
# File 'lib/spectre.rb', line 79 def desc @desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
79 80 81 |
# File 'lib/spectre.rb', line 79 def name @name end |
#specs ⇒ Object (readonly)
Returns the value of attribute specs.
79 80 81 |
# File 'lib/spectre.rb', line 79 def specs @specs end |
Instance Method Details
#add_spec(desc, tags, data, block, context, file, line) ⇒ Object
87 88 89 90 |
# File 'lib/spectre.rb', line 87 def add_spec desc, , data, block, context, file, line name = @name + '-' + (@specs.length+1).to_s @specs << Spec.new(name, self, desc, , data, block, context, file, line) end |
#to_h ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/spectre.rb', line 92 def to_h { name: @name, desc: @desc, specs: @specs.map { |x| x.to_h }, } end |