Sha256: 226733320d1f4d84187cc0a72274b1bd4f6649f5947011f7bd090d27515d3aef

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

require 'rspec-system'
require 'yaml'
require 'pp'
require 'tempfile'

RSpec.configure do |c|
  include RSpecSystem::Log

  def nodeset
    Pathname.new(File.join(File.basename(__FILE__), '..', '.nodeset.yml'))
  end

  def rspec_system_config
    YAML.load_file('.nodeset.yml')
  end

  # Grab the type of virtual environment we wish to run these tests in
  def rspec_virtual_env
    ENV["RSPEC_VIRTUAL_ENV"] || 'vagrant'
  end

  def rspec_system_node_set
    setname = ENV['RSPEC_SET'] || rspec_system_config['default_set']
    config = rspec_system_config['sets'][setname]
    RSpecSystem::NodeSet.create(setname, config, rspec_virtual_env)
  end

  def start_nodes
    ns = rspec_system_node_set

    log.info "START RSPEC-SYSTEM SETUP"
    log.info "Setname is: " + ns.setname
    log.info "Configuration is: " + ns.config.pretty_inspect
    log.info "Virtual Environment type is: #{ns.env_type}"
    log.info "Default node is: #{ns.default_node.name}"

    ns.setup
  end

  def stop_nodes
    log.info 'FINALIZE RSPEC-SYSTEM SETUP'
    rspec_system_node_set.teardown
  end

  def call_custom_setup_block
    # Run test specific setup routines
    if pr = RSpec.configuration.system_setup_block then
      log.info "Running custom setup block"
      pr.call
      log.info "Finished running custom setup block"
    end
  end

  # Default the system_tmp dir to something random
  c.system_tmp = Dir.tmpdir

  c.before :suite do
    start_nodes
    call_custom_setup_block
  end

  c.after :suite do
    stop_nodes
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-system-0.1.3 lib/rspec-system/spec_helper.rb
rspec-system-0.1.2 lib/rspec-system/spec_helper.rb
rspec-system-0.1.1 lib/rspec-system/spec_helper.rb
rspec-system-0.1.0 lib/rspec-system/spec_helper.rb