Sha256: e67352e2250e70a862e4eff65303ddf5fc3c24f91a42d4d494753c9edc3389b0

Contents?: true

Size: 698 Bytes

Versions: 9

Compression:

Stored size: 698 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  = 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

9 entries across 9 versions & 1 rubygems

Version Path
rambo_ruby-0.7.1 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.7.0 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.6.0 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.5.0 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.4.0 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.3.3 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.3.2 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.3.1 lib/rambo/rspec/spec_file.rb
rambo_ruby-0.3.0 lib/rambo/rspec/spec_file.rb