morse_spec_helpers 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/morse_spec_helpers/version.rb +3 -0
- data/lib/morse_spec_helpers.rb +490 -0
- data/morse_spec_helpers.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83f985a4afeaf1e12108fdcbc43947afaa552828
|
4
|
+
data.tar.gz: 967f7652846cd8c14e9f9c94c42c7af2a16ff7c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc3cc668e8c4697ec89ac2ac408ec9face29578ce250921f9af73e21a3752a77436b29ae8cf175d0710a9427bcedb6065ede9160ea22ec36b77d39878a5d396b
|
7
|
+
data.tar.gz: 38575ccc855e0c752e046e005953d584f115b84481cde29895bea2a02df052182ee26f4b301299574866e7feba7bb96fd69af460a9fe645863c43f7187b9e656
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Terry S
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MorseSpecHelpers
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'morse_spec_helpers'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install morse_spec_helpers
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/morse_spec_helpers/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,490 @@
|
|
1
|
+
require "morse_spec_helpers/version"
|
2
|
+
|
3
|
+
module MorseSpecHelpers
|
4
|
+
|
5
|
+
def boolean_default_false(method)
|
6
|
+
exists(method)
|
7
|
+
it "should default to false" do
|
8
|
+
new_thing=@instance.class.new
|
9
|
+
expect(new_thing.send(method)).to be_false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def boolean_default_true(method)
|
14
|
+
exists(method)
|
15
|
+
it "should default to true" do
|
16
|
+
new_thing=@instance.class.new
|
17
|
+
expect(new_thing.send(method)).to be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def exists(method)
|
22
|
+
context "must respond to #{method}" do
|
23
|
+
it "should respond to #{method}" do
|
24
|
+
expect(@instance).to respond_to(method)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def exposes(variable)
|
30
|
+
it "exposes variable #{variable}" do
|
31
|
+
expect(controller.send(variable)).to_not be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def mandatory_array(method)
|
36
|
+
context "#{method}" do
|
37
|
+
exists(method)
|
38
|
+
it "should be an Array" do
|
39
|
+
expect(@instance.send(method).is_a?(Array)).to be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def mandatory_belongs_to(model)
|
45
|
+
context "#{model}" do
|
46
|
+
context "where the id is incorrect" do
|
47
|
+
before do
|
48
|
+
allow(model).to receive(:find_by_id).and_return(nil)
|
49
|
+
end
|
50
|
+
it "should be invalid" do
|
51
|
+
expect(@instance).to_not be_valid
|
52
|
+
end
|
53
|
+
end
|
54
|
+
context "where the id is correct" do
|
55
|
+
before do
|
56
|
+
allow(model).to receive(:find_by_id).and_return(true)
|
57
|
+
end
|
58
|
+
it "should be valid" do
|
59
|
+
expect(@instance).to be_valid
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def mandatory_date(method)
|
66
|
+
context "#{method} is a mandatory date" do
|
67
|
+
it "should reject a blank #{method}" do
|
68
|
+
@instance.send("#{method}=","")
|
69
|
+
expect(@instance).not_to be_valid
|
70
|
+
end
|
71
|
+
it "should accept a normal date for #{method}" do
|
72
|
+
@instance.send("#{method}=",Date.today)
|
73
|
+
expect(@instance).to be_valid
|
74
|
+
end
|
75
|
+
mandatory_thing(method)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def mandatory_datetime(method,time=nil)
|
80
|
+
context "#{method} is a mandatory datetime" do
|
81
|
+
it "should reject a blank #{method}" do
|
82
|
+
@instance.send("#{method}=","")
|
83
|
+
expect(@instance).not_to be_valid
|
84
|
+
end
|
85
|
+
it "should accept a normal datetime for #{method}" do
|
86
|
+
@instance.send("#{method}=",time||Time.now)
|
87
|
+
expect(@instance).to be_valid
|
88
|
+
end
|
89
|
+
mandatory_thing(method)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def mandatory_relation(method)
|
94
|
+
context "#{method}" do
|
95
|
+
exists(method)
|
96
|
+
it "should be an ActiveRecord::Relation" do
|
97
|
+
expect(@instance.send(method).is_a?(ActiveRecord::Relation)).to be_true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def mandatory_string(method)
|
103
|
+
context "#{method} is a mandatory string" do
|
104
|
+
it "should reject a blank #{method}" do
|
105
|
+
@instance.send("#{method}=","")
|
106
|
+
expect(@instance).not_to be_valid
|
107
|
+
end
|
108
|
+
it "should accept a normal string for #{method}" do
|
109
|
+
@instance.send("#{method}=","test")
|
110
|
+
expect(@instance).to be_valid
|
111
|
+
end
|
112
|
+
mandatory_thing(method)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def mandatory_string_from_collection(method,collection)
|
117
|
+
context "#{method} is a mandatory string" do
|
118
|
+
exists(method)
|
119
|
+
it "should reject a blank #{method}" do
|
120
|
+
@instance.send("#{method}=","")
|
121
|
+
expect(@instance).not_to be_valid
|
122
|
+
end
|
123
|
+
context "where the value is not within the acceptable options" do
|
124
|
+
it "should reject it" do
|
125
|
+
@instance.send("#{method}=","zgodnflax")
|
126
|
+
expect(@instance).to_not be_valid
|
127
|
+
end
|
128
|
+
end
|
129
|
+
context "where the value is within the acceptable options" do
|
130
|
+
it "should accept it" do
|
131
|
+
@instance.send("#{method}=",collection.first)
|
132
|
+
expect(@instance).to be_valid
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def mandatory_string_with_default(method,default)
|
139
|
+
context "#{method} is a mandatory string which defaults to #{default}" do
|
140
|
+
it "should set a blank string to #{default}" do
|
141
|
+
@instance.send("#{method}=",nil)
|
142
|
+
expect(@instance).to be_valid
|
143
|
+
expect(@instance.send(method)).to eq(default)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def mandatory_thing(method)
|
149
|
+
context "#{method} is mandatory" do
|
150
|
+
exists(method)
|
151
|
+
it "should reject a nil #{method}" do
|
152
|
+
@instance.send("#{method}=","")
|
153
|
+
expect(@instance).not_to be_valid
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def mandatory_time(method,time=nil)
|
159
|
+
context "#{method} is a mandatory time" do
|
160
|
+
it "should reject a blank #{method}" do
|
161
|
+
@instance.send("#{method}=","")
|
162
|
+
expect(@instance).not_to be_valid
|
163
|
+
end
|
164
|
+
it "should accept a normal time for #{method}" do
|
165
|
+
@instance.send("#{method}=",time||Time.now)
|
166
|
+
expect(@instance).to be_valid
|
167
|
+
end
|
168
|
+
mandatory_thing(method)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def one_date_not_after_the_other(first,second)
|
173
|
+
context "for dates, where both #{first} and #{second} exist" do
|
174
|
+
before do
|
175
|
+
@first=Date.today-1.week
|
176
|
+
@second=Date.today+1.week
|
177
|
+
end
|
178
|
+
context "where #{first} is before #{second}" do
|
179
|
+
before do
|
180
|
+
@instance.send("#{first}=",@first)
|
181
|
+
@instance.send("#{second}=",@second)
|
182
|
+
end
|
183
|
+
it "should be valid" do
|
184
|
+
expect(@instance).to be_valid
|
185
|
+
end
|
186
|
+
end
|
187
|
+
context "where #{first} is the same as #{second}" do
|
188
|
+
before do
|
189
|
+
@instance.send("#{first}=",@first)
|
190
|
+
@instance.send("#{second}=",@first)
|
191
|
+
end
|
192
|
+
it "should be valid" do
|
193
|
+
expect(@instance).to be_valid
|
194
|
+
end
|
195
|
+
end
|
196
|
+
context "where #{first} is after #{second}" do
|
197
|
+
before do
|
198
|
+
@instance.send("#{first}=",@second)
|
199
|
+
@instance.send("#{second}=",@first)
|
200
|
+
end
|
201
|
+
it "should not be valid" do
|
202
|
+
expect(@instance).to_not be_valid
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def one_datetime_not_after_the_other(first,second)
|
209
|
+
context "for datetimes, where both #{first} and #{second} exist" do
|
210
|
+
before do
|
211
|
+
t=Time.now
|
212
|
+
@first=t-1.week
|
213
|
+
@second=t+1.week
|
214
|
+
end
|
215
|
+
one_thing_not_after_the_other(first,second)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def one_thing_not_after_the_other(first,second)
|
220
|
+
context "where #{first} is before #{second}" do
|
221
|
+
before do
|
222
|
+
@instance.send("#{first}=",@first)
|
223
|
+
@instance.send("#{second}=",@second)
|
224
|
+
end
|
225
|
+
it "should be valid" do
|
226
|
+
expect(@instance).to be_valid
|
227
|
+
end
|
228
|
+
end
|
229
|
+
context "where #{first} is the same as #{second}" do
|
230
|
+
before do
|
231
|
+
@instance.send("#{first}=",@first)
|
232
|
+
@instance.send("#{second}=",@first)
|
233
|
+
end
|
234
|
+
it "should be valid" do
|
235
|
+
expect(@instance).to be_valid
|
236
|
+
end
|
237
|
+
end
|
238
|
+
context "where #{first} is after #{second}" do
|
239
|
+
before do
|
240
|
+
@instance.send("#{first}=",@second)
|
241
|
+
@instance.send("#{second}=",@first)
|
242
|
+
end
|
243
|
+
it "should not be valid" do
|
244
|
+
expect(@instance).to_not be_valid
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def optional_belongs_to(model)
|
250
|
+
context "#{model}" do
|
251
|
+
let(:model_id){"#{model.to_s.underscore}_id"}
|
252
|
+
context "where the id is incorrect" do
|
253
|
+
before do
|
254
|
+
allow(model).to receive(:find_by_id).and_return(nil)
|
255
|
+
end
|
256
|
+
it "should set the id to nil" do
|
257
|
+
@instance.valid?
|
258
|
+
expect(@instance.send(model_id)).to be_nil
|
259
|
+
end
|
260
|
+
it "should be valid" do
|
261
|
+
expect(@instance).to be_valid
|
262
|
+
end
|
263
|
+
end
|
264
|
+
context "where the id is correct" do
|
265
|
+
before do
|
266
|
+
allow(model).to receive(:where).and_return(model.where("id is not null").first)
|
267
|
+
end
|
268
|
+
it "should be valid" do
|
269
|
+
expect(@instance).to be_valid
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def optional_date(method)
|
276
|
+
context "#{method} is an optional date" do
|
277
|
+
exists(method)
|
278
|
+
it "should make a blank #{method} nil" do
|
279
|
+
@instance.send("#{method}=","")
|
280
|
+
expect(@instance).to be_valid
|
281
|
+
expect(@instance.send(method)).to be_nil
|
282
|
+
end
|
283
|
+
it "should accept a normal date for #{method}" do
|
284
|
+
@instance.send("#{method}=",Date.today)
|
285
|
+
expect(@instance).to be_valid
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def optional_datetime(method)
|
291
|
+
context "#{method} is an optional datetime" do
|
292
|
+
exists(method)
|
293
|
+
it "should make a blank #{method} nil" do
|
294
|
+
@instance.send("#{method}=","")
|
295
|
+
expect(@instance).to be_valid
|
296
|
+
expect(@instance.send(method)).to be_nil
|
297
|
+
end
|
298
|
+
it "should accept a normal datetime for #{method}" do
|
299
|
+
@instance.send("#{method}=",Time.now)
|
300
|
+
expect(@instance).to be_valid
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def optional_float(method)
|
306
|
+
context "#{method} is an optional float" do
|
307
|
+
exists(method)
|
308
|
+
it "should make a blank #{method} nil" do
|
309
|
+
@instance.send("#{method}=","")
|
310
|
+
expect(@instance).to be_valid
|
311
|
+
expect(@instance.send(method)).to be_nil
|
312
|
+
end
|
313
|
+
it "should accept a normal float for #{method}" do
|
314
|
+
@instance.send("#{method}=",1.0)
|
315
|
+
expect(@instance).to be_valid
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def optional_time(method)
|
321
|
+
context "#{method} is an optional time" do
|
322
|
+
exists(method)
|
323
|
+
it "should make a blank #{method} nil" do
|
324
|
+
@instance.send("#{method}=","")
|
325
|
+
expect(@instance).to be_valid
|
326
|
+
expect(@instance.send(method)).to be_nil
|
327
|
+
end
|
328
|
+
it "should accept a normal time for #{method}" do
|
329
|
+
@instance.send("#{method}=",Time.now)
|
330
|
+
expect(@instance).to be_valid
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def optional_string(method)
|
336
|
+
context "#{method} is an optional string" do
|
337
|
+
exists(method)
|
338
|
+
it "should make a blank #{method} nil" do
|
339
|
+
@instance.send("#{method}=","")
|
340
|
+
expect(@instance).to be_valid
|
341
|
+
expect(@instance.send(method)).to be_nil
|
342
|
+
end
|
343
|
+
it "should accept a normal string for #{method}" do
|
344
|
+
@instance.send("#{method}=","test")
|
345
|
+
expect(@instance).to be_valid
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def optional_string_from_collection(method,collection)
|
351
|
+
context "#{method} is an optional string" do
|
352
|
+
exists(method)
|
353
|
+
it "should make a blank #{method} nil" do
|
354
|
+
@instance.send("#{method}=","")
|
355
|
+
expect(@instance).to be_valid
|
356
|
+
expect(@instance.send(method)).to be_nil
|
357
|
+
end
|
358
|
+
context "where the value is not within the acceptable options" do
|
359
|
+
it "should not accept it" do
|
360
|
+
@instance.send("#{method}=","zgodnflax")
|
361
|
+
expect(@instance).to_not be_valid
|
362
|
+
end
|
363
|
+
end
|
364
|
+
context "where the value is within the acceptable options" do
|
365
|
+
it "should accept it" do
|
366
|
+
@instance.send("#{method}=",collection.first)
|
367
|
+
expect(@instance).to be_valid
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
def processes_attachment_to_attribute(method)
|
374
|
+
describe "#{method} processing" do
|
375
|
+
describe "accessors" do
|
376
|
+
%w{attachment attachment_title attachment_alt attachment_remove}.each do |suffix|
|
377
|
+
it "should respond to #{method}_#{suffix}" do
|
378
|
+
expect(@instance).to respond_to("#{method}_#{suffix}")
|
379
|
+
end
|
380
|
+
end
|
381
|
+
describe "processing" do
|
382
|
+
describe "where all is good" do
|
383
|
+
it "should process the #{method} attachment properly" do
|
384
|
+
@instance.send("#{method}=",nil)
|
385
|
+
@instance.valid?
|
386
|
+
expect(@instance.send(method)).to be_nil
|
387
|
+
@instance.send("#{method}_attachment=",fixture_file_upload("../support/images/placeholder.png", 'image/png'))
|
388
|
+
@instance.send("#{method}_attachment_title=","test")
|
389
|
+
@instance.valid?
|
390
|
+
expect(@instance.send(method)).to_not be_nil
|
391
|
+
end
|
392
|
+
end
|
393
|
+
describe "where the #{method} attachment has errors" do
|
394
|
+
it "should be invalid and add attachment errors to #{method} attachment" do
|
395
|
+
@instance.send("#{method}=",nil)
|
396
|
+
@instance.valid?
|
397
|
+
expect(@instance.send(method)).to be_nil
|
398
|
+
@instance.send("#{method}_attachment_title=",nil)
|
399
|
+
@instance.send("#{method}_attachment=",fixture_file_upload("../support/images/placeholder.png", 'image/png'))
|
400
|
+
expect(@instance.valid?).to_not be_true
|
401
|
+
expect(@instance.errors[method]).to_not be_empty
|
402
|
+
expect(@instance.send(method)).to be_nil
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def processes_multiple_attachments_to_attribute(method)
|
411
|
+
describe "#{method} processing" do
|
412
|
+
it "should respond to #{method}" do
|
413
|
+
expect(@instance.respond_to?(method)).to be_true
|
414
|
+
end
|
415
|
+
describe "accessors" do
|
416
|
+
%w{attachment attachment_title attachment_alt attachment_remove}.each do |suffix|
|
417
|
+
it "should respond to #{method.to_s.singularize}_#{suffix}" do
|
418
|
+
expect(@instance).to respond_to("#{method.to_s.singularize}_#{suffix}")
|
419
|
+
end
|
420
|
+
end
|
421
|
+
describe "processing" do
|
422
|
+
describe "where all is good" do
|
423
|
+
it "should process the #{method} attachment properly" do
|
424
|
+
@instance.send("#{method}=",[])
|
425
|
+
@instance.valid?
|
426
|
+
expect(@instance.send(method)).to be_empty
|
427
|
+
@instance.send("#{method.to_s.singularize}_attachment=",fixture_file_upload("../support/images/placeholder.png", 'image/png'))
|
428
|
+
@instance.send("#{method.to_s.singularize}_attachment_alt=","test")
|
429
|
+
@instance.valid?
|
430
|
+
expect(@instance.send(method)).to_not be_empty
|
431
|
+
end
|
432
|
+
end
|
433
|
+
describe "where the #{method} attachment has errors" do
|
434
|
+
it "should be invalid and add attachment errors to #{method} attachment" do
|
435
|
+
@instance.send("#{method}=",[])
|
436
|
+
@instance.valid?
|
437
|
+
expect(@instance.send(method)).to be_empty
|
438
|
+
@instance.send("#{method.to_s.singularize}_attachment_alt=",nil)
|
439
|
+
@instance.send("#{method.to_s.singularize}_attachment=",fixture_file_upload("../support/images/placeholder.png", 'image/png'))
|
440
|
+
expect(@instance.valid?).to_not be_true
|
441
|
+
expect(@instance.errors[method]).to_not be_empty
|
442
|
+
expect(@instance.send(method)).to be_empty
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
def redirects_to(path)
|
451
|
+
it "should redirect to #{path}" do
|
452
|
+
expect(response).to redirect_to(path)
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
def returns_200
|
457
|
+
it "returns http success" do
|
458
|
+
expect(response).to be_success
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
def sets_flash(method)
|
463
|
+
it "should set flash #{method}" do
|
464
|
+
expect(flash[method]).to_not be_nil
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
def sets_flash_alert
|
469
|
+
sets_flash(:alert)
|
470
|
+
end
|
471
|
+
|
472
|
+
def sets_flash_error
|
473
|
+
sets_flash(:error)
|
474
|
+
end
|
475
|
+
|
476
|
+
def sets_flash_notice
|
477
|
+
sets_flash(:notice)
|
478
|
+
end
|
479
|
+
|
480
|
+
def should_be_valid
|
481
|
+
it "should be valid" do
|
482
|
+
expect(@instance).to be_valid
|
483
|
+
end
|
484
|
+
end
|
485
|
+
def should_not_be_valid
|
486
|
+
it "should not be valid" do
|
487
|
+
expect(@instance).to_not be_valid
|
488
|
+
end
|
489
|
+
end
|
490
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'morse_spec_helpers/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "morse_spec_helpers"
|
8
|
+
spec.version = MorseSpecHelpers::VERSION
|
9
|
+
spec.authors = ["Terry S"]
|
10
|
+
spec.email = ["itsterry@gmail.com"]
|
11
|
+
spec.summary = %q{A series of helpers to make the rspec experience nicer.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: morse_spec_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Terry S
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-04 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
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
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- itsterry@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/morse_spec_helpers.rb
|
54
|
+
- lib/morse_spec_helpers/version.rb
|
55
|
+
- morse_spec_helpers.gemspec
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.2.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: A series of helpers to make the rspec experience nicer.
|
80
|
+
test_files: []
|