Sha256: ca5484dc2e1cea468efa519ce18f0bbc5e0b705c7398aff97d64550a5d002e33
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require "erb" require "raml" require "rambo/raml_models" require "rambo/rspec/examples" module Rambo module RSpec class HelperFile attr_reader :options def initialize(template_path:, file_path:, raml: nil, options: nil) @template_path = template_path @file_path = file_path @options = options || { framework: :rails } @raml = raml ? Rambo::RamlModels::Api.new(raml) : nil end def app_classes { :rails => "Rails.application", :"sinatra:classic" => "Sinatra::Application", :"sinatra:modular" => "Sinatra::Base.descendants.find {|klass| klass != Sinatra::Application } || Sinatra::Application", :grape => "Grape::API.descendants.first", :rory => "Rory.application" } end def generate write_to_file(render) unless file_already_exists? end def render b = binding ERB.new(template, 0, "-", "@result").result(raml.instance_eval { b }) @result end private attr_reader :template_path, :file_path, :raml def file_already_exists? File.exist?(file_path) end def write_to_file(template) File.write(file_path, template) end def template @template ||= File.read(template_path) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rambo_ruby-0.7.1 | lib/rambo/rspec/helper_file.rb |
rambo_ruby-0.7.0 | lib/rambo/rspec/helper_file.rb |