Sha256: d5c148c6f8075c03e5d738d8defeb864edc0b66c510999504211c4626751dcaa

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

begin
  require 'spec'
rescue LoadError
  require 'rubygems' unless ENV['NO_RUBYGEMS']
  gem 'rspec'
  require 'spec'
end

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'rubygems'
require 'ohm'
require 'redis'
require 'tweetable'
require 'fakeweb'

FakeWeb.allow_net_connect = false

def twitter_url(path, login=nil, password=nil)
  if path =~ /^http/
    path
  else
    login || pass ? "http://#{login}:#{password}@api.twitter.com#{path}" : path
  end    
end

def fixture_file(filename)
  return '' if filename == ''
  file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
  File.read(file_path)
end

def stub_get(url, filename, options = {})
  fwoptions = {:body => fixture_file(filename)}
  fwoptions.merge!({:status => options[:status]}) unless options[:status].nil?
  FakeWeb.register_uri(:get, twitter_url(url, options[:login], options[:password]), fwoptions)
end

def stub_post(url, filename)
  FakeWeb.register_uri(:post, twitter_url(url), :body => fixture_file(filename))
end

def stub_put(url, filename)
  FakeWeb.register_uri(:put, twitter_url(url), :body => fixture_file(filename))
end


class RedisSpecHelper
  TEST_OPTIONS = {:db => 11}
  
  def self.reset    
    Ohm.connect(TEST_OPTIONS)
    Ohm.flush
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tweetable-0.1.13 spec/spec_helper.rb
tweetable-0.1.11 spec/spec_helper.rb
tweetable-0.1.10 spec/spec_helper.rb