Class: Vigia::Sail::RSpecObject
- Inherits:
-
Object
- Object
- Vigia::Sail::RSpecObject
- Includes:
- Hooks
- Defined in:
- lib/vigia/sail/rspec_object.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rspec ⇒ Object
readonly
Returns the value of attribute rspec.
Class Method Summary collapse
- .clean! ⇒ Object
- .inherited(subclass) ⇒ Object
- .register(name, options) ⇒ Object
- .setup_and_run(name, rspec) ⇒ Object
Instance Method Summary collapse
- #contextual_object(option_name: nil, object: nil, context: nil) ⇒ Object
-
#initialize(name, options, rspec) ⇒ RSpecObject
constructor
A new instance of RSpecObject.
Methods included from Hooks
#execute_hook, #hooks_for_object, #with_hooks
Constructor Details
#initialize(name, options, rspec) ⇒ RSpecObject
Returns a new instance of RSpecObject.
33 34 35 36 37 38 |
# File 'lib/vigia/sail/rspec_object.rb', line 33 def initialize(name, , rspec) @name = name @options = @rspec = rspec end |
Class Attribute Details
.collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/vigia/sail/rspec_object.rb', line 5 def collection @collection end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/vigia/sail/rspec_object.rb', line 31 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/vigia/sail/rspec_object.rb', line 31 def @options end |
#rspec ⇒ Object (readonly)
Returns the value of attribute rspec.
31 32 33 |
# File 'lib/vigia/sail/rspec_object.rb', line 31 def rspec @rspec end |
Class Method Details
.clean! ⇒ Object
20 21 22 |
# File 'lib/vigia/sail/rspec_object.rb', line 20 def clean! @collection = {} end |
.inherited(subclass) ⇒ Object
24 25 26 |
# File 'lib/vigia/sail/rspec_object.rb', line 24 def inherited(subclass) subclass.instance_variable_set('@collection', {}) end |
.register(name, options) ⇒ Object
7 8 9 10 |
# File 'lib/vigia/sail/rspec_object.rb', line 7 def register(name, ) @collection = {} if collection.nil? @collection.merge!(name => ) end |
.setup_and_run(name, rspec) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/vigia/sail/rspec_object.rb', line 12 def setup_and_run(name, rspec) items = collection.select{ |k,v| k == name } raise "Cannot find #{ self.name } with name #{ name }" if items.empty? name, = items.first instance = new(name, , rspec) instance.run end |
Instance Method Details
#contextual_object(option_name: nil, object: nil, context: nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vigia/sail/rspec_object.rb', line 40 def contextual_object(option_name: nil, object: nil, context: nil) context ||= rspec.described_class object ||= [option_name] case object when Symbol context.adapter.send(object) when Proc context.instance_exec(&object) else object end end |