excursion 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/excursion/datastores/test.rb +33 -0
- data/lib/excursion/helpers/url_helper.rb +10 -18
- data/lib/excursion/pool.rb +2 -0
- data/lib/excursion/pool/dummy_application.rb +13 -0
- data/lib/excursion/route_pool.rb +1 -1
- data/lib/excursion/version.rb +1 -1
- data/spec/dummy/log/development.log +44114 -0
- data/spec/excursion/datastores/test_spec.rb +112 -0
- data/spec/excursion/pool/dummy_application_spec.rb +219 -0
- metadata +10 -4
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'excursion/datastores/test'
|
3
|
+
|
4
|
+
describe 'Excursion::Datastores::Test' do
|
5
|
+
|
6
|
+
subject do
|
7
|
+
Excursion::Datastores::Test.new
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe '::new' do
|
12
|
+
it 'should not require pool data' do
|
13
|
+
expect { Excursion::Datastores::Test.new }.to_not raise_exception
|
14
|
+
expect { Excursion::Datastores::Test.new nil }.to_not raise_exception
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should optionally accept dummy pool data' do
|
18
|
+
expect { Excursion::Datastores::Test.new {} }.to_not raise_exception
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#read' do
|
23
|
+
describe 'key' do
|
24
|
+
it 'should be required' do
|
25
|
+
expect { subject.read }.to raise_exception
|
26
|
+
expect { subject.read('test_key') }.to_not raise_exception
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should accept a symbol or string' do
|
30
|
+
expect { subject.read('test_key') }.to_not raise_exception
|
31
|
+
expect { subject.read(:test_key) }.to_not raise_exception
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should convert symbols to strings' do
|
35
|
+
expect(subject.read(:key1)).to eql(subject.read('key1'))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the requested key does not exist' do
|
40
|
+
it 'should return a dummy application' do
|
41
|
+
subject.read('non_existent_key').should be_an_instance_of(Excursion::Pool::DummyApplication)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the requested key exists' do
|
46
|
+
it 'should return the value of the requested key' do
|
47
|
+
Excursion::Specs::Mocks::SIMPLE_VALUES.each do |key,val|
|
48
|
+
subject.write(key, val)
|
49
|
+
expect(subject.read(key)).to eql(val)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#write' do
|
56
|
+
describe 'key' do
|
57
|
+
it 'should be required' do
|
58
|
+
expect { subject.write }.to raise_exception
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should accept a symbol or string' do
|
62
|
+
expect { subject.write('str_key', 'strval') }.to_not raise_exception
|
63
|
+
expect { subject.write(:sym_key, 'symval') }.to_not raise_exception
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should convert symbols to strings' do
|
67
|
+
subject.write(:sym_key, 'symval')
|
68
|
+
subject.read('sym_key').should == 'symval'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'value' do
|
73
|
+
it 'should be required' do
|
74
|
+
expect { subject.write('test_key') }.to raise_exception(ArgumentError)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should add the key to the datastore and set the value' do
|
79
|
+
subject.write('test_key', 'testval')
|
80
|
+
subject.read('test_key').should == 'testval'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should return the value of the added key' do
|
84
|
+
subject.write('test_key', 'testval').should == 'testval'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context '#delete' do
|
89
|
+
describe 'key' do
|
90
|
+
it 'should be required' do
|
91
|
+
expect { subject.delete }.to raise_exception(ArgumentError)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should remove the key from the datastore' do
|
96
|
+
subject.write('key1', Excursion::Specs::Mocks::SIMPLE_VALUES['key1'])
|
97
|
+
subject.read('key1').should eql(Excursion::Specs::Mocks::SIMPLE_VALUES['key1'])
|
98
|
+
subject.delete('key1')
|
99
|
+
subject.read('key1').should_not eql(Excursion::Specs::Mocks::SIMPLE_VALUES['key1'])
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should return the value of the deleted key if it exists' do
|
103
|
+
keyval = subject.read('key1')
|
104
|
+
subject.delete('key1').should eql(keyval)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should return nil if the deleted key does not exist' do
|
108
|
+
subject.delete('non_existent_key').should eql(nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,219 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Excursion::Pool::DummyApplication' do
|
4
|
+
|
5
|
+
context '::new' do
|
6
|
+
it 'should require a name' do
|
7
|
+
expect { Excursion::Pool::DummyApplication.new }.to raise_exception(ArgumentError)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should require a config hash' do
|
11
|
+
expect { Excursion::Pool::DummyApplication.new 'app_name' }.to raise_exception(ArgumentError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should accept an optional route collection' do
|
15
|
+
expect { Excursion::Pool::DummyApplication.new 'app_name', {} }.to_not raise_exception(ArgumentError)
|
16
|
+
expect { Excursion::Pool::DummyApplication.new 'app_name', {}, {} }.to_not raise_exception(ArgumentError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return a populated DummyApplication object' do
|
20
|
+
mock = Excursion::Specs::Mocks::SIMPLE_APP
|
21
|
+
mock_routes = Excursion::Specs::Mocks::NAMED_ROUTES
|
22
|
+
|
23
|
+
app = Excursion::Pool::DummyApplication.new mock[:name], {default_url_options: mock[:default_url_options], registered_at: mock[:registered_at]}, mock_routes
|
24
|
+
app.should be_an_instance_of(Excursion::Pool::DummyApplication)
|
25
|
+
app.name.should eql(mock[:name])
|
26
|
+
app.default_url_options.should eql(mock[:default_url_options])
|
27
|
+
mock_routes.each do |name,path|
|
28
|
+
app.routes.routes.keys.should include(name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '::from_cache' do
|
34
|
+
it 'should require a cached application hash' do
|
35
|
+
expect { Excursion::Pool::DummyApplication.from_cache }.to raise_exception(ArgumentError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should return an DummyApplication object with the cached properties' do
|
39
|
+
mock = Excursion::Specs::Mocks::SIMPLE_APP
|
40
|
+
|
41
|
+
app = Excursion::Pool::DummyApplication.from_cache(mock)
|
42
|
+
app.should be_an_instance_of(Excursion::Pool::DummyApplication)
|
43
|
+
app.name.should eql(mock[:name])
|
44
|
+
app.default_url_options.should eql(mock[:default_url_options])
|
45
|
+
mock[:routes].each do |name,path|
|
46
|
+
app.routes.routes.keys.should include(name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#to_cache' do
|
52
|
+
subject { Excursion::Pool::DummyApplication.from_cache(Excursion::Specs::Mocks::SIMPLE_APP) }
|
53
|
+
|
54
|
+
it 'should return a hash' do
|
55
|
+
subject.to_cache.should be_an_instance_of(Hash)
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'returned hash' do
|
59
|
+
it 'should contain the app name' do
|
60
|
+
subject.to_cache[:name].should eql(subject.name)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should contain the default_url_options' do
|
64
|
+
subject.to_cache[:default_url_options].should eql(subject.default_url_options)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should contain a hash of the routes' do
|
68
|
+
subject.to_cache[:routes].should be_an_instance_of(Hash)
|
69
|
+
subject.to_cache[:routes].each do |name,path|
|
70
|
+
subject.routes.routes.keys.should include(name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should contain the registered_at property' do
|
75
|
+
subject.to_cache[:registered_at].should eql(subject.instance_variable_get(:@registered_at))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#from_cache' do
|
81
|
+
subject { Excursion::Pool::DummyApplication.new 'test_app', {} }
|
82
|
+
|
83
|
+
it 'should require a cached application object' do
|
84
|
+
expect { subject.from_cache }.to raise_exception(ArgumentError)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should populate the object with the cached values' do
|
88
|
+
mock = Excursion::Specs::Mocks::SIMPLE_APP
|
89
|
+
subject.from_cache(mock)
|
90
|
+
subject.default_url_options.should eql(mock[:default_url_options])
|
91
|
+
subject.instance_variable_get(:@registered_at).to_i.should eql(mock[:registered_at].to_i)
|
92
|
+
subject.routes.each do |name,path|
|
93
|
+
mock[:routes].keys.should include(name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#route' do
|
99
|
+
subject { Excursion::Pool::DummyApplication.from_cache(Excursion::Specs::Mocks::SIMPLE_APP) }
|
100
|
+
|
101
|
+
it 'should require a name' do
|
102
|
+
expect { subject.route }.to raise_exception(ArgumentError)
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when the route exists' do
|
106
|
+
it 'should return the route object' do
|
107
|
+
if Excursion.rails3?
|
108
|
+
subject.route(:example).should be_an_instance_of(Journey::Route)
|
109
|
+
elsif Excursion.rails4?
|
110
|
+
subject.route(:example).should be_an_instance_of(ActionDispatch::Journey::Route)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'when the route does not exist' do
|
116
|
+
it 'should return a dummy route' do
|
117
|
+
if Excursion.rails3?
|
118
|
+
subject.route(:non_existent_route).should be_an_instance_of(Journey::Route)
|
119
|
+
elsif Excursion.rails4?
|
120
|
+
subject.route(:non_existent_route).should be_an_instance_of(ActionDispatch::Journey::Route)
|
121
|
+
end
|
122
|
+
subject.route(:non_existent_route).path.spec.to_s.should eql("/#{subject.name.underscore}/non_existent_route")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#routes' do
|
128
|
+
subject { Excursion::Pool::DummyApplication.from_cache(Excursion::Specs::Mocks::SIMPLE_APP) }
|
129
|
+
|
130
|
+
it 'should return a NamedRouteCollection' do
|
131
|
+
subject.routes.should be_an_instance_of(ActionDispatch::Routing::RouteSet::NamedRouteCollection)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#routes=' do
|
136
|
+
subject { Excursion::Pool::DummyApplication.new 'test_app', {} }
|
137
|
+
|
138
|
+
it 'should accept a Hash of named routes' do
|
139
|
+
expect { subject.routes = {} }.to_not raise_exception(ArgumentError)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should accept a NamedRouteCollection' do
|
143
|
+
expect { subject.routes = ActionDispatch::Routing::RouteSet::NamedRouteCollection.new }.to_not raise_exception(ArgumentError)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should only accept a Hash or NamedRouteCollection' do
|
147
|
+
expect { subject.routes = 'test string' }.to raise_exception(ArgumentError)
|
148
|
+
expect { subject.routes = 123 }.to raise_exception(ArgumentError)
|
149
|
+
expect { subject.routes = :test_symbol }.to raise_exception(ArgumentError)
|
150
|
+
expect { subject.routes = [] }.to raise_exception(ArgumentError)
|
151
|
+
expect { subject.routes = Object }.to raise_exception(ArgumentError)
|
152
|
+
expect { subject.routes = Object.new }.to raise_exception(ArgumentError)
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when passing a Hash' do
|
156
|
+
it 'should override the application routes with the ones provided' do
|
157
|
+
subject.routes = Hash[Excursion::Specs::Mocks::NAMED_ROUTES.collect {|k,v| [k,v] }]
|
158
|
+
Excursion::Specs::Mocks::NAMED_ROUTES.each do |name,path|
|
159
|
+
subject.routes.routes.keys.should include(name)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when passing a NamedRouteCollection' do
|
165
|
+
it 'should override the application routes with the ones provided' do
|
166
|
+
subject.routes = Excursion::Specs::Mocks::NAMED_ROUTES
|
167
|
+
Excursion::Specs::Mocks::NAMED_ROUTES.each do |name,path|
|
168
|
+
subject.routes.routes.keys.should include(name)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#set_routes' do
|
175
|
+
subject { Excursion::Pool::DummyApplication.new 'test_app', {} }
|
176
|
+
|
177
|
+
context 'routes' do
|
178
|
+
it 'should be required' do
|
179
|
+
expect { subject.set_routes }.to raise_exception(ArgumentError)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should accept a Hash of named routes' do
|
183
|
+
expect { subject.set_routes({}) }.to_not raise_exception(ArgumentError)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should accept a NamedRouteCollection' do
|
187
|
+
expect { subject.set_routes ActionDispatch::Routing::RouteSet::NamedRouteCollection.new }.to_not raise_exception(ArgumentError)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should only accept a Hash or NamedRouteCollection' do
|
191
|
+
expect { subject.set_routes 'test string' }.to raise_exception(ArgumentError)
|
192
|
+
expect { subject.set_routes 123 }.to raise_exception(ArgumentError)
|
193
|
+
expect { subject.set_routes :test_symbol }.to raise_exception(ArgumentError)
|
194
|
+
expect { subject.set_routes [] }.to raise_exception(ArgumentError)
|
195
|
+
expect { subject.set_routes Object }.to raise_exception(ArgumentError)
|
196
|
+
expect { subject.set_routes Object.new }.to raise_exception(ArgumentError)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'when passing a Hash' do
|
201
|
+
it 'should override the application routes with the ones provided' do
|
202
|
+
subject.set_routes Hash[Excursion::Specs::Mocks::NAMED_ROUTES]
|
203
|
+
Excursion::Specs::Mocks::NAMED_ROUTES.each do |name,path|
|
204
|
+
subject.routes.routes.keys.should include(name)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context 'when passing a NamedRouteCollection' do
|
210
|
+
it 'should override the application routes with the ones provided' do
|
211
|
+
subject.set_routes Excursion::Specs::Mocks::NAMED_ROUTE_COLLECTION
|
212
|
+
Excursion::Specs::Mocks::NAMED_ROUTES.each do |name,path|
|
213
|
+
subject.routes.routes.keys.should include(name)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excursion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/excursion/exceptions/pool.rb
|
81
81
|
- lib/excursion/exceptions/active_record.rb
|
82
82
|
- lib/excursion/exceptions/memcache.rb
|
83
|
+
- lib/excursion/pool/dummy_application.rb
|
83
84
|
- lib/excursion/pool/application.rb
|
84
85
|
- lib/excursion/railtie.rb
|
85
86
|
- lib/excursion/configuration.rb
|
@@ -91,6 +92,7 @@ files:
|
|
91
92
|
- lib/excursion/datastores/file.rb
|
92
93
|
- lib/excursion/datastores/active_record.rb
|
93
94
|
- lib/excursion/datastores/memcache.rb
|
95
|
+
- lib/excursion/datastores/test.rb
|
94
96
|
- lib/excursion/helpers.rb
|
95
97
|
- lib/excursion/route_pool.rb
|
96
98
|
- lib/excursion/version.rb
|
@@ -141,9 +143,11 @@ files:
|
|
141
143
|
- spec/excursion/helpers_spec.rb
|
142
144
|
- spec/excursion/route_pool_spec.rb
|
143
145
|
- spec/excursion/pool/application_spec.rb
|
146
|
+
- spec/excursion/pool/dummy_application_spec.rb
|
144
147
|
- spec/excursion/pool_spec.rb
|
145
148
|
- spec/excursion/helpers/url_helper_spec.rb
|
146
149
|
- spec/excursion/helpers/application_helper_spec.rb
|
150
|
+
- spec/excursion/datastores/test_spec.rb
|
147
151
|
- spec/excursion/datastores/active_record_with_memcache_spec.rb
|
148
152
|
- spec/excursion/datastores/active_record_spec.rb
|
149
153
|
- spec/excursion/datastores/memcache_spec.rb
|
@@ -217,9 +221,11 @@ test_files:
|
|
217
221
|
- spec/excursion/helpers_spec.rb
|
218
222
|
- spec/excursion/route_pool_spec.rb
|
219
223
|
- spec/excursion/pool/application_spec.rb
|
224
|
+
- spec/excursion/pool/dummy_application_spec.rb
|
220
225
|
- spec/excursion/pool_spec.rb
|
221
226
|
- spec/excursion/helpers/url_helper_spec.rb
|
222
227
|
- spec/excursion/helpers/application_helper_spec.rb
|
228
|
+
- spec/excursion/datastores/test_spec.rb
|
223
229
|
- spec/excursion/datastores/active_record_with_memcache_spec.rb
|
224
230
|
- spec/excursion/datastores/active_record_spec.rb
|
225
231
|
- spec/excursion/datastores/memcache_spec.rb
|