excalibur 0.0.2
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/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +162 -0
- data/Rakefile +2 -0
- data/excalibur.gemspec +32 -0
- data/lib/excalibur/configuration.rb +77 -0
- data/lib/excalibur/decorator.rb +55 -0
- data/lib/excalibur/duplicator.rb +19 -0
- data/lib/excalibur/railtie.rb +15 -0
- data/lib/excalibur/truncatable_content.rb +82 -0
- data/lib/excalibur/version.rb +4 -0
- data/lib/excalibur/view_helpers.rb +59 -0
- data/lib/excalibur.rb +91 -0
- data/lib/generators/excalibur/decorator_generator.rb +18 -0
- data/lib/generators/excalibur/install_generator.rb +18 -0
- data/lib/generators/templates/decorator.rb +75 -0
- data/lib/generators/templates/excalibur.rb +151 -0
- data/spec/lib/excalibur/configuration_spec.rb +215 -0
- data/spec/lib/excalibur/decorator_spec.rb +224 -0
- data/spec/lib/excalibur/duplicator_spec.rb +49 -0
- data/spec/lib/excalibur/truncatable_content_spec.rb +192 -0
- data/spec/lib/excalibur/view_helper_spec.rb +87 -0
- data/spec/lib/excalibur_spec.rb +85 -0
- data/spec/lib/generators/excalibur/decorator_generator_spec.rb +28 -0
- data/spec/lib/generators/excalibur/install_generator_spec.rb +30 -0
- data/spec/spec_helper.rb +80 -0
- metadata +219 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Excalibur
|
4
|
+
class Foo; include Duplicator; end
|
5
|
+
|
6
|
+
describe Duplicator do
|
7
|
+
let(:klass) { Foo.new }
|
8
|
+
|
9
|
+
describe '#dup_instance' do
|
10
|
+
context 'when input is a truncable content' do
|
11
|
+
let(:obj) { TruncateableContent.new }
|
12
|
+
|
13
|
+
it 'should call dup' do
|
14
|
+
expect( obj ).to receive(:dup)
|
15
|
+
|
16
|
+
klass.dup_instance(obj)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when input is a hash' do
|
21
|
+
let(:obj) { ::HashWithIndifferentAccess.new }
|
22
|
+
|
23
|
+
it 'should call dup' do
|
24
|
+
expect( obj ).to receive(:deep_dup)
|
25
|
+
|
26
|
+
klass.dup_instance(obj)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when input is a string' do
|
31
|
+
let(:obj) { 'foobar' }
|
32
|
+
|
33
|
+
it 'should not call dup' do
|
34
|
+
expect( obj ).to_not receive(:dup)
|
35
|
+
|
36
|
+
expect(klass.dup_instance(obj)).to eq('foobar')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when input is nil' do
|
41
|
+
let(:obj) { nil }
|
42
|
+
|
43
|
+
it 'should not call dup' do
|
44
|
+
expect(klass.dup_instance(obj)).to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Excalibur
|
4
|
+
describe TruncateableContent do
|
5
|
+
describe '#new' do
|
6
|
+
let(:obj) { TruncateableContent.new }
|
7
|
+
|
8
|
+
it 'should create default content hash' do
|
9
|
+
expect(obj.content).to_not be_nil
|
10
|
+
expect(obj.content).to be_instance_of ::HashWithIndifferentAccess
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should create default options hash' do
|
14
|
+
expect(obj.options).to_not be_nil
|
15
|
+
expect(obj.options).to be_instance_of ::HashWithIndifferentAccess
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should create a default combinator' do
|
19
|
+
expect(obj.combinator).to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#can_merge?' do
|
24
|
+
let(:obj) { TruncateableContent.new }
|
25
|
+
|
26
|
+
context 'when the objects are not the same' do
|
27
|
+
it 'should be false' do
|
28
|
+
expect(obj.can_merge?(true)).to eq(false)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when the objects is the same' do
|
33
|
+
it 'should be true' do
|
34
|
+
expect(obj.can_merge?(obj)).to eq(true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#merge!' do
|
40
|
+
context 'when trying to merge with the wrong type of object' do
|
41
|
+
let(:obj) { TruncateableContent.new }
|
42
|
+
|
43
|
+
it 'should raise a TypeError' do
|
44
|
+
expect { obj.merge!('foo') }.to raise_error(TypeError, 'can only merge two Excalibur::TruncateableContent objects')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when merging two correct object types' do
|
49
|
+
let(:obj_a) { TruncateableContent.new({body: 'foobar'}, {'body' => 'baz', other: true}, 'obj_a') }
|
50
|
+
let(:obj_b) { TruncateableContent.new({'body' => 'baz', other: true}, {body: 'foobar'}, 'obj_b') }
|
51
|
+
|
52
|
+
context 'function result' do
|
53
|
+
it 'should return the object' do
|
54
|
+
expect(obj_a.merge!(obj_b)).to be_instance_of TruncateableContent
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'instance result' do
|
59
|
+
before do
|
60
|
+
obj_a.merge!(obj_b)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should merge the content' do
|
64
|
+
expect(obj_a.content).to eq({'body' => 'baz', 'other' => true})
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should merge the options' do
|
68
|
+
expect(obj_a.options).to eq({'body' => 'foobar', 'other' => true})
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should overwrite the combinator' do
|
72
|
+
expect(obj_a.combinator).to eq('obj_b')
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when merging an object without combinator' do
|
76
|
+
let(:obj_b) { TruncateableContent.new({'body' => 'baz', other: true}, {body: 'foobar'}) }
|
77
|
+
|
78
|
+
it 'should not overwrite the combinator' do
|
79
|
+
expect(obj_a.combinator).to eq('obj_a')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#dup' do
|
87
|
+
let(:obj) { TruncateableContent.new({body: 'foobar', other: proc { |obj| "proc content #{obj}" }}, {}, nil) }
|
88
|
+
|
89
|
+
it 'should create a duplicate of the object and the attributes' do
|
90
|
+
expect(obj).to receive(:dup_instance).exactly(3).times
|
91
|
+
|
92
|
+
obj.dup
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#get_content' do
|
97
|
+
let(:obj) { TruncateableContent.new(body: 'foobar', other: proc { |obj| "proc content #{obj}" }) }
|
98
|
+
|
99
|
+
it 'should return string content' do
|
100
|
+
expect(obj.get_content(:body)).to be_instance_of ::String
|
101
|
+
expect(obj.get_content(:body)).to eq('foobar')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return the result of proc content' do
|
105
|
+
expect(obj.get_content(:other, true)).to be_instance_of ::String
|
106
|
+
expect(obj.get_content(:other, true)).to eq('proc content true')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#update_content' do
|
111
|
+
let(:obj) { TruncateableContent.new }
|
112
|
+
|
113
|
+
context 'when value is provided' do
|
114
|
+
it 'should add the content value' do
|
115
|
+
expect { obj.update_content(:body, 'Body content') }.to change(obj, :content)
|
116
|
+
expect(obj.content[:body]).to eq('Body content')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when value has not been provided' do
|
121
|
+
it 'should add the content value' do
|
122
|
+
obj.update_content(:body)
|
123
|
+
|
124
|
+
expect(obj.content).to have_key(:body)
|
125
|
+
expect(obj.content[:body]).to be_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#update_option' do
|
131
|
+
let(:obj) { TruncateableContent.new }
|
132
|
+
|
133
|
+
context 'when value is provided' do
|
134
|
+
it 'should add the option value' do
|
135
|
+
expect { obj.update_option(:limit, 88) }.to change(obj, :options)
|
136
|
+
expect(obj.options[:limit]).to eq(88)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when value has not been provided' do
|
141
|
+
it 'should add the content value' do
|
142
|
+
obj.update_option(:limit)
|
143
|
+
|
144
|
+
expect(obj.options).to have_key(:limit)
|
145
|
+
expect(obj.options[:limit]).to be_nil
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe '#update_combinator' do
|
151
|
+
let(:obj) { TruncateableContent.new }
|
152
|
+
|
153
|
+
it 'should set the combinator' do
|
154
|
+
expect(obj.combinator).to be_nil
|
155
|
+
|
156
|
+
expect{ obj.update_combinator(proc { 'foobar' }) }.to change(obj, :combinator)
|
157
|
+
|
158
|
+
expect(obj.combinator).to be_instance_of(::Proc)
|
159
|
+
expect(obj.combinator.call).to eq('foobar')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#render_long' do
|
164
|
+
let(:obj) { TruncateableContent.new(body: 'foobar', other: proc { |obj| "proc content #{obj}" }) }
|
165
|
+
|
166
|
+
it 'should render all the values of the content hash' do
|
167
|
+
expect(obj.render_long(true)).to be_instance_of ::String
|
168
|
+
expect(obj.render_long(true)).to eq('foobarproc content true')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#render_short' do
|
173
|
+
context 'when a combinator is a proc' do
|
174
|
+
let(:obj) { TruncateableContent.new({}, {}, proc { |obj| "obj: #{obj}" }) }
|
175
|
+
|
176
|
+
it 'should call the proc with the given object' do
|
177
|
+
expect(obj.render_short(true)).to eq('obj: true')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'when a combinator is not a proc' do
|
182
|
+
let(:obj) { TruncateableContent.new() }
|
183
|
+
|
184
|
+
it 'should call for render_long' do
|
185
|
+
expect(obj).to receive(:render_long).with(true)
|
186
|
+
|
187
|
+
obj.render_short(true)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'excalibur/view_helpers'
|
3
|
+
require 'action_view/helpers'
|
4
|
+
|
5
|
+
class Dummy; end
|
6
|
+
class Klass; end
|
7
|
+
|
8
|
+
module Excalibur
|
9
|
+
class DummyDecorator < Decorator; end
|
10
|
+
|
11
|
+
describe ViewHelpers do
|
12
|
+
let(:helpers) do
|
13
|
+
klass = Klass.new.extend(ActionView::Helpers::TagHelper)
|
14
|
+
klass.extend(ViewHelpers)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#entitle' do
|
18
|
+
let(:obj) { Dummy.new }
|
19
|
+
|
20
|
+
it 'should try and decorate an object' do
|
21
|
+
expect(DummyDecorator).to receive(:decorate).with(obj, {})
|
22
|
+
|
23
|
+
helpers.entitle(obj, {})
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should set an instance variable' do
|
27
|
+
helpers.entitle(obj, {})
|
28
|
+
|
29
|
+
expect(helpers.instance_variable_get(:@excalibur_subject)).to be_present
|
30
|
+
expect(helpers.instance_variable_get(:@excalibur_subject)).to be_instance_of DummyDecorator
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#render_title_tag' do
|
35
|
+
context 'when the configuration is standard' do
|
36
|
+
it 'should return a title tag with the default content' do
|
37
|
+
expect(helpers.render_title_tag).to eq '<title>Excalibur</title>'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when the configuration changed' do
|
42
|
+
before do
|
43
|
+
DummyDecorator.excalibur_set_title_content :body, 'New custom title'
|
44
|
+
DummyDecorator.excalibur_set_title_content :prefix, '()==|::::::> '
|
45
|
+
|
46
|
+
helpers.entitle(Dummy.new)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return a title tag with the custom title content' do
|
50
|
+
expect(helpers.render_title_tag).to eq '<title>()==|::::::> New custom title</title>'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#render_meta_tags' do
|
56
|
+
context 'when the configuration is standard' do
|
57
|
+
it 'should return a set of meta tags with the default content' do
|
58
|
+
expect(helpers.render_meta_tags).to include '<meta content="Excalibur; a worthy title for a gem about titles." name="description" />'
|
59
|
+
expect(helpers.render_meta_tags).to include '<meta content="width=device-width, initial-scale=1" name="viewport" />'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when the configuration changed' do
|
64
|
+
before do
|
65
|
+
DummyDecorator.excalibur_set_description_content :body, 'New custom description'
|
66
|
+
DummyDecorator.excalibur_set_meta_tag :foo, :bar, 'baz'
|
67
|
+
DummyDecorator.excalibur_set_meta_tag :foo, :array, ['foo', 'bar', 'baz']
|
68
|
+
DummyDecorator.excalibur_set_meta_tag :foo, :proc, proc { |obj| obj.class.to_s }
|
69
|
+
DummyDecorator.excalibur_set_meta_tag :foo, :nil, nil
|
70
|
+
|
71
|
+
helpers.entitle(Dummy.new)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return a title tag with the custom title content' do
|
75
|
+
expect(helpers.render_meta_tags).to include '<meta content="New custom description" name="description" />'
|
76
|
+
expect(helpers.render_meta_tags).to include '<meta content="width=device-width, initial-scale=1" name="viewport" />'
|
77
|
+
expect(helpers.render_meta_tags).to include '<meta content="baz" foo="bar" />'
|
78
|
+
expect(helpers.render_meta_tags).to include '<meta content="foo" foo="array" />'
|
79
|
+
expect(helpers.render_meta_tags).to include '<meta content="bar" foo="array" />'
|
80
|
+
expect(helpers.render_meta_tags).to include '<meta content="baz" foo="array" />'
|
81
|
+
expect(helpers.render_meta_tags).to include '<meta content="Excalibur::DummyDecorator" foo="proc" />'
|
82
|
+
expect(helpers.render_meta_tags).to_not include 'foo="nil" />'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Excalibur
|
4
|
+
describe '::configure' do
|
5
|
+
context 'when the config is empty' do
|
6
|
+
let(:obj) { Decorator.new(true) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Excalibur.configure {}
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should create a configuration' do
|
13
|
+
expect(Excalibur.configuration).to be_present
|
14
|
+
expect(Excalibur.configuration).to be_instance_of Configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set the config default objects' do
|
18
|
+
expect(Excalibur.configuration.title).to be_instance_of TruncateableContent
|
19
|
+
expect(Excalibur.configuration.description).to be_instance_of TruncateableContent
|
20
|
+
expect(Excalibur.configuration.meta_tags).to be_instance_of ::HashWithIndifferentAccess
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the correct title value' do
|
24
|
+
expect(Excalibur.configuration.title.to_s(obj)).to eq('Excalibur')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have the correct description value' do
|
28
|
+
expect(Excalibur.configuration.description.to_s(obj)).to eq('Excalibur; a worthy title for a gem about titles.')
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
Excalibur.reset
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when the config is contains changes' do
|
37
|
+
before do
|
38
|
+
Excalibur.configure do |config|
|
39
|
+
config.title = 'Foobar'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should set the config default objects' do
|
44
|
+
expect(Excalibur.configuration.description).to be_instance_of TruncateableContent
|
45
|
+
expect(Excalibur.configuration.meta_tags).to be_instance_of ::HashWithIndifferentAccess
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should have the changed title' do
|
49
|
+
expect(Excalibur.configuration.title).to be_instance_of ::String
|
50
|
+
expect(Excalibur.configuration.title.to_s).to eq('Foobar')
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
Excalibur.reset
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '::configuration' do
|
60
|
+
before do
|
61
|
+
@config = Excalibur.configuration
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should create only one new' do
|
65
|
+
expect(Configuration).to_not receive(:new)
|
66
|
+
expect(Excalibur.configuration).to eq(@config)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '::reset' do
|
71
|
+
before do
|
72
|
+
Excalibur.configure do |config|
|
73
|
+
config.title = 'Foobar'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should set the config value' do
|
78
|
+
@old = Excalibur.configuration
|
79
|
+
|
80
|
+
Excalibur.reset
|
81
|
+
|
82
|
+
expect(Excalibur.configuration.title).to_not equal(@old.title)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'generator_spec'
|
2
|
+
require 'generators/excalibur/decorator_generator'
|
3
|
+
|
4
|
+
module Excalibur
|
5
|
+
describe Generators::DecoratorGenerator do
|
6
|
+
destination File.expand_path('../../tmp', __FILE__)
|
7
|
+
arguments %w(dummy)
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
prepare_destination
|
11
|
+
run_generator
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create the correct file and content' do
|
15
|
+
expect(destination_root).to have_structure {
|
16
|
+
directory 'app' do
|
17
|
+
directory 'decorators' do
|
18
|
+
directory 'excalibur' do
|
19
|
+
file 'dummy_decorator.rb' do
|
20
|
+
contains 'class Excalibur::DummyDecorator < Excalibur::Decorator'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'generator_spec'
|
2
|
+
require 'generators/excalibur/install_generator'
|
3
|
+
|
4
|
+
module Excalibur
|
5
|
+
describe Generators::InstallGenerator do
|
6
|
+
destination File.expand_path('../../tmp', __FILE__)
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
prepare_destination
|
10
|
+
run_generator
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'creates a test initializer' do
|
14
|
+
assert_file 'config/initializers/excalibur.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should copy the template initializer over to the app config' do
|
18
|
+
expect(destination_root).to have_structure {
|
19
|
+
no_file 'excalibur.rb'
|
20
|
+
directory 'config' do
|
21
|
+
directory 'initializers' do
|
22
|
+
file 'excalibur.rb' do
|
23
|
+
contains 'Excalibur.configure do |config|'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'excalibur'
|
2
|
+
require 'pry'
|
3
|
+
require 'simplecov'
|
4
|
+
|
5
|
+
SimpleCov.start
|
6
|
+
|
7
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
8
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
9
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
10
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
11
|
+
#
|
12
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
13
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
14
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
15
|
+
# individual file that may not need all of that loaded. Instead, make a
|
16
|
+
# separate helper file that requires this one and then use it only in the specs
|
17
|
+
# that actually need it.
|
18
|
+
#
|
19
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
20
|
+
# users commonly want.
|
21
|
+
#
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# These two settings work together to allow you to limit a spec run
|
25
|
+
# to individual examples or groups you care about by tagging them with
|
26
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
27
|
+
# get run.
|
28
|
+
config.filter_run :focus
|
29
|
+
config.run_all_when_everything_filtered = true
|
30
|
+
|
31
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
32
|
+
# file, and it's useful to allow more verbose output when running an
|
33
|
+
# individual spec file.
|
34
|
+
if config.files_to_run.one?
|
35
|
+
# Use the documentation formatter for detailed output,
|
36
|
+
# unless a formatter has already been configured
|
37
|
+
# (e.g. via a command-line flag).
|
38
|
+
config.default_formatter = 'doc'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Print the 10 slowest examples and example groups at the
|
42
|
+
# end of the spec run, to help surface which specs are running
|
43
|
+
# particularly slow.
|
44
|
+
# config.profile_examples = 10
|
45
|
+
|
46
|
+
# Run specs in random order to surface order dependencies. If you find an
|
47
|
+
# order dependency and want to debug it, you can fix the order by providing
|
48
|
+
# the seed, which is printed after each run.
|
49
|
+
# --seed 1234
|
50
|
+
config.order = :random
|
51
|
+
|
52
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
53
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
54
|
+
# test failures related to randomization by passing the same `--seed` value
|
55
|
+
# as the one that triggered the failure.
|
56
|
+
Kernel.srand config.seed
|
57
|
+
|
58
|
+
# rspec-expectations config goes here. You can use an alternate
|
59
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
60
|
+
# assertions if you prefer.
|
61
|
+
config.expect_with :rspec do |expectations|
|
62
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
63
|
+
# For more details, see:
|
64
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
65
|
+
expectations.syntax = :expect
|
66
|
+
end
|
67
|
+
|
68
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
69
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
70
|
+
config.mock_with :rspec do |mocks|
|
71
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
72
|
+
# For more details, see:
|
73
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
74
|
+
mocks.syntax = :expect
|
75
|
+
|
76
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
77
|
+
# a real object. This is generally recommended.
|
78
|
+
mocks.verify_partial_doubles = true
|
79
|
+
end
|
80
|
+
end
|