20 lines
525 B
Ruby
20 lines
525 B
Ruby
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||
|
|
||
|
describe "Term#new" do
|
||
|
it "takes a field, a operator and a value" do
|
||
|
t = Polecat::Term.new :id, :eq, 23
|
||
|
t.field.should be(:id)
|
||
|
t.operator.should be(:eq)
|
||
|
t.value.should be(23)
|
||
|
end
|
||
|
|
||
|
it "converts Strings to Regexps, if the operator is :eq" do
|
||
|
t = Polecat::Term.new :name, :eq, "foo"
|
||
|
t.value.should == /^foo$/
|
||
|
end
|
||
|
|
||
|
it "raises an error if no argument is given" do
|
||
|
lambda { Polecat::Term.new }.should raise_error
|
||
|
end
|
||
|
end
|