lookout-rack-test 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +4 -0
- data/cucumber.yml +5 -0
- data/examples/test_app.rb +62 -0
- data/examples/test_models.rb +15 -0
- data/features/general_steps/requests.feature +13 -0
- data/features/general_steps/requests_with_json_body.feature +15 -0
- data/features/general_steps/requests_with_params.feature +27 -0
- data/features/general_steps/response.feature +21 -0
- data/features/liquid_templates.feature +44 -0
- data/features/not_timefreeze.feature +14 -0
- data/features/number_transform.feature +5 -0
- data/features/step_definitions/liquid_templates_steps.rb +3 -0
- data/features/step_definitions/number_transform_steps.rb +7 -0
- data/features/step_definitions/timefreeze_steps.rb +15 -0
- data/features/support/env.rb +10 -0
- data/features/timefreeze.feature +15 -0
- data/lib/lookout/rack/test.rb +8 -0
- data/lib/lookout/rack/test/cucumber.rb +32 -0
- data/lib/lookout/rack/test/cucumber/before.rb +5 -0
- data/lib/lookout/rack/test/cucumber/general_steps.rb +42 -0
- data/lib/lookout/rack/test/cucumber/server.rb +11 -0
- data/lib/lookout/rack/test/cucumber/transforms.rb +3 -0
- data/lib/lookout/rack/test/load_factories.rb +5 -0
- data/lib/lookout/rack/test/rake.rb +16 -0
- data/lib/lookout/rack/test/rake/cucumber.rake +16 -0
- data/lib/lookout/rack/test/rake/rspec.rake +21 -0
- data/lib/lookout/rack/test/rspec.rb +52 -0
- data/lib/lookout/rack/test/rspec/email_helpers.rb +32 -0
- data/lib/lookout/rack/test/rspec/fake_request.rb +20 -0
- data/lib/lookout/rack/test/rspec/model_examples.rb +12 -0
- data/lib/lookout/rack/test/rspec/route_helper.rb +7 -0
- data/lib/lookout/rack/test/version.rb +7 -0
- data/lookout-rack-test.gemspec +44 -0
- data/spec/email_helpers_spec.rb +104 -0
- data/spec/model_examples_spec.rb +51 -0
- data/spec/setup_spec.rb +51 -0
- data/spec/spec_helper.rb +15 -0
- metadata +339 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'A timestamped model' do
|
4
|
+
context 'A model' do
|
5
|
+
subject(:model) { double('Mock model') }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
attrs.each do |attr|
|
9
|
+
model.stub(attr)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'that is a timestamped model' do
|
14
|
+
let(:attrs) { [:id, :created_at, :updated_at, :deleted_at] }
|
15
|
+
|
16
|
+
it_behaves_like 'a timestamped model'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'without an id' do
|
20
|
+
let(:attrs) { [:created_at, :updated_at, :deleted_at] }
|
21
|
+
|
22
|
+
it 'should not behave like a timestamped model' do
|
23
|
+
pending
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'without an created_at' do
|
28
|
+
let(:attrs) { [:id, :updated_at, :deleted_at] }
|
29
|
+
|
30
|
+
it 'should not behave like a timestamped model' do
|
31
|
+
pending
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'without an updated_at' do
|
36
|
+
let(:attrs) { [:id, :created_at, :deleted_at] }
|
37
|
+
|
38
|
+
it 'should not behave like a timestamped model' do
|
39
|
+
pending
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'without an deleted_at' do
|
44
|
+
let(:attrs) { [:id, :created_at, :updated_at] }
|
45
|
+
|
46
|
+
it 'should not behave like a timestamped model' do
|
47
|
+
pending
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/setup_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ':timefreeze => true' do
|
4
|
+
before :each do
|
5
|
+
@initial_time = Time.now
|
6
|
+
sleep 0.5
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'a test marked as :timefreeze => true', :timefreeze => true do
|
10
|
+
it 'should be frozen in time' do
|
11
|
+
expect(@initial_time).to eql Time.now
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'a test not marked as :timefreeze => true' do
|
16
|
+
it 'should not be frozen in time' do
|
17
|
+
expect(@initial_time).not_to eql Time.now
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ':speed => :slow' do
|
23
|
+
context 'a test marked as :speed => :slow', :speed => :slow do
|
24
|
+
it 'should have called .setup on the Models module' do
|
25
|
+
expect(TestModels.was_setup?).to be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'a test not marked as :speed => :slow' do
|
30
|
+
it 'should not have called .setup on the Models module' do
|
31
|
+
expect(TestModels.was_setup?).to be_false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ':type => :route' do
|
37
|
+
subject(:request) { get '/' }
|
38
|
+
|
39
|
+
context 'a test marked as :type => :route', :type => :route do
|
40
|
+
it 'should be able to GET a route' do
|
41
|
+
expect { get '/' }.not_to raise_error
|
42
|
+
expect(last_response.status).to be 200
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'a test not marked as :type => :route' do
|
47
|
+
it 'should not be able to GET a route' do
|
48
|
+
expect { get '/' }.to raise_error(NoMethodError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../')
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
require 'lookout/rack/test/rspec'
|
5
|
+
include Lookout::Rack::Test::RSpec
|
6
|
+
|
7
|
+
ExpectationNotMetError = RSpec::Expectations::ExpectationNotMetError
|
8
|
+
|
9
|
+
require 'examples/test_models'
|
10
|
+
require 'examples/test_app'
|
11
|
+
|
12
|
+
# These methods are tested in setup_spec
|
13
|
+
configure_rspec
|
14
|
+
setup_models(TestModels)
|
15
|
+
setup_routes(TestApp)
|
metadata
ADDED
@@ -0,0 +1,339 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lookout-rack-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ian Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: liquid
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.12'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ci_reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: nokogiri
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rack-test
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: timecop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: factory_girl
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: cucumber
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: capybara
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 2.x
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ~>
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.x
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: selenium-webdriver
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - <=
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 2.35.1
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - <=
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 2.35.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: sauce-connect
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ! '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: sauce
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ~>
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '3.0'
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ~>
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '3.0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: sauce-cucumber
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ~>
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '3.0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ~>
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '3.0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: mercury-messages
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ! '>='
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ! '>='
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
description: RSpec and Cucumber helpers
|
252
|
+
email:
|
253
|
+
- ian.smith@lookout.com
|
254
|
+
executables: []
|
255
|
+
extensions: []
|
256
|
+
extra_rdoc_files: []
|
257
|
+
files:
|
258
|
+
- .gitignore
|
259
|
+
- Gemfile
|
260
|
+
- LICENSE.txt
|
261
|
+
- README.md
|
262
|
+
- Rakefile
|
263
|
+
- cucumber.yml
|
264
|
+
- examples/test_app.rb
|
265
|
+
- examples/test_models.rb
|
266
|
+
- features/general_steps/requests.feature
|
267
|
+
- features/general_steps/requests_with_json_body.feature
|
268
|
+
- features/general_steps/requests_with_params.feature
|
269
|
+
- features/general_steps/response.feature
|
270
|
+
- features/liquid_templates.feature
|
271
|
+
- features/not_timefreeze.feature
|
272
|
+
- features/number_transform.feature
|
273
|
+
- features/step_definitions/liquid_templates_steps.rb
|
274
|
+
- features/step_definitions/number_transform_steps.rb
|
275
|
+
- features/step_definitions/timefreeze_steps.rb
|
276
|
+
- features/support/env.rb
|
277
|
+
- features/timefreeze.feature
|
278
|
+
- lib/lookout/rack/test.rb
|
279
|
+
- lib/lookout/rack/test/cucumber.rb
|
280
|
+
- lib/lookout/rack/test/cucumber/before.rb
|
281
|
+
- lib/lookout/rack/test/cucumber/general_steps.rb
|
282
|
+
- lib/lookout/rack/test/cucumber/server.rb
|
283
|
+
- lib/lookout/rack/test/cucumber/transforms.rb
|
284
|
+
- lib/lookout/rack/test/load_factories.rb
|
285
|
+
- lib/lookout/rack/test/rake.rb
|
286
|
+
- lib/lookout/rack/test/rake/cucumber.rake
|
287
|
+
- lib/lookout/rack/test/rake/rspec.rake
|
288
|
+
- lib/lookout/rack/test/rspec.rb
|
289
|
+
- lib/lookout/rack/test/rspec/email_helpers.rb
|
290
|
+
- lib/lookout/rack/test/rspec/fake_request.rb
|
291
|
+
- lib/lookout/rack/test/rspec/model_examples.rb
|
292
|
+
- lib/lookout/rack/test/rspec/route_helper.rb
|
293
|
+
- lib/lookout/rack/test/version.rb
|
294
|
+
- lookout-rack-test.gemspec
|
295
|
+
- spec/email_helpers_spec.rb
|
296
|
+
- spec/model_examples_spec.rb
|
297
|
+
- spec/setup_spec.rb
|
298
|
+
- spec/spec_helper.rb
|
299
|
+
homepage: ''
|
300
|
+
licenses:
|
301
|
+
- MIT
|
302
|
+
metadata: {}
|
303
|
+
post_install_message:
|
304
|
+
rdoc_options: []
|
305
|
+
require_paths:
|
306
|
+
- lib
|
307
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
308
|
+
requirements:
|
309
|
+
- - ! '>='
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: '0'
|
312
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
313
|
+
requirements:
|
314
|
+
- - ! '>='
|
315
|
+
- !ruby/object:Gem::Version
|
316
|
+
version: '0'
|
317
|
+
requirements: []
|
318
|
+
rubyforge_project:
|
319
|
+
rubygems_version: 2.0.5
|
320
|
+
signing_key:
|
321
|
+
specification_version: 4
|
322
|
+
summary: ''
|
323
|
+
test_files:
|
324
|
+
- features/general_steps/requests.feature
|
325
|
+
- features/general_steps/requests_with_json_body.feature
|
326
|
+
- features/general_steps/requests_with_params.feature
|
327
|
+
- features/general_steps/response.feature
|
328
|
+
- features/liquid_templates.feature
|
329
|
+
- features/not_timefreeze.feature
|
330
|
+
- features/number_transform.feature
|
331
|
+
- features/step_definitions/liquid_templates_steps.rb
|
332
|
+
- features/step_definitions/number_transform_steps.rb
|
333
|
+
- features/step_definitions/timefreeze_steps.rb
|
334
|
+
- features/support/env.rb
|
335
|
+
- features/timefreeze.feature
|
336
|
+
- spec/email_helpers_spec.rb
|
337
|
+
- spec/model_examples_spec.rb
|
338
|
+
- spec/setup_spec.rb
|
339
|
+
- spec/spec_helper.rb
|