Sha256: ae864cbbd802c25d128b90f4bca4b4259f2dad31e024f8a54050b30cf7f9c8f9

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'yaml'
require 'rspec'
require 'vcr'
require 'squall'

VCR.config do |c|
  c.cassette_library_dir = 'spec/vcr_cassettes'
  c.stub_with :fakeweb
  c.default_cassette_options = {:record => :new_episodes}
end

RSpec.configure do |c|
  c.extend VCR::RSpec::Macros
  c.after(:each) do
    Squall.reset_config
  end
end

def default_config
  yaml = File.join(ENV['HOME'], '.squall.yml')
  if ENV['SQUALL_LIVE'] && File.exists?(yaml)
    config = YAML::load_file(yaml)
    uri  = config['base_uri']
    user = config['username']
    pass = config['password']
  else
    uri  = 'http://www.example.com'
    user = 'user'
    pass = 'pass'
  end
  Squall.config do |c|
    c.base_uri uri
    c.username user
    c.password pass
  end
end

def requires_attr(attr, &block)
  expect { block.call }.to raise_error(ArgumentError, /Missing required params: #{attr}/i)
end

def mock_request(meth, path, options = {})
  config = Squall.config
  uri    = URI.parse(Squall.config[:base_uri])
  url    = "#{uri.scheme}://#{config[:username]}:#{config[:password]}@#{uri.host}:#{uri.port}#{path}"
  FakeWeb.register_uri(meth, url, {:content_type => 'application/json'}.merge(options))
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squall-1.0.2 spec/spec_helper.rb
squall-1.0.1 spec/spec_helper.rb
squall-1.0.0 spec/spec_helper.rb