GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
reorged the path matching specs
automatthew (author)
Sun Sep 21 13:07:49 -0700 2008
commit  fa964ade5c5db00bd79064b967f25ead35d77866
tree    5574fc21f216543d5d5c615c82f00da32692c98b
parent  d699ee43267600bbdae69f542b7283cd60864743
...
1
2
3
 
 
 
 
 
 
4
5
6
7
8
9
10
11
 
 
12
13
14
15
 
 
16
17
18
19
 
 
 
 
20
21
22
23
 
 
 
24
25
26
...
31
32
33
34
35
 
 
36
37
38
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
42
43
44
 
 
45
46
47
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
 
16
17
18
19
 
 
20
21
22
23
 
 
24
25
26
27
28
 
 
 
29
30
31
32
33
34
...
39
40
41
 
 
42
43
44
45
 
 
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
 
 
62
63
64
65
66
67
68
69
70
0
@@ -1,26 +1,34 @@
0
 # require 'test_helper' because RubyMate needs help
0
 require File.join(File.dirname(__FILE__) , "helpers")
0
 
0
+Waves::Matchers::Path.module_eval do
0
+ def matches?(request)
0
+ self.call(request).kind_of?(Hash)
0
+ end
0
+end
0
+
0
 describe "A path matcher with a single string component" do
0
   
0
   before do
0
     @matcher = Waves::Matchers::Path.new( [ "smurf" ] )
0
   end
0
   
0
- it "matches a single-component url with the string" do
0
- @matcher.call(waves_request("/smurf")).should == {}
0
+ it "matches a single-component path consisting of the string" do
0
+ @matcher.matches?(waves_request("/smurf")).should == true
0
   end
0
   
0
- it "does not match a single-component url with a different string" do
0
- @matcher.call( waves_request("/bad") ).should == nil
0
+ it "does not match a single-component path with a different string" do
0
+ @matcher.matches?( waves_request("/bad") ).should == false
0
   end
0
   
0
- it "does not match a multi-component url with the string as the first component" do
0
- @matcher.call( waves_request("/smurf/close") ).should == nil
0
+ it "does not match a multi-component path" do
0
+ @matcher.matches?( waves_request("/smurf/close") ).should == false
0
+ @matcher.matches?( waves_request("/not/even/close") ).should == false
0
+ @matcher.matches?( waves_request("/not/smurf/close") ).should == false
0
   end
0
-
0
- it "does not match a multi-component url entirely without the string" do
0
- @matcher.call( waves_request("/not/even/close") ).should == nil
0
+
0
+ it "does not match '/' " do
0
+ @matcher.matches?( waves_request("/")).should == false
0
   end
0
   
0
 end
0
@@ -31,17 +39,32 @@ describe "A path matcher with multiple string components" do
0
     @matcher = Waves::Matchers::Path.new( [ "smurf", "pie" ] )
0
   end
0
   
0
- it "matches when all url components match" do
0
- @matcher.call(waves_request("/smurf/pie")).should == {}
0
+ it "matches when all path components match" do
0
+ @matcher.matches?(waves_request("/smurf/pie")).should == true
0
   end
0
   
0
- it "does not match when no url components match" do
0
- @matcher.call(waves_request("/foo/bar")).should == nil
0
+ it "does not match unless all path components match" do
0
+ @matcher.matches?(waves_request("/foo/bar")).should == false
0
+ @matcher.matches?(waves_request("/smurf")).should == false
0
+ @matcher.matches?(waves_request("/smurf/cake")).should == false
0
+ @matcher.matches?(waves_request("/smurf/pie/filling")).should == false
0
+ @matcher.matches?(waves_request("/filling/smurf/pie")).should == false
0
+ end
0
+
0
+end
0
+
0
+describe "A path matcher with a single capture component" do
0
+
0
+ before do
0
+ @matcher = Waves::Matchers::Path.new( [ :resource ] )
0
   end
0
   
0
- it "does not match when only the first component matches" do
0
- @matcher.call(waves_request("/smurf/cake")).should == nil
0
- @matcher.call(waves_request("/smurf/pie/filling")).should == nil
0
+ it "matches any single-component path" do
0
+ @matcher.matches?(waves_request("/smurf")).should == true
0
   end
0
   
0
 end
0
+
0
+
0
+
0
+

Comments

    No one has commented yet.