Sha256: bc4a7e2d7e968dca78401dc256a9e3486f196322561da063b428ca6b9b7ac02d

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

# coding: utf-8

begin
  require 'cover_me'
rescue LoadError
  # ignore, only for development, it’s in the Gemfile
end

require 'mockspotify'
require 'hallon'

# Bail on failure
Thread.abort_on_exception = true

RSpec.configure do |config|
  config.treat_symbols_as_metadata_keys_with_true_values = true

  config.before do
    Hallon::Session.stub(:instance?).and_return(true)
  end

  def fixture_image_path
    File.expand_path('../fixtures/pink_cover.jpg', __FILE__)
  end

  def create_session(valid_appkey = true, options = options)
    appkey = valid_appkey ? 'appkey_good' : 'appkey_bad'
    Hallon::Session.send(:new, appkey, options)
  end

  def instantiate(klass, *pointers)
    pointers.map { |x| klass.new(*x) }
  end

  def mock_session(times = 1)
    Hallon::Session.should_receive(:instance).at_least(times).times.and_return(session)
    yield
  end

  def stub_session(target = nil)
    if target
      target.stub(:session).and_return(session)
    else
      Hallon::Session.stub(:instance).and_return(session)
    end

    target.tap { yield if block_given? }
  end

  def pointer_array_with(*args)
    ary = FFI::MemoryPointer.new(:pointer, args.size)
    ary.write_array_of_pointer args
    def ary.length
      size / type_size
    end

    ary
  end
end

RSpec::Core::ExampleGroup.instance_eval do
  let(:options) do
    {
      :user_agent => "Hallon (rspec)",
      :settings_path => "tmp",
      :cache_path => ""
    }
  end

  let(:session) { create_session }
end

# Requires supporting files in ./support/ and ./fixtures/
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
Dir["#{File.dirname(__FILE__)}/fixtures/**/*.rb"].each {|f| require f}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hallon-0.13.0 spec/spec_helper.rb