class Rambo::DocumentGenerator

Attributes

file[RW]
options[RW]
raml[RW]

Public Class Methods

generate!(file, options={}) click to toggle source
# File lib/rambo/document_generator.rb, line 12
def generate!(file, options={})
  generator = new(file, options)
  generator.generate_spec_dir!
  generator.generate_matcher_dir!
  generator.generate_examples!
  generator.generate_spec_file!
  generator.generate_rambo_helper!
  generator.generate_matchers!
end
new(file, options={}) click to toggle source
# File lib/rambo/document_generator.rb, line 23
def initialize(file, options={})
  @file    = file
  @raml    = Raml::Parser.parse_file(file)
  @options = options
end

Public Instance Methods

generate_examples!() click to toggle source
# File lib/rambo/document_generator.rb, line 33
def generate_examples!
  FileUtils.mkdir_p("spec/support/examples")
end
generate_matcher_dir!() click to toggle source
# File lib/rambo/document_generator.rb, line 52
def generate_matcher_dir!
  FileUtils.mkdir_p("spec/support/matchers")
end
generate_matchers!() click to toggle source
# File lib/rambo/document_generator.rb, line 56
def generate_matchers!
  Rambo::RSpec::HelperFile.new(
    template_path: File.expand_path("../rspec/templates/matcher_file_template.erb", __FILE__),
    file_path: "spec/support/matchers/rambo_matchers.rb", raml: nil
  ).generate
end
generate_rambo_helper!() click to toggle source
# File lib/rambo/document_generator.rb, line 43
def generate_rambo_helper!
  Rambo::RSpec::HelperFile.new(
    template_path: File.expand_path("../rspec/templates/rambo_helper_file_template.erb", __FILE__),
    file_path:     "spec/rambo_helper.rb",
    raml:          raml,
    options:       options
  ).generate
end
generate_spec_dir!() click to toggle source
# File lib/rambo/document_generator.rb, line 29
def generate_spec_dir!
  FileUtils.mkdir_p("spec/contract/output")
end
generate_spec_file!() click to toggle source
# File lib/rambo/document_generator.rb, line 37
def generate_spec_file!
  spec_file_name = file.match(/[^\/]*\.raml$/).to_s.gsub(/\.raml$/, "_spec.rb")
  contents       = Rambo::RSpec::SpecFile.new(raml, options).render
  File.write("spec/contract/#{spec_file_name}", contents)
end