-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathspec_helper.rb
113 lines (94 loc) · 3.3 KB
/
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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
ENV['RSPEC_ENV'] = 'test'
require 'simplecov'
# for simplecov to work correctly, it has to be started before any other code
unless RUBY_PLATFORM =~ /java/
SimpleCov.start do
add_filter 'spec/'
add_group 'Middleware', 'lib/gooddata/bricks/middleware'
add_group 'CLI', 'lib/gooddata/cli'
add_group 'Commands', 'lib/gooddata/commands'
add_group 'Core', 'lib/gooddata/core'
add_group 'Exceptions', 'lib/gooddata/exceptions'
add_group 'Extensions', 'lib/gooddata/extensions'
add_group 'Goodzilla', 'lib/gooddata/goodzilla'
add_group 'Models', 'lib/gooddata/models'
add_group 'LCM', 'lib/gooddata/lcm'
end
end
require 'rspec'
require 'pathname'
require 'gooddata'
require 'vcr_configurer'
require_relative 'double_with_class'
GoodData.logging_off unless ENV['GD_SPEC_LOG'] == 'true'
# Automagically include all helpers/*_helper.rb
require_relative 'environment/environment'
base = Pathname(__FILE__).dirname.expand_path
Dir.glob(base + 'helpers/*_helper.rb').each do |file|
require file
end
GoodData::Environment.load
RSpec::Expectations.configuration.warn_about_potential_false_positives = false
RSpec.configure do |config|
config.deprecation_stream = File.open('deprecations.txt', 'w') if File.world_writable?('deprecations.txt')
config.filter_run_excluding :broken => true
config.fail_fast = false
if GoodData::Environment::VCR_ON
GoodData::Helpers::VcrConfigurer.setup
skip_sleep = GoodData::Helpers::VcrConfigurer.vcr_record_mode == :none
config.before(:all) do
# in case the test uses VCR
if self.class.metadata[:vcr]
# replace parallel iterations with the serial one, since VCR can't handle parallel request matching correctly
module Enumerable
def peach_with_index(*, &y)
each_with_index(&y)
end
end
# Insert cassette for before(:all) and after(:all) blocks.
# vcr_all_cassette specifies the cassette name. Unique name is needed
# for multiple all blocks so that they don't overwrite each other).
VCR.insert_cassette("#{self.class.metadata[:description]}/#{self.class.metadata[:vcr_all_cassette] || 'all'}")
if skip_sleep
# avoid polling idle time by overriding sleep
module Kernel
alias :old_sleep :sleep
def sleep(n)
n
end
end
end
end
end
config.after(:all) do
# in case the test uses VCR
if self.class.metadata[:vcr]
# eject the cassete recording everything what happens outside the tests cases
VCR.eject_cassette
# reload the original parallel iterations
load('pmap.rb')
if skip_sleep
# reload sleep method
module Kernel
alias :sleep :old_sleep
end
end
end
end
end
include GoodData::Helpers
config.include BlueprintHelper
config.include CliHelper
config.include ConnectionHelper
config.include CryptoHelper
config.include CsvHelper
config.include ProcessHelper
config.include ProjectHelper
config.include ScheduleHelper
end