Sha256: 712dee25195e0407edc360233f1f3cbd623d24ee96ddbd22e65b6e14b4b1d742

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

SPEC_FOLDER = File.dirname(__FILE__)
require 'yogi_berra'
require 'rspec/mocks'

def build_exception
  raise Exception
rescue Exception => caught_exception
  caught_exception
end

def build_session
  { "access" =>
    { "user_id" => 30785,
      "id" => 605,
      "password" => "[FILTERED]",
      "auth_key" => "Baseball is ninety percent mental and the other half is physical."
    }
  }
end

def mock_mongo(opts)
  mongo_client = double('mongo client')
  mongo_connection = double('mongo connection')

  if opts[:mongo_client_stub]
    Mongo::MongoClient.should_receive(:new).at_least(1).times { mongo_client }
    mongo_client.should_receive(:[]).at_least(1).times { mongo_connection }
  end

  if opts[:authenticate_stub] == :error
    mongo_connection.should_receive(:authenticate).at_least(1).times.and_raise
  else
    mongo_connection.should_receive(:authenticate).at_least(1).times
  end

  if opts[:connection_stub]
    mongo_connection.should_receive(:[]).at_least(1).times { mongo_connection }
    mongo_connection.should_receive(:insert).at_least(1).times
  end
end

def mock_yogi_fork_database
  client = YogiBerra::Catcher.fork_database.join
  YogiBerra::Catcher.should_receive(:fork_database).at_least(1).times { client }
end

def reset_if_rails
  if defined?(Rails)
    Object.send(:remove_const, :Rails)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yogi_berra-0.1.7 spec/spec_helper.rb
yogi_berra-0.1.6 spec/spec_helper.rb
yogi_berra-0.1.4 spec/spec_helper.rb
yogi_berra-0.1.3 spec/spec_helper.rb