Class: RhoSpecModule

Inherits:
Object show all
Defined in:
lib/extensions/rhospec/rhospec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec_name, spec_body) ⇒ RhoSpecModule

Returns a new instance of RhoSpecModule.



21
22
23
24
25
26
27
28
29
30
# File 'lib/extensions/rhospec/rhospec.rb', line 21

def initialize(spec_name, spec_body)
    @before = {}
    @after = {}
    @tests = {}
    
    @env = Object.new
    
    @spec_name = spec_name
    @spec_body = spec_body
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



19
20
21
# File 'lib/extensions/rhospec/rhospec.rb', line 19

def after
  @after
end

#beforeObject

Returns the value of attribute before.



19
20
21
# File 'lib/extensions/rhospec/rhospec.rb', line 19

def before
  @before
end

#spec_nameObject

Returns the value of attribute spec_name.



19
20
21
# File 'lib/extensions/rhospec/rhospec.rb', line 19

def spec_name
  @spec_name
end

#testsObject

Returns the value of attribute tests.



19
20
21
# File 'lib/extensions/rhospec/rhospec.rb', line 19

def tests
  @tests
end

Instance Method Details

#run_specObject



32
33
34
35
36
37
# File 'lib/extensions/rhospec/rhospec.rb', line 32

def run_spec
    setting_str = $spec_settings.length()>0  ? ";#{$spec_settings}" : ""
    puts "TEST: #{@spec_name}" + setting_str

    @env.instance_eval(&@spec_body) if @spec_body
end

#run_test(test_body) ⇒ Object



39
40
41
# File 'lib/extensions/rhospec/rhospec.rb', line 39

def run_test(test_body)
    @env.instance_eval(&test_body) if test_body
end