Class: Rambo::RSpec::SpecFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rambo/rspec/spec_file.rb

Constant Summary collapse

TEMPLATE_PATH =
File.expand_path('../templates/spec_file_template.erb', __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raml, options = {}) ⇒ SpecFile



14
15
16
17
18
# File 'lib/rambo/rspec/spec_file.rb', line 14

def initialize(raml, options={})
  @raml     = Rambo::RamlModels::Api.new(raml)
  @options  = options
  @examples = Examples.new(@raml, @options)
end

Instance Attribute Details

#examplesObject (readonly)

Returns the value of attribute examples.



10
11
12
# File 'lib/rambo/rspec/spec_file.rb', line 10

def examples
  @examples
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/rambo/rspec/spec_file.rb', line 10

def options
  @options
end

#ramlObject (readonly)

Returns the value of attribute raml.



10
11
12
# File 'lib/rambo/rspec/spec_file.rb', line 10

def raml
  @raml
end

Instance Method Details

#renderObject



24
25
26
27
28
# File 'lib/rambo/rspec/spec_file.rb', line 24

def render
  b = binding
  ERB.new(template, 0, "-", "@result").result(raml.instance_eval { b })
  @result
end

#templateObject



20
21
22
# File 'lib/rambo/rspec/spec_file.rb', line 20

def template
  @template ||= File.read(TEMPLATE_PATH)
end