/
configuration_spec.rb
156 lines (139 loc) · 4.81 KB
/
configuration_spec.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
require 'spec_helper'
RSpec.describe Quke::Configuration do
describe '#features_folder' do
context 'when specified NOT specified in config file' do
it "defaults to 'features'" do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.features_folder).to eq('features')
end
end
context 'when specified in config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.features_folder).to eq('spec')
end
end
end
describe '#app_host' do
context 'when NOT specified in the config file' do
it "defaults to ''" do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.app_host).to eq('')
end
end
context 'when specified in config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.app_host).to eq('http://localhost:4567')
end
end
end
describe '#driver' do
context 'when NOT specified in the config file' do
it "defaults to 'phantomjs'" do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.driver).to eq('phantomjs')
end
end
context 'when specified in the config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.driver).to eq('chrome')
end
end
end
describe '#pause' do
context 'when NOT specified in the config file' do
it 'defaults to 0' do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.pause).to eq(0)
end
end
context 'when specified in config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.pause).to eq(1)
end
end
context 'when in the config file as a string' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.as_string.yml')
expect(subject.pause).to eq(1)
end
end
end
describe '#stop_on_error' do
context 'when NOT specified in the config file' do
it 'defaults to false' do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.stop_on_error).to eq(false)
end
end
context 'when specified in config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.stop_on_error).to eq(true)
end
end
context 'when in the config file as a string' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.as_string.yml')
expect(subject.stop_on_error).to eq(true)
end
end
end
describe '#browserstack' do
context 'when NOT specified in the config file' do
it 'defaults to a blank username and auth_key' do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.browserstack).to eq('username' => '', 'auth_key' => '')
end
end
context 'when specified in the config file' do
it 'matches the config file' do
Quke::Configuration.file_location = data_path('.simple.yml')
expect(subject.browserstack).to eq(
'username' => 'jdoe',
'auth_key' => '123456789ABCDE',
'build' => 'Version 1',
'project' => 'Adding browserstack support'
)
end
end
end
describe '#poltergeist_options' do
context 'when NOT specified in the config file' do
it 'defaults to a blank username and auth_key' do
Quke::Configuration.file_location = data_path('.no_file.yml')
expect(subject.poltergeist_options).to eq(
js_errors: true,
timeout: 30,
debug: false,
phantomjs_options: [
'--load-images=no',
'--disk-cache=false',
'--ignore-ssl-errors=yes'
],
inspector: true
)
end
end
end
describe '#to_s' do
it 'return the values held by the instance and not an instance ID' do
Quke::Configuration.file_location = data_path('.no_file.yml')
# rubocop:disable Style/StringLiterals
expect(subject.to_s).to eq(
"{\"features_folder\"=>\"features\", \"app_host\"=>\"\", \"driver\"=>\"phantomjs\", \"pause\"=>0, \"stop_on_error\"=>\"false\", \"browserstack\"=>{\"username\"=>\"\", \"auth_key\"=>\"\"}}"
)
# rubocop:enable Style/StringLiterals
end
end
describe '.file_name' do
context 'environment variable not set' do
it "returns the default value '.config.yml'" do
expect(Quke::Configuration.file_name).to eq('.config.yml')
end
end
end
end