Permalink
Browse files

adding a test to find default regexp nodes.

  • Loading branch information...
1 parent ba53081 commit e95aeace2ada6379be36075923f2a52c561fb7db @tenderlove tenderlove committed Sep 27, 2011
Showing with 21 additions and 1 deletion.
  1. +6 −1 lib/journey/nodes/node.rb
  2. +15 −0 test/nodes/test_symbol.rb
@@ -53,9 +53,14 @@ class Symbol < Terminal
attr_accessor :regexp
alias :symbol :regexp
+ DEFAULT_EXP = /[^\.\/\?]+/
def initialize left
super
- @regexp = /[^\.\/\?]+/
+ @regexp = DEFAULT_EXP
+ end
+
+ def default_regexp?
+ regexp == DEFAULT_EXP
end
end
View
@@ -0,0 +1,15 @@
+require 'helper'
+
+module Journey
+ module Nodes
+ class TestSymbol < MiniTest::Unit::TestCase
+ def test_default_regexp?
+ sym = Symbol.new nil
+ assert sym.default_regexp?
+
+ sym.regexp = nil
+ refute sym.default_regexp?
+ end
+ end
+ end
+end

0 comments on commit e95aeac

Please sign in to comment.