-
Notifications
You must be signed in to change notification settings - Fork 2
/
spec_helper.rb
43 lines (33 loc) · 978 Bytes
/
spec_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
require 'simplecov'
require 'simplecov-rcov'
require 'rspec'
lib = File.expand_path('../lib', File.dirname(__FILE__))
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cert-protector'
DUMMY_PATH = File.join(File.expand_path(File.dirname(__FILE__)), 'dummy')
ENV['RACK_ENV'] = 'test'
module RSpecMixin
include Rack::Test::Methods
def app() Sinatra::Application end
end
RSpec.configure do |config|
# Disable old "should" syntax. Force all specs to use
# the new "expect" syntax.
config.expect_with(:rspec) {|c| c.syntax = :expect}
config.mock_with(:rspec) {|c| c.syntax = :expect}
config.after(:all) do
FileUtils.rm_rf(DUMMY_PATH)
end
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").string
ensure
eval("$#{stream} = #{stream.upcase}")
end
result
end
end
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter