Class: CSpec::Spec
- Inherits:
-
Object
- Object
- CSpec::Spec
- Defined in:
- lib/cspec/spec.rb
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#initialization_args ⇒ Object
readonly
Returns the value of attribute initialization_args.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#method_args ⇒ Object
readonly
Returns the value of attribute method_args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #error ⇒ Object
-
#initialize(hash) ⇒ Spec
constructor
A new instance of Spec.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Spec
Returns a new instance of Spec.
13 14 15 16 17 18 19 20 21 |
# File 'lib/cspec/spec.rb', line 13 def initialize(hash) @class = hash['class'] @name = hash['name'] @type = hash['type'] @method = hash['method'] @method_args = ::CSpec::DataType.convert_all(hash['method_args']) @initialization_args = ::CSpec::DataType.convert_all(hash['initialization_args']) @expected = hash['expected'] end |
Instance Attribute Details
#class ⇒ Object (readonly)
Returns the value of attribute class.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def class @class end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def expected @expected end |
#initialization_args ⇒ Object (readonly)
Returns the value of attribute initialization_args.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def initialization_args @initialization_args end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def method @method end |
#method_args ⇒ Object (readonly)
Returns the value of attribute method_args.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def method_args @method_args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/cspec/spec.rb', line 5 def type @type end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/cspec/spec.rb', line 23 def ==(other) name == other&.name && self.class == other&.class && method == other&.method && type == other&.type && method_args == other&.method_args && initialization_args == other&.initialization_args end |
#error ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/cspec/spec.rb', line 32 def error return ["#{self.class} does not exist"] unless Object.const_defined?(self.class) errors = [] errors += send("#{type}_errors") errors.size.positive? ? errors.flatten : nil end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/cspec/spec.rb', line 42 def to_s "name: #{name}, class: #{self.class}, method: #{method}, method_args: #{method_args}" end |