Sha256: 411a84637bc7d774c56790093fb1a2044e7af59ff1828cca213d068a64f21bdf

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'rspec'
require 'rast/parameter_generator'
require 'rast/spec_dsl'

# Main DSL. This is the entry point of the test when running a spec.
class Rast
# RSpec All scenario test
#
# Example:
#   >> Hola.hi("spanish")
#   => hola mundo
#
# Arguments:
#   language: (String)

  alias global_spec spec

  def initialize(rasted_subject, &block)
    @subject = if rasted_subject.class == Module
                 Class.new { extend rasted_subject }
               else
                 rasted_subject.new
               end

    @subject_name = rasted_subject

    spec_path = caller[2][/spec.*?\.rb/]
    yaml_path = spec_path.gsub(/(\w+).rb/, 'rast/\\1.yml')

    @generator = ParameterGenerator.new(yaml_path: yaml_path)

    instance_eval(&block)
  end

  def spec(id, &block)
    global_spec(
      subject: @subject,
      name: @subject_name,
      fixtures: @generator.generate_fixtures(spec_id: id),
      spec_id: id,
      &block
    )
  end
end

# DSL Entry Point
def rast(rasted_subject, &block)
  Rast.new(rasted_subject, &block)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rast-0.11.1 lib/rast.rb
rast-0.11.0 lib/rast.rb
rast-0.10.0 lib/rast.rb
rast-0.9.0 lib/rast.rb
rast-0.9.0.pre lib/rast.rb
rast-0.8.1.pre lib/rast.rb
rast-0.8.0.pre lib/rast.rb
rast-0.6.2.pre lib/rast.rb
rast-0.6.1.pre lib/rast.rb
rast-0.6.0.pre lib/rast.rb
rast-0.4.2.pre lib/rast.rb
rast-0.4.1.pre lib/rast.rb
rast-0.4.0.pre lib/rast.rb