module Rambo

Constants

MAJOR
MINOR
PATCH

Attributes

file[R]
options[R]

Public Class Methods

generate_contract_tests!(file: nil, options: {}) click to toggle source
# File lib/rambo.rb, line 10
def generate_contract_tests!(file: nil, options: {})
  @options             = yaml_options.merge(options)
  @options[:framework] = :rails if @options.fetch(:framework, nil).nil?
  @file                = file || @options.delete(:raml) || raml_file

  DocumentGenerator.generate!(@file, @options)
end
version() click to toggle source
# File lib/version.rb, line 6
def self.version
  [Rambo::MAJOR, Rambo::MINOR, Rambo::PATCH].join('.')
end

Private Class Methods

raml_file() click to toggle source

TODO: Permit use of multiple RAML files, since right now this only takes

the first one it finds in the "doc" directory.
# File lib/rambo.rb, line 37
def raml_file
  return options.fetch(:raml) if options && options.fetch(:raml, nil)

  raml_path = File.join(FileUtils.pwd, "doc", "raml")
  Dir.foreach(raml_path) {|file| return File.join(raml_path, file) if file.match(/\.raml$/) }
end
yaml_options() click to toggle source
# File lib/rambo.rb, line 20
def yaml_options
  opts = YAML.load(File.read(File.join(FileUtils.pwd, ".rambo.yml"))).symbolize_keys

  opts[:framework] = opts[:framework].to_sym if opts[:framework]

  if opts && opts.fetch(:raml, nil)
    opts[:raml] = File.join(FileUtils.pwd, opts.fetch(:raml))
  end

  opts || {}
rescue
  { framework: :rails }
end