strelka 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ChangeLog +156 -9
  4. data/History.rdoc +15 -0
  5. data/IDEAS.rdoc +17 -1
  6. data/MILESTONES.rdoc +1 -1
  7. data/Manifest.txt +10 -2
  8. data/Plugins.rdoc +4 -4
  9. data/README.rdoc +3 -3
  10. data/Rakefile +5 -4
  11. data/bin/strelka +19 -10
  12. data/contrib/hoetemplate/data/project/apps/file_name_app +1 -0
  13. data/contrib/hoetemplate/lib/file_name.rb.erb +3 -2
  14. data/examples/apps/hello-world +1 -0
  15. data/examples/apps/ws-chat +69 -0
  16. data/examples/apps/ws-echo +61 -0
  17. data/examples/gen-config.rb +6 -5
  18. data/lib/strelka/app/auth.rb +2 -2
  19. data/lib/strelka/app/errors.rb +1 -1
  20. data/lib/strelka/app/filters.rb +3 -2
  21. data/lib/strelka/app/negotiation.rb +2 -2
  22. data/lib/strelka/app/parameters.rb +1 -2
  23. data/lib/strelka/app/restresources.rb +3 -2
  24. data/lib/strelka/app/routing.rb +1 -1
  25. data/lib/strelka/app/sessions.rb +2 -2
  26. data/lib/strelka/app/templating.rb +7 -3
  27. data/lib/strelka/app.rb +5 -145
  28. data/lib/strelka/behavior/plugin.rb +4 -4
  29. data/lib/strelka/discovery.rb +211 -0
  30. data/lib/strelka/httprequest.rb +1 -0
  31. data/lib/strelka/httpresponse/negotiation.rb +7 -1
  32. data/lib/strelka/mixins.rb +4 -1
  33. data/lib/strelka/paramvalidator.rb +1 -1
  34. data/lib/strelka/plugins.rb +8 -6
  35. data/lib/strelka/websocketserver/routing.rb +116 -0
  36. data/lib/strelka/websocketserver.rb +147 -0
  37. data/lib/strelka.rb +5 -4
  38. data/spec/{lib/constants.rb → constants.rb} +3 -2
  39. data/spec/{lib/helpers.rb → helpers.rb} +15 -14
  40. data/spec/strelka/app/auth_spec.rb +145 -142
  41. data/spec/strelka/app/errors_spec.rb +20 -26
  42. data/spec/strelka/app/filters_spec.rb +67 -54
  43. data/spec/strelka/app/negotiation_spec.rb +8 -14
  44. data/spec/strelka/app/parameters_spec.rb +23 -29
  45. data/spec/strelka/app/restresources_spec.rb +98 -100
  46. data/spec/strelka/app/routing_spec.rb +57 -57
  47. data/spec/strelka/app/sessions_spec.rb +11 -17
  48. data/spec/strelka/app/templating_spec.rb +36 -40
  49. data/spec/strelka/app_spec.rb +48 -147
  50. data/spec/strelka/authprovider/basic_spec.rb +5 -11
  51. data/spec/strelka/authprovider/hostaccess_spec.rb +9 -15
  52. data/spec/strelka/authprovider_spec.rb +3 -9
  53. data/spec/strelka/cookie_spec.rb +32 -38
  54. data/spec/strelka/cookieset_spec.rb +31 -37
  55. data/spec/strelka/discovery_spec.rb +144 -0
  56. data/spec/strelka/exceptions_spec.rb +2 -8
  57. data/spec/strelka/httprequest/acceptparams_spec.rb +74 -83
  58. data/spec/strelka/httprequest/auth_spec.rb +5 -15
  59. data/spec/strelka/httprequest/negotiation_spec.rb +93 -103
  60. data/spec/strelka/httprequest/session_spec.rb +12 -22
  61. data/spec/strelka/httprequest_spec.rb +1 -7
  62. data/spec/strelka/httpresponse/negotiation_spec.rb +84 -76
  63. data/spec/strelka/httpresponse/session_spec.rb +25 -35
  64. data/spec/strelka/httpresponse_spec.rb +20 -26
  65. data/spec/strelka/mixins_spec.rb +66 -61
  66. data/spec/strelka/multipartparser_spec.rb +31 -37
  67. data/spec/strelka/paramvalidator_spec.rb +389 -373
  68. data/spec/strelka/plugins_spec.rb +17 -23
  69. data/spec/strelka/router/default_spec.rb +32 -38
  70. data/spec/strelka/router/exclusive_spec.rb +28 -34
  71. data/spec/strelka/router_spec.rb +2 -8
  72. data/spec/strelka/session/db_spec.rb +17 -15
  73. data/spec/strelka/session/default_spec.rb +22 -28
  74. data/spec/strelka/session_spec.rb +3 -9
  75. data/spec/strelka/websocketserver/routing_spec.rb +119 -0
  76. data/spec/strelka/websocketserver_spec.rb +149 -0
  77. data/spec/strelka_spec.rb +11 -13
  78. data.tar.gz.sig +3 -3
  79. metadata +22 -14
  80. metadata.gz.sig +0 -0
@@ -2,16 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
8
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
9
- }
5
+ require_relative '../helpers'
10
6
 
11
7
  require 'rspec'
12
8
 
13
- require 'spec/lib/helpers'
14
-
15
9
  require 'strelka'
16
10
  require 'strelka/plugins'
17
11
 
@@ -80,7 +74,7 @@ describe "Strelka plugin system" do
80
74
  end
81
75
 
82
76
  it "registers itself with a plugin registry" do
83
- Strelka::Pluggable.loaded_plugins.should include( @plugin.plugin_name => @plugin )
77
+ expect( Strelka::Pluggable.loaded_plugins ).to include( @plugin.plugin_name => @plugin )
84
78
  end
85
79
 
86
80
 
@@ -91,7 +85,7 @@ describe "Strelka plugin system" do
91
85
  @before_mod = Module.new do
92
86
  def self::name; "Strelka::Pluggable::BeforeTestPlugin"; end
93
87
  extend Strelka::Plugin
94
- run_before( modname )
88
+ run_outside( modname )
95
89
  end
96
90
  end
97
91
 
@@ -110,7 +104,7 @@ describe "Strelka plugin system" do
110
104
  @after_mod = Module.new do
111
105
  def self::name; "Strelka::Pluggable::AfterTestPlugin"; end
112
106
  extend Strelka::Plugin
113
- run_after( modname )
107
+ run_inside( modname )
114
108
  end
115
109
  end
116
110
 
@@ -128,7 +122,7 @@ describe "Strelka plugin system" do
128
122
  context "loading" do
129
123
 
130
124
  it "requires plugins from a directory based on the name of the loader" do
131
- Strelka::Pluggable.should_receive( :require ).
125
+ expect( Strelka::Pluggable ).to receive( :require ).
132
126
  with( 'strelka/pluggable/scheduler' ).
133
127
  and_return do
134
128
  Module.new do
@@ -152,7 +146,7 @@ describe "Strelka plugin system" do
152
146
  app = Class.new( Strelka::Pluggable )
153
147
  app.register_plugin( plugin )
154
148
 
155
- app.a_class_method.should == "yep."
149
+ expect( app.a_class_method ).to eq( "yep." )
156
150
  end
157
151
 
158
152
  it "adds class-instance variables to the class if the plugin has them" do
@@ -168,9 +162,9 @@ describe "Strelka plugin system" do
168
162
  app = Class.new( Strelka::Pluggable )
169
163
  app.register_plugin( plugin )
170
164
 
171
- app.testing_value.should == :default
165
+ expect( app.testing_value ).to eq( :default )
172
166
  app.testing_value = :not_the_default
173
- app.testing_value.should == :not_the_default
167
+ expect( app.testing_value ).to eq( :not_the_default )
174
168
  end
175
169
 
176
170
  it "adds class-instance variables to the class if the plugin has them" do
@@ -187,7 +181,7 @@ describe "Strelka plugin system" do
187
181
  app.instance_variable_set( :@testing_value, :pre_existing_value )
188
182
  app.register_plugin( plugin )
189
183
 
190
- app.testing_value.should == :pre_existing_value
184
+ expect( app.testing_value ).to eq( :pre_existing_value )
191
185
  end
192
186
 
193
187
  end
@@ -210,7 +204,7 @@ describe "Strelka plugin system" do
210
204
  @templating_plugin = Module.new do
211
205
  def self::name; "Strelka::Pluggable::Templating"; end
212
206
  extend Strelka::Plugin
213
- run_before :routing
207
+ run_outside :routing
214
208
  end
215
209
  end
216
210
 
@@ -221,7 +215,7 @@ describe "Strelka plugin system" do
221
215
  end
222
216
  klass.install_plugins
223
217
 
224
- klass.ancestors.should include( @routing_plugin )
218
+ expect( klass.ancestors ).to include( @routing_plugin )
225
219
  end
226
220
 
227
221
  it "can declare a list of plugins to load" do
@@ -229,7 +223,7 @@ describe "Strelka plugin system" do
229
223
  plugins :templating, :routing
230
224
  end
231
225
  klass.install_plugins
232
- klass.ancestors.should include( @routing_plugin, @templating_plugin )
226
+ expect( klass.ancestors ).to include( @routing_plugin, @templating_plugin )
233
227
  end
234
228
 
235
229
  it "has an introspection method for examining the list of loaded plugins" do
@@ -237,7 +231,7 @@ describe "Strelka plugin system" do
237
231
  plugins :templating, :routing
238
232
  end
239
233
  klass.install_plugins
240
- klass.application_stack.should == [ @templating_plugin, @routing_plugin ]
234
+ expect( klass.application_stack ).to eq( [ @templating_plugin, @routing_plugin ] )
241
235
  end
242
236
 
243
237
 
@@ -250,16 +244,16 @@ describe "Strelka plugin system" do
250
244
  end
251
245
  subclass.install_plugins
252
246
 
253
- subclass.ancestors.should order( @templating_plugin ).before( @routing_plugin )
247
+ expect( subclass.ancestors ).to order( @templating_plugin ).before( @routing_plugin )
254
248
  end
255
249
 
256
250
  it "adds information about where plugins were installed" do
257
251
  klass = Class.new( Strelka::Pluggable ) do
258
252
  plugin :routing
259
253
  end
260
- klass.plugins_installed_from.should be_nil()
254
+ expect( klass.plugins_installed_from ).to be_nil()
261
255
  klass.install_plugins
262
- klass.plugins_installed_from.should =~ /#{__FILE__}:#{__LINE__ - 1}/
256
+ expect( klass.plugins_installed_from ).to match( /#{__FILE__}:#{__LINE__ - 1}/ )
263
257
  end
264
258
 
265
259
  it "are inherited by subclasses" do
@@ -270,7 +264,7 @@ describe "Strelka plugin system" do
270
264
  route_some_stuff
271
265
  end
272
266
 
273
- subclass.routed.should be_true()
267
+ expect( subclass.routed ).to be_true()
274
268
  end
275
269
 
276
270
  end
@@ -2,16 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
8
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
9
- }
5
+ require_relative '../../helpers'
10
6
 
11
7
  require 'rspec'
12
8
 
13
- require 'spec/lib/helpers'
14
-
15
9
  require 'strelka'
16
10
  require 'strelka/router/default'
17
11
 
@@ -46,37 +40,37 @@ describe Strelka::Router::Default do
46
40
 
47
41
  it "routes GET /user/foo/bar/baz to the GET foo/bar action" do
48
42
  req = @request_factory.get( '/user/foo/bar/baz' )
49
- @router.route_request( req ).should match_route( :GET_foo_bar )
43
+ expect( @router.route_request(req) ).to match_route( :GET_foo_bar )
50
44
  end
51
45
 
52
46
  it "routes GET /user/foo/bar to the GET foo/bar action" do
53
47
  req = @request_factory.get( '/user/foo/bar' )
54
- @router.route_request( req ).should match_route( :GET_foo_bar )
48
+ expect( @router.route_request(req) ).to match_route( :GET_foo_bar )
55
49
  end
56
50
 
57
51
  it "routes GET /user/foo to the GET foo action" do
58
52
  req = @request_factory.get( '/user/foo' )
59
- @router.route_request( req ).should match_route( :GET_foo )
53
+ expect( @router.route_request(req) ).to match_route( :GET_foo )
60
54
  end
61
55
 
62
56
  it "doesn't route GET /user" do
63
57
  req = @request_factory.get( '/user' )
64
- @router.route_request( req ).should be_nil()
58
+ expect( @router.route_request(req) ).to be_nil()
65
59
  end
66
60
 
67
61
  it "doesn't route GET /user/something/foo/bar" do
68
62
  req = @request_factory.get( '/user/something/foo/bar' )
69
- @router.route_request( req ).should be_nil()
63
+ expect( @router.route_request(req) ).to be_nil()
70
64
  end
71
65
 
72
66
  it "doesn't route GET /user/other" do
73
67
  req = @request_factory.get( '/user/other' )
74
- @router.route_request( req ).should be_nil()
68
+ expect( @router.route_request(req) ).to be_nil()
75
69
  end
76
70
 
77
71
  it "routes HEAD requests to the GET route" do
78
72
  req = @request_factory.head( '/user/foo' )
79
- @router.route_request( req ).should match_route( :GET_foo )
73
+ expect( @router.route_request(req) ).to match_route( :GET_foo )
80
74
  end
81
75
 
82
76
  it "responds with a 405 (method not allowed) for a DELETE request to /user/foo" do
@@ -107,27 +101,27 @@ describe Strelka::Router::Default do
107
101
 
108
102
  it "routes /user/foo/bar/baz to the foo/bar action" do
109
103
  req = @request_factory.get( '/user/foo/bar/baz' )
110
- @router.route_request( req ).should match_route( :foo_bar )
104
+ expect( @router.route_request(req) ).to match_route( :foo_bar )
111
105
  end
112
106
 
113
107
  it "routes /user/foo/bar to the foo/bar action" do
114
108
  req = @request_factory.get( '/user/foo/bar' )
115
- @router.route_request( req ).should match_route( :foo_bar )
109
+ expect( @router.route_request(req) ).to match_route( :foo_bar )
116
110
  end
117
111
 
118
112
  it "routes /user/foo to the foo action" do
119
113
  req = @request_factory.get( '/user/foo' )
120
- @router.route_request( req ).should match_route( :foo )
114
+ expect( @router.route_request(req) ).to match_route( :foo )
121
115
  end
122
116
 
123
117
  it "routes /user to the fallback action" do
124
118
  req = @request_factory.get( '/user' )
125
- @router.route_request( req ).should match_route( :fallback )
119
+ expect( @router.route_request(req) ).to match_route( :fallback )
126
120
  end
127
121
 
128
122
  it "routes /user/other to the fallback action" do
129
123
  req = @request_factory.get( '/user/other' )
130
- @router.route_request( req ).should match_route( :fallback )
124
+ expect( @router.route_request(req) ).to match_route( :fallback )
131
125
  end
132
126
 
133
127
  end
@@ -142,37 +136,37 @@ describe Strelka::Router::Default do
142
136
 
143
137
  it "routes /user/foo/barbim/baz to the foo/\w{6} action" do
144
138
  req = @request_factory.get( '/user/foo/barbim/baz' )
145
- @router.route_request( req ).should match_route( :foo_six )
139
+ expect( @router.route_request(req) ).to match_route( :foo_six )
146
140
  end
147
141
 
148
142
  it "routes /user/foo/barbat to the foo/\w{6} action" do
149
143
  req = @request_factory.get( '/user/foo/barbat' )
150
- @router.route_request( req ).should match_route( :foo_six )
144
+ expect( @router.route_request(req) ).to match_route( :foo_six )
151
145
  end
152
146
 
153
147
  it "routes /user/foo/bar/baz to the foo/\w{3} action" do
154
148
  req = @request_factory.get( '/user/foo/bar/baz' )
155
- @router.route_request( req ).should match_route( :foo_three )
149
+ expect( @router.route_request(req) ).to match_route( :foo_three )
156
150
  end
157
151
 
158
152
  it "routes /user/foo/bar to the foo/\w{3} action" do
159
153
  req = @request_factory.get( '/user/foo/bar' )
160
- @router.route_request( req ).should match_route( :foo_three )
154
+ expect( @router.route_request(req) ).to match_route( :foo_three )
161
155
  end
162
156
 
163
157
  it "routes /user/foo to the foo action" do
164
158
  req = @request_factory.get( '/user/foo' )
165
- @router.route_request( req ).should match_route( :foo )
159
+ expect( @router.route_request(req) ).to match_route( :foo )
166
160
  end
167
161
 
168
162
  it "doesn't route /user" do
169
163
  req = @request_factory.get( '/user' )
170
- @router.route_request( req ).should be_nil()
164
+ expect( @router.route_request(req) ).to be_nil()
171
165
  end
172
166
 
173
167
  it "doesn't route /user/other" do
174
168
  req = @request_factory.get( '/user/other' )
175
- @router.route_request( req ).should be_nil()
169
+ expect( @router.route_request(req) ).to be_nil()
176
170
  end
177
171
 
178
172
  end
@@ -189,22 +183,22 @@ describe Strelka::Router::Default do
189
183
 
190
184
  it "routes /user/foo/1 to the foo/\d+ action" do
191
185
  req = @request_factory.get( '/user/foo/1' )
192
- @router.route_request( req ).should match_route( :foo_digit )
186
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
193
187
  end
194
188
 
195
189
  it "routes /user/foo/12 to the foo/\d+ action" do
196
190
  req = @request_factory.get( '/user/foo/12' )
197
- @router.route_request( req ).should match_route( :foo_digit )
191
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
198
192
  end
199
193
 
200
194
  it "routes /user/foo/123 to the foo/\w{3} action" do
201
195
  req = @request_factory.get( '/user/foo/123' )
202
- @router.route_request( req ).should match_route( :foo_three )
196
+ expect( @router.route_request(req) ).to match_route( :foo_three )
203
197
  end
204
198
 
205
199
  it "routes /user/foo/1234 to the foo/\d+ action" do
206
200
  req = @request_factory.get( '/user/foo/1234' )
207
- @router.route_request( req ).should match_route( :foo_digit )
201
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
208
202
  end
209
203
 
210
204
  end
@@ -221,22 +215,22 @@ describe Strelka::Router::Default do
221
215
 
222
216
  it "routes /user/foo/1 to the foo/\d+ action" do
223
217
  req = @request_factory.get( '/user/foo/1' )
224
- @router.route_request( req ).should match_route( :foo_digit )
218
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
225
219
  end
226
220
 
227
221
  it "routes /user/foo/12 to the foo/\d+ action" do
228
222
  req = @request_factory.get( '/user/foo/12' )
229
- @router.route_request( req ).should match_route( :foo_digit )
223
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
230
224
  end
231
225
 
232
226
  it "routes /user/foo/123 to the foo/\d+ action" do
233
227
  req = @request_factory.get( '/user/foo/123' )
234
- @router.route_request( req ).should match_route( :foo_digit )
228
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
235
229
  end
236
230
 
237
231
  it "routes /user/foo/1234 to the foo/\d+ action" do
238
232
  req = @request_factory.get( '/user/foo/1234' )
239
- @router.route_request( req ).should match_route( :foo_digit )
233
+ expect( @router.route_request(req) ).to match_route( :foo_digit )
240
234
  end
241
235
 
242
236
  end
@@ -250,22 +244,22 @@ describe Strelka::Router::Default do
250
244
 
251
245
  it "routes /user/foo/1 to the foo action" do
252
246
  req = @request_factory.get( '/user/foo/1' )
253
- @router.route_request( req ).should match_route( :foo )
247
+ expect( @router.route_request(req) ).to match_route( :foo )
254
248
  end
255
249
 
256
250
  it "routes /foo.pdf to the regexp action" do
257
251
  req = @request_factory.get( '/user/foo.pdf' )
258
- @router.route_request( req ).should match_route( :as_pdf )
252
+ expect( @router.route_request(req) ).to match_route( :as_pdf )
259
253
  end
260
254
 
261
255
  it "doesn't route /foo%1B.pdf to the regexp action" do
262
256
  req = @request_factory.get( "/user/foo%1B.pdf" )
263
- @router.route_request( req ).should_not match_route( :as_pdf )
257
+ expect( @router.route_request(req) ).to_not match_route( :as_pdf )
264
258
  end
265
259
 
266
260
  it "routes /zanzibar.pdf to the regexp action" do
267
261
  req = @request_factory.get( '/user/zanzibar.pdf' )
268
- @router.route_request( req ).should match_route( :as_pdf )
262
+ expect( @router.route_request(req) ).to match_route( :as_pdf )
269
263
  end
270
264
 
271
265
  end
@@ -2,16 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
8
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
9
- }
5
+ require_relative '../../helpers'
10
6
 
11
7
  require 'rspec'
12
8
 
13
- require 'spec/lib/helpers'
14
-
15
9
  require 'strelka'
16
10
  require 'strelka/router/exclusive'
17
11
 
@@ -44,32 +38,32 @@ describe Strelka::Router::Exclusive do
44
38
 
45
39
  it "doesn't route /user/foo/bar/baz" do
46
40
  req = @request_factory.get( '/user/foo/bar/baz' )
47
- @router.route_request( req ).should be_nil()
41
+ expect( @router.route_request(req) ).to be_nil()
48
42
  end
49
43
 
50
44
  it "routes /user/foo/bar to the foo/bar action" do
51
45
  req = @request_factory.get( '/user/foo/bar' )
52
- @router.route_request( req ).should match_route( :GET_foo_bar )
46
+ expect( @router.route_request(req) ).to match_route( :GET_foo_bar )
53
47
  end
54
48
 
55
49
  it "routes /user/foo/bar?limit=10 to the foo/bar action" do
56
50
  req = @request_factory.get( '/user/foo/bar?limit=10' )
57
- @router.route_request( req ).should match_route( :GET_foo_bar )
51
+ expect( @router.route_request(req) ).to match_route( :GET_foo_bar )
58
52
  end
59
53
 
60
54
  it "routes /user/foo to the foo action" do
61
55
  req = @request_factory.get( '/user/foo' )
62
- @router.route_request( req ).should match_route( :GET_foo )
56
+ expect( @router.route_request(req) ).to match_route( :GET_foo )
63
57
  end
64
58
 
65
59
  it "doesn't route /user" do
66
60
  req = @request_factory.get( '/user' )
67
- @router.route_request( req ).should be_nil()
61
+ expect( @router.route_request(req) ).to be_nil()
68
62
  end
69
63
 
70
64
  it "doesn't route /user/other" do
71
65
  req = @request_factory.get( '/user/other' )
72
- @router.route_request( req ).should be_nil()
66
+ expect( @router.route_request(req) ).to be_nil()
73
67
  end
74
68
 
75
69
  end
@@ -85,32 +79,32 @@ describe Strelka::Router::Exclusive do
85
79
 
86
80
  it "doesn't route GET /user/foo/bar/baz" do
87
81
  req = @request_factory.get( '/user/foo/bar/baz' )
88
- @router.route_request( req ).should be_nil()
82
+ expect( @router.route_request(req) ).to be_nil()
89
83
  end
90
84
 
91
85
  it "routes GET /user/foo/bar to the GET foo/bar action" do
92
86
  req = @request_factory.get( '/user/foo/bar' )
93
- @router.route_request( req ).should match_route( :GET_foo_bar )
87
+ expect( @router.route_request(req) ).to match_route( :GET_foo_bar )
94
88
  end
95
89
 
96
90
  it "routes POST /user/foo/bar to the POST foor/bar action" do
97
91
  req = @request_factory.post( '/user/foo/bar' )
98
- @router.route_request( req ).should match_route( :POST_foo_bar )
92
+ expect( @router.route_request(req) ).to match_route( :POST_foo_bar )
99
93
  end
100
94
 
101
95
  it "routes GET /user/foo to the GET foo action" do
102
96
  req = @request_factory.get( '/user/foo' )
103
- @router.route_request( req ).should match_route( :GET_foo )
97
+ expect( @router.route_request(req) ).to match_route( :GET_foo )
104
98
  end
105
99
 
106
100
  it "routes GET /user to the fallback action" do
107
101
  req = @request_factory.get( '/user' )
108
- @router.route_request( req ).should match_route( :fallback )
102
+ expect( @router.route_request(req) ).to match_route( :fallback )
109
103
  end
110
104
 
111
105
  it "doesn't route GET /user/other" do
112
106
  req = @request_factory.get( '/user/other' )
113
- @router.route_request( req ).should be_nil()
107
+ expect( @router.route_request(req) ).to be_nil()
114
108
  end
115
109
 
116
110
  it "responds with an HTTP::METHOD_NOT_ALLOWED for a POST to /user/foo" do
@@ -140,37 +134,37 @@ describe Strelka::Router::Exclusive do
140
134
 
141
135
  it "doesn't route /user/foo/barbim/baz" do
142
136
  req = @request_factory.get( '/user/foo/barbim/baz' )
143
- @router.route_request( req ).should be_nil()
137
+ expect( @router.route_request(req) ).to be_nil()
144
138
  end
145
139
 
146
140
  it "routes /user/foo/barbat to the foo/\w{6} action" do
147
141
  req = @request_factory.get( '/user/foo/barbat' )
148
- @router.route_request( req ).should match_route( :GET_foo_six )
142
+ expect( @router.route_request(req) ).to match_route( :GET_foo_six )
149
143
  end
150
144
 
151
145
  it "doesn't route /user/foo/bar/baz" do
152
146
  req = @request_factory.get( '/user/foo/bar/baz' )
153
- @router.route_request( req ).should be_nil()
147
+ expect( @router.route_request(req) ).to be_nil()
154
148
  end
155
149
 
156
150
  it "routes /user/foo/bar to the foo/\w{3} action" do
157
151
  req = @request_factory.get( '/user/foo/bar' )
158
- @router.route_request( req ).should match_route( :GET_foo_three )
152
+ expect( @router.route_request(req) ).to match_route( :GET_foo_three )
159
153
  end
160
154
 
161
155
  it "routes /user/foo to the foo action" do
162
156
  req = @request_factory.get( '/user/foo' )
163
- @router.route_request( req ).should match_route( :GET_foo )
157
+ expect( @router.route_request(req) ).to match_route( :GET_foo )
164
158
  end
165
159
 
166
160
  it "doesn't route /user" do
167
161
  req = @request_factory.get( '/user' )
168
- @router.route_request( req ).should be_nil()
162
+ expect( @router.route_request(req) ).to be_nil()
169
163
  end
170
164
 
171
165
  it "doesn't route /user/other" do
172
166
  req = @request_factory.get( '/user/other' )
173
- @router.route_request( req ).should be_nil()
167
+ expect( @router.route_request(req) ).to be_nil()
174
168
  end
175
169
 
176
170
  end
@@ -187,22 +181,22 @@ describe Strelka::Router::Exclusive do
187
181
 
188
182
  it "routes /user/foo/1 to the foo/\d+ action" do
189
183
  req = @request_factory.get( '/user/foo/1' )
190
- @router.route_request( req ).should match_route( :GET_foo_digit )
184
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
191
185
  end
192
186
 
193
187
  it "routes /user/foo/12 to the foo/\d+ action" do
194
188
  req = @request_factory.get( '/user/foo/12' )
195
- @router.route_request( req ).should match_route( :GET_foo_digit )
189
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
196
190
  end
197
191
 
198
192
  it "routes /user/foo/123 to the foo/\w{3} action" do
199
193
  req = @request_factory.get( '/user/foo/123' )
200
- @router.route_request( req ).should match_route( :GET_foo_three )
194
+ expect( @router.route_request(req) ).to match_route( :GET_foo_three )
201
195
  end
202
196
 
203
197
  it "routes /user/foo/1234 to the foo/\d+ action" do
204
198
  req = @request_factory.get( '/user/foo/1234' )
205
- @router.route_request( req ).should match_route( :GET_foo_digit )
199
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
206
200
  end
207
201
 
208
202
  end
@@ -219,22 +213,22 @@ describe Strelka::Router::Exclusive do
219
213
 
220
214
  it "routes /user/foo/1 to the foo/\d+ action" do
221
215
  req = @request_factory.get( '/user/foo/1' )
222
- @router.route_request( req ).should match_route( :GET_foo_digit )
216
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
223
217
  end
224
218
 
225
219
  it "routes /user/foo/12 to the foo/\d+ action" do
226
220
  req = @request_factory.get( '/user/foo/12' )
227
- @router.route_request( req ).should match_route( :GET_foo_digit )
221
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
228
222
  end
229
223
 
230
224
  it "routes /user/foo/123 to the foo/\d+ action" do
231
225
  req = @request_factory.get( '/user/foo/123' )
232
- @router.route_request( req ).should match_route( :GET_foo_digit )
226
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
233
227
  end
234
228
 
235
229
  it "routes /user/foo/1234 to the foo/\d+ action" do
236
230
  req = @request_factory.get( '/user/foo/1234' )
237
- @router.route_request( req ).should match_route( :GET_foo_digit )
231
+ expect( @router.route_request(req) ).to match_route( :GET_foo_digit )
238
232
  end
239
233
 
240
234
  end
@@ -2,16 +2,10 @@
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
  # encoding: utf-8
4
4
 
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
8
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
9
- }
5
+ require_relative '../helpers'
10
6
 
11
7
  require 'rspec'
12
8
 
13
- require 'spec/lib/helpers'
14
-
15
9
  require 'strelka'
16
10
  require 'strelka/router'
17
11
 
@@ -33,7 +27,7 @@ describe Strelka::Router do
33
27
 
34
28
 
35
29
  it "looks for plugins under strelka/router" do
36
- Strelka::Router.plugin_prefixes.should include( 'strelka/router' )
30
+ expect( Strelka::Router.plugin_prefixes ).to include( 'strelka/router' )
37
31
  end
38
32
 
39
33
 
@@ -1,16 +1,10 @@
1
1
  # -*- rspec -*-
2
2
  # vim: set nosta noet ts=4 sw=4:
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent
7
- $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
8
- }
4
+ require_relative '../../helpers'
9
5
 
10
6
  require 'rspec'
11
7
 
12
- require 'spec/lib/helpers'
13
-
14
8
  require 'strelka'
15
9
  require 'strelka/session/db'
16
10
 
@@ -54,14 +48,21 @@ describe Strelka::Session::Db do
54
48
  end
55
49
 
56
50
 
51
+ RSpec::Matchers.define( :contain_table ) do |tablename|
52
+ match do |db|
53
+ db.table_exists?( tablename )
54
+ end
55
+ end
56
+
57
+
57
58
  it "creates the database if needed" do
58
- described_class.db.table_exists?( :sessions ).should be_true()
59
+ expect( described_class.db ).to contain_table( :sessions )
59
60
  end
60
61
 
61
62
 
62
63
  it "can change the default table name" do
63
64
  described_class.configure( @default_config.merge(:table_name => :brothy) )
64
- described_class.db.table_exists?( :brothy ).should be_true()
65
+ expect( described_class.db ).to contain_table( :brothy )
65
66
  described_class.db.drop_table( :brothy )
66
67
  end
67
68
 
@@ -73,7 +74,7 @@ describe Strelka::Session::Db do
73
74
  :session => @session_data.to_yaml )
74
75
 
75
76
  session = described_class.load( @session_id )
76
- session.namespaced_hash.should == @session_data
77
+ expect( session.namespaced_hash ).to eq( @session_data )
77
78
  end
78
79
 
79
80
 
@@ -84,7 +85,7 @@ describe Strelka::Session::Db do
84
85
 
85
86
  session_cookie = "%s=%s" % [ @cookie_name, @session_id ]
86
87
  req = @request_factory.get( '/frothy/gymkata', :cookie => session_cookie )
87
- described_class.should have_session_for( req )
88
+ expect( described_class ).to have_session_for( req )
88
89
  end
89
90
 
90
91
 
@@ -95,9 +96,10 @@ describe Strelka::Session::Db do
95
96
  session.save( response )
96
97
 
97
98
  row = session.class.dataset.filter( :session_id => @session_id ).first
98
- row[ :session_id ].should == @session_id
99
- row[ :session ].should =~ /hurrrg: true/
100
- row[ :created ].to_s.should =~ /\d{4}-\d{2}-\d{2}/
101
- response.header_data.should =~ /Set-Cookie: #{@cookie_name}=#{@session_id}/i
99
+
100
+ expect( row[ :session_id ] ).to eq( @session_id )
101
+ expect( row[ :session ] ).to match( /hurrrg: true/ )
102
+ expect( row[ :created ].to_s ).to match( /\d{4}-\d{2}-\d{2}/ )
103
+ expect( response.header_data ).to match( /Set-Cookie: #{@cookie_name}=#{@session_id}/i )
102
104
  end
103
105
  end