Sha256: aac4ebae07a1c6e749fec7730b8a454a1201af8483dfca843d712b7787083fcf

Contents?: true

Size: 1.7 KB

Versions: 5

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

def valid_user_cache_data
  {123 => {"name" => "foo"}, 456 => {"name" => "bar"}, 'me' => {"name" => "bot", "id" => 789}}
end

# Fetching data about users

def stub_user_data_request(user_id, response_code = 200)
  body = response_code == 200 ? Yajl::Encoder.encode(:user => valid_user_cache_data[user_id]) : ""
  stub_request(:get, "https://#{valid_params[:subdomain]}.campfirenow.com/users/#{user_id}.json").
    with(:headers => {'Authorization'=>['6124d98749365e3db2c9e5b27ca04db6', 'X'], 'Content-Type'=>'application/json'}).
    to_return(:status => response_code, :body => body, :headers => {:ETag => etag_for_data(valid_user_cache_data[user_id])})
end

def stub_timeout_user_data_request(user_id)
  stub_request(:get, "https://#{valid_params[:subdomain]}.campfirenow.com/users/#{user_id}.json").
    with(:headers => {'Authorization'=>['6124d98749365e3db2c9e5b27ca04db6', 'X'], 'Content-Type'=>'application/json'}).
    to_timeout
end

# Fetching data about self

def stub_self_data_request(response_code = 200)
  body = response_code == 200 ? Yajl::Encoder.encode(:user => valid_user_cache_data['me']) : ""
  stub_request(:get, "https://#{valid_params[:subdomain]}.campfirenow.com/users/me.json").
    with(:headers => {'Authorization'=>['6124d98749365e3db2c9e5b27ca04db6', 'X'], 'Content-Type'=>'application/json'}).
    to_return(:status => response_code, :body => body, :headers => {:ETag => etag_for_data(valid_user_cache_data['me'])})
end

def stub_timeout_self_data_request
  stub_request(:get, "https://#{valid_params[:subdomain]}.campfirenow.com/users/me.json").
    with(:headers => {'Authorization'=>['6124d98749365e3db2c9e5b27ca04db6', 'X'], 'Content-Type'=>'application/json'}).
    to_timeout
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
em-campfire-1.1.3 spec/users_helper.rb
em-campfire-1.1.2 spec/users_helper.rb
em-campfire-1.1.1 spec/users_helper.rb
em-campfire-1.1.0 spec/users_helper.rb
em-campfire-1.0.0 spec/users_helper.rb