0
# require 'test_helper' because RubyMate needs help
0
require File.join(File.dirname(__FILE__) , "helpers")
0
+Waves::Matchers::Path.module_eval do
0
+ self.call(request).kind_of?(Hash)
0
describe "A path matcher with a single string component" do
0
@matcher = Waves::Matchers::Path.new( [ "smurf" ] )
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
- 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
- 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
- it "does not match a multi-component url entirely without the string" do
0
- @matcher.call( waves_request("/not/even/close") ).should == nil
0
+ it "does not match '/' " do
0
+ @matcher.matches?( waves_request("/")).should == false
0
@@ -31,17 +39,32 @@ describe "A path matcher with multiple string components" do
0
@matcher = Waves::Matchers::Path.new( [ "smurf", "pie" ] )
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
- 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
+describe "A path matcher with a single capture component" do
0
+ @matcher = Waves::Matchers::Path.new( [ :resource ] )
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
Comments
No one has commented yet.