Class: Uspec::Spec
- Inherits:
-
Object
- Object
- Uspec::Spec
- Defined in:
- lib/uspec/spec.rb
Instance Method Summary collapse
-
#initialize(harness, description, &block) ⇒ Spec
constructor
A new instance of Spec.
Constructor Details
#initialize(harness, description, &block) ⇒ Spec
Returns a new instance of Spec.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/uspec/spec.rb', line 6 def initialize harness, description, &block @__uspec_description = description @__uspec_block = block @__uspec_harness = harness ns = harness.define ns.instance_variables.each do |name| self.instance_variable_set( name, ns.instance_variable_get(name) ) unless name.to_s.include? '@__uspec' end ns.methods(false).each do |name| self.define_singleton_method name do |*args, &block| ns.send name, *args, &block end unless name.to_s.include? '__uspec' end if block then self.define_singleton_method :__uspec_block, &block else self.define_singleton_method :__uspec_block do raise NotImplementedError, "Uspec: No block provided for `#{@__uspec_description}`" end end end |