Class: Rambo::RSpec::HelperFile
- Inherits:
-
Object
- Object
- Rambo::RSpec::HelperFile
- Defined in:
- lib/rambo/rspec/helper_file.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #app_classes ⇒ Object
- #generate ⇒ Object
-
#initialize(template_path:, file_path:, raml: nil, options: nil) ⇒ HelperFile
constructor
A new instance of HelperFile.
- #render ⇒ Object
Constructor Details
#initialize(template_path:, file_path:, raml: nil, options: nil) ⇒ HelperFile
Returns a new instance of HelperFile.
11 12 13 14 15 16 |
# File 'lib/rambo/rspec/helper_file.rb', line 11 def initialize(template_path:, file_path:, raml: nil, options: nil) @template_path = template_path @file_path = file_path = || { framework: :rails } @raml = raml ? Rambo::RamlModels::Api.new(raml) : nil end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/rambo/rspec/helper_file.rb', line 9 def end |
Instance Method Details
#app_classes ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/rambo/rspec/helper_file.rb', line 18 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" } end |
#generate ⇒ Object
27 28 29 |
# File 'lib/rambo/rspec/helper_file.rb', line 27 def generate write_to_file(render) unless file_already_exists? end |
#render ⇒ Object
31 32 33 34 35 |
# File 'lib/rambo/rspec/helper_file.rb', line 31 def render b = binding ERB.new(template, 0, "-", "@result").result(raml.instance_eval { b }) @result end |