Sha256: eea457e4257cf83501d14cf49f8bc1f0ca178bcb03915fdb9623fbe6af4f4c8a

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'thor'
require 'tomatoharvest'

require 'webmock/rspec'
require 'minitest/unit'

require 'support/file_helpers'
require 'support/harvest_helpers'

WebMock.disable_net_connect!(allow_localhost: true)

RSpec.configure do |c|
  c.include MiniTest::Assertions
  c.include FileHelpers
  c.include HarvestHelpers

  #
  # Speed up the timer
  #
  c.before :each do
    const = 'TomatoHarvest::Timer::SLEEP_LENGTH'
    stub_const(const, 1/100000)
  end

  #
  # Stub HTTP requests
  #
  c.before do
    stub_harvest
  end

  #
  # Don't daemonize for tests
  # Dont notify the terminal
  #
  c.before do
    allow(Daemons).to receive(:daemonize) { false }
    allow(TerminalNotifier).to receive(:notify) { true }
    allow_any_instance_of(TomatoHarvest::Tmux).to receive(:update) { true }
  end

  # Stub Home dir 
  c.before(:each) do
    stub_const('TomatoHarvest::Config::HOME_DIR', 'spec/')
  end

  #
  # Cleanup .toma/
  #

  [
    ["TomatoHarvest::Config::GLOBAL_DIR", File.expand_path('spec/.toma/')],
    ["TomatoHarvest::Config::LOCAL_DIR",  File.expand_path('.toma/')]
  ].each do |const, path|
    c.before :each do
      stub_const(const, path)
      FileUtils.rm_rf(path) if File.directory?(path)
    end

    c.after :each do
      FileUtils.rm_rf(path) if File.directory?(path)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tomatoharvest-0.1.1 spec/helper.rb
tomatoharvest-0.1.0 spec/helper.rb