Permalink
Browse files

Changed not operator spec to pending

- Need to implment sorting first as it seems not recursing in the right order
  • Loading branch information...
1 parent 25b5ccf commit 9b499afb86cfb3f2fff1e9589eb40dba7f3b9b6d Makoto Inoue committed Nov 9, 2008
Showing with 27 additions and 6 deletions.
  1. +10 −4 lib/tc_adapter.rb
  2. +17 −2 spec/tc_adapater_spec.rb
View
@@ -96,17 +96,23 @@ def read_one(query)
end
when :not # TODO: Think about better way to extract, as this is going through data one by one
then
+ # NotImplementedError{"The below code is not working as order is not always correct"}
ruby_operator = "!="
- # result = ""
+ result = ""
item_id = access_data(query.model, property.name) do |item|
raw_data = BDBCUR::new(item)
raw_data.first
- while key = raw_data.key && eval("raw_data.key #{ruby_operator} value")
- result = item.get(raw_data.key)
- raw_data.next
+ while key = raw_data.key
+ if eval("raw_data.key #{ruby_operator} value")
+ result = item.get(raw_data.key)
+ break
+ else
+ raw_data.next
+ end
end
result
end
+
else
raise NotImplementedError("#{operator} is not implmented yet")
end
View
@@ -102,9 +102,15 @@
@peter = User.create(:name => 'peter', :age => 3)
@mark = User.create(:name => 'mark', :age => 5)
end
- it "should return a record for string" do
+ it "should return a record for string when non matching value comes first" do
+ pending()
User.first(:name.not => 'tom').should == @peter
end
+
+ it "should return a record for string when matching value comes first" do
+ pending()
+ User.first(:name.not => 'peter').should == @tom
+ end
it "should return a record for numeric" do
pending
User.first(:age.not => 2).should == @peter
@@ -119,7 +125,16 @@
it 'should get a record with multiple matchers'
end
describe "all" do
- it 'should get records by eql matcher'
+ before(:each) do
+ @tom = User.create(:name => 'tom', :age => 2)
+ @peter = User.create(:name => 'peter', :age => 3)
+ @mark = User.create(:name => 'mark', :age => 5)
+ @andy = User.create(:name => 'andy', :age => 5)
+ end
+ it 'should get records by eql matcher' do
+ pending
+ User.all(:age => 5).should == [@mark, @andy]
+ end
it 'should get records by not matcher'
it 'should get records by gt matcher'
it 'should get records by gte matcher'

0 comments on commit 9b499af

Please sign in to comment.