Sha256: 7be84a2ddf89140067d7370aac151f0946f6339823e2a4dd49cd6a1f69485810
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
class TokenizeTo def initialize(expected_tokens) @expected_tokens = expected_tokens.map do |t| case t when SQLTree::Token then t when String then SQLTree::Token::String.new(t) when Numeric then SQLTree::Token::Number.new(t) when Symbol then SQLTree::Token.const_get(t.to_s.upcase) else "Cannot check for this token: #{t.inspect}!" end end end def matches?(found_tokens) @found_tokens = found_tokens return @found_tokens == @expected_tokens end def description "expected to tokenized to #{@expected_tokens.inspect}" end def failure_message " #{@expected_tokens.inspect} expected, but found #{@found_tokens.inspect}" end def negative_failure_message " expected not to be tokenized to #{@expected_tokens.inspect}" end end def tokenize_to(*expected_tokens) TokenizeTo.new(expected_tokens) end def sql_var(name) SQLTree::Token::Variable.new(name.to_s) end def dot SQLTree::Token::DOT end def comma SQLTree::Token::COMMA end def lparen SQLTree::Token::LPAREN end def rparen SQLTree::Token::RPAREN end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sql_tree-0.1.0 | spec/lib/matchers.rb |
sql_tree-0.0.3 | spec/lib/matchers.rb |