forked from hotsh/rstat.us
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_helper.rb
85 lines (72 loc) · 2.04 KB
/
test_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require "minitest/autorun"
require "webmock/test_unit"
require "mocha/setup"
ENV["RAILS_ENV"] = "test"
begin
require File.expand_path('../../config/environment', __FILE__)
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = "rstatus-test"
rescue Mongo::ConnectionFailure => e
puts <<-DERPMSG
*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*
*
* Whoops! It looks like mongo isn't running on this machine.
* Please check the following:
*
* 1. Is Mongo installed? (http://www.mongodb.org/)
*
* 2. Is `mongod` running? <<<<<<<<<<<<<<<<<<<< MOST COMMON PROBLEM
*
* 3. Have you done anything custom that would warrant a change to the
* config in test/test_helper.rb? (You probably haven't)
*
*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*DERP*
DERPMSG
exit 1
end
VCR.config do |c|
c.cassette_library_dir = 'test/data/vcr_cassettes'
c.stub_with :webmock
c.ignore_localhost = true
end
Fabrication.configure do |config|
fabricator_dir = "test/fabricators"
end
module TestHelper
def setup
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.start
ApplicationController.new.set_current_view_context
end
def teardown
DatabaseCleaner.clean
end
def auth_response(username, options={})
{
"provider" => options[:provider] || "twitter",
"uid" => options[:uid] || 12345,
"info" => {
"name" => "Joe Public",
"email" => "[email protected]",
"nickname" => options[:nickname] || username,
"urls" => { "Website" => "http://rstat.us" },
"description" => "A description",
"image" => "/images/something.png"
},
"credentials" => {
"token" => options[:token] || "1234",
"secret" => options[:secret] || "4567"
}
}
end
end
# Mock Pony for mail delivery
module Pony
def self.deliveries
@deliveries ||= []
end
def self.mail(options)
deliveries << build_mail(options)
end
end