Sha256: 581761862ddbf27b1a54a5bd84d8e5aa5abc5d61803e70696378526bf6e5afb9

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 Bytes

Contents

require 'erb'
require 'raml'

require "rambo/rspec/examples"
require "rambo/raml_models"

module Rambo
  module RSpec
    class SpecFile
      attr_reader :raml, :examples, :options

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

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rambo_ruby-0.2.3 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.2.2 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.2.1 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.2.0 lib/rambo/rspec/spec_file.rb