Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

many improvements to right_aws SDB adapter... now uses the SDB.select…

… method opposed to depricated query and query with attrs
  • Loading branch information...
commit d6f181ba919cc298eb98d9f6f60758ef0fcf3a4f 1 parent 8f38022
Dan Mayer authored
View
11 Rakefile
@@ -3,6 +3,7 @@ require 'spec'
require 'spec/rake/spectask'
require 'pathname'
require "rake/gempackagetask"
+require 'devver'
ROOT = Pathname(__FILE__).dirname.expand_path
require ROOT + 'lib/simpledb_adapter'
@@ -26,6 +27,14 @@ Spec::Rake::SpecTask.new(:spec) do |t|
end
end
+desc 'Run specifications without Rcov'
+Spec::Rake::SpecTask.new(:spec_no_rcov) do |t|
+ if File.exists?('spec/spec.opts')
+ t.spec_opts << '--options' << 'spec/spec.opts'
+ end
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
+end
+
spec = Gem::Specification.new do |s|
s.name = "dm-adapter-simpledb"
@@ -55,4 +64,4 @@ task :gemspec do
File.open("dm-adapter-simpledb.gemspec", "w") do |file|
file.puts spec.to_ruby
end
-end
+end
View
3  aws_config.sample
@@ -0,0 +1,3 @@
+1_YOUR_ACCESS_KEY_2
+I_YOUR_SECRET_KEY_0
+
View
36 lib/simpledb_adapter.rb
@@ -35,11 +35,11 @@ def read_many(query)
conditions = set_conditions(query, sdb_type)
order = set_sort_order(query, conditions)
results = get_results(query, conditions, order)
-
+
Collection.new(query) do |collection|
results.each do |result|
data = query.fields.map do |property|
- value = result[:attributes][property.field.to_s]
+ value = result.values[0][property.field.to_s]
if value != nil
if value.size > 1
value.map {|v| property.typecast(v) }
@@ -81,7 +81,7 @@ def domain
#sets the conditions for the SDB query
def set_conditions(query, sdb_type)
- conditions = ["['simpledb_type' = '#{sdb_type}']"]
+ conditions = ["simpledb_type = '#{sdb_type}'"]
if query.conditions.size > 0
conditions += query.conditions.map do |condition|
operator = case condition[0]
@@ -93,7 +93,7 @@ def set_conditions(query, sdb_type)
when :lte then '<='
else raise "Invalid query operator: #{operator.inspect}"
end
- "['#{condition[1].name.to_s}' #{operator} '#{condition[2].to_s}']"
+ "#{condition[1].name.to_s} #{operator} '#{condition[2].to_s}'"
end
end
conditions
@@ -103,8 +103,9 @@ def set_conditions(query, sdb_type)
def set_sort_order(query, conditions)
if query.order!=nil && query.order.length > 0
query_object = query.order[0]
- conditions << "['#{query_object.property.name.to_s}'> '']" #anything sorted on must be a condition
- order = "sort '#{query_object.property.name.to_s}' #{query_object.direction==:desc ? 'DESC' : 'ASC'}"
+ #anything sorted on must be a condition for SDB
+ conditions << "#{query_object.property.name.to_s} > ''"
+ order = "order by #{query_object.property.name.to_s} #{query_object.direction==:desc ? 'desc' : 'asc'}"
else
order = ""
end
@@ -112,21 +113,14 @@ def set_sort_order(query, conditions)
#gets all results or proper number of results depending on the :limit
def get_results(query, conditions, order)
- results = sdb.query(domain, "#{conditions.compact.join(' intersection ')} #{order}")
- if query.limit!=nil && query.limit <= results[:items].length
- results[:items] = results[:items][0...query.limit]
- else
- sdb_continuation_key = results[:next_token]
- #this means there are more results to retrieve from SDB
- while (sdb_continuation_key!=nil) do
- old_results = results
- results = sdb.query(domain, "#{conditions.compact.join(' intersection ')} #{order}", nil, sdb_continuation_key)
- results[:items] = old_results[:items] + results[:items]
- sdb_continuation_key = results[:next_token]
- end
- end
- #todo use newer SDB batch get attributes
- results = results[:items].map {|d| sdb.get_attributes(domain, d) }
+
+ #TODO add support for continuation keys (again)
+ query_call = "select * from #{domain} "
+ query_call = query_call + "where #{conditions.compact.join(' and ')}" if conditions.length > 0
+ query_call = query_call + " #{order}"
+ query_call = query_call + " limit #{query.limit}" if query.limit!=nil
+ results = sdb.select(query_call)
+ results = results[:items]
end
# Creates an item name for a query
View
16 spec/associations_spec.rb
@@ -0,0 +1,16 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+require 'ruby-debug'
+
+describe 'associations' do
+ it 'should work with belongs_to associations'
+ it 'should work with has n associations'
+end
+
+describe 'STI' do
+ it 'should override default type'
+ it 'should load descendents on parent.all'
+ it 'should raise an error if you have a column named couchdb_type'
+end
+
+
View
52 spec/date_spec.rb
@@ -0,0 +1,52 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+
+class Professor
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+end
+
+describe 'with multiple records saved' do
+ before(:each) do
+ @person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today }
+ @jeremy = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
+ @danielle = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26))
+ @keegan = Professor.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20))
+ sleep(0.4) #or the get calls might not have these created yet
+ end
+
+ after(:each) do
+ @jeremy.destroy
+ @danielle.destroy
+ @keegan.destroy
+ sleep(0.4) #or might not be destroyed by the next test
+ end
+
+ it 'should handle DateTime' do
+ pending 'Need to figure out how to coerce DateTime'
+ time = Time.now
+ @jeremy.created_at = time
+ @jeremy.save
+ sleep(0.2)
+ person = Professor.get!(@jeremy.id, @jeremy.name)
+ person.created_at.should == time
+ end
+
+ it 'should handle Date' do
+ person = Professor.get!(@jeremy.id, @jeremy.name)
+ person.birthday.should == @jeremy.birthday
+ end
+
+ it 'should match with Data' do
+ people = Professor.all(:birthday => Date.today)
+ people.length.should == 3
+ end
+
+end
View
102 spec/limit_and_order_spec.rb
@@ -0,0 +1,102 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+
+class Hero
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+ belongs_to :company
+end
+
+describe 'with multiple records saved' do
+ before(:each) do
+ @person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today }
+ @jeremy = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
+ @danielle = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26))
+ @keegan = Hero.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20, :wealth => 15.00))
+ sleep(0.4) #or the get calls might not have these created yet
+ end
+
+ after(:each) do
+ @jeremy.destroy
+ @danielle.destroy
+ @keegan.destroy
+ sleep(0.4) #or might not be destroyed by the next test
+ end
+
+ it 'should handle limit one case' do
+ persons = Hero.all(:limit => 1)
+ persons.length.should ==1
+ end
+
+ it 'should handle max item limit case' do
+ persons = Hero.all(:limit => 3)
+ persons.length.should ==3
+ end
+
+ it 'should handle max item if limit is large case' do
+ persons = Hero.all(:limit => 150)
+ persons.length.should ==3
+ end
+
+ #it would be really slow to create over 100 entires to test this until we have batch creation
+ it 'should handle limits over the default SDB 100 results limit'
+
+ #it would be really slow to create over 100 entires to test this until we have batch creation
+ it 'should get all results over the default SDB 100 results limit'
+
+ it 'should handle ordering asc results with a limit' do
+ persons = Hero.all(:order => [:age.asc], :limit => 2)
+ persons.inspect #can't access via array until loaded? Weird
+ persons.length.should ==2
+ persons[0].should == @keegan
+ persons[1].should == @jeremy
+ end
+
+ it 'should handle ordering asc results' do
+ persons = Hero.all(:order => [:age.asc])
+ persons.inspect #can't access via array until loaded? Weird
+ persons[0].should == @keegan
+ persons[1].should == @jeremy
+ persons[2].should == @danielle
+ end
+
+ it 'should handle ordering desc results' do
+ persons = Hero.all(:order => [:age.desc])
+ persons.inspect #can't access via array until loaded? Weird
+ persons[0].should == @danielle
+ persons[1].should == @jeremy
+ persons[2].should == @keegan
+ end
+
+ it 'should handle ordering results with multiple conditionss' do
+ persons = Hero.all(:age.gt => 20, :wealth.gt => 20, :order => [:age.desc])
+ persons.inspect #can't access via array until loaded? Weird
+ persons.length.should ==2
+ persons[0].should == @danielle
+ persons[1].should == @jeremy
+ end
+
+ it 'should handle ordering results with ordered by conditions' do
+ persons = Hero.all(:age.gt => 20, :order => [:age.desc])
+ persons.inspect #can't access via array until loaded? Weird
+ persons.length.should ==2
+ persons[0].should == @danielle
+ persons[1].should == @jeremy
+ end
+
+ it 'should handle ordering results with unorder by conditions' do
+ persons = Hero.all(:wealth.gt => 20.00, :order => [:age.desc])
+ persons.inspect #can't access via array until loaded? Weird
+ persons.length.should ==2
+ persons[0].should == @danielle
+ persons[1].should == @jeremy
+ end
+
+end
View
42 spec/migrations_spec.rb
@@ -0,0 +1,42 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+require 'ruby-debug'
+
+describe 'support migrations' do
+
+ #TODO do this on different storage
+ class Person
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+ belongs_to :company
+ end
+
+ before do
+ @adapter = repository(:default).adapter
+ end
+
+# test can't be run simultanious make it delete a throwawaable storage model
+# instead of the one used by all the tests
+# it "should destroy model storage" do
+# ENV['destroy']='true'
+# @adapter.destroy_model_storage(repository(:default), Person)
+# @adapter.storage_exists?("missionaries").should == false
+# ENV['destroy']='false'
+# @adapter.create_model_storage(repository(:default), Person)
+# @adapter.storage_exists?("missionaries").should == true
+# end
+
+ it "should create model storage" do
+ Person.auto_migrate!
+ @adapter.storage_exists?("missionaries").should == true
+ end
+
+end
+
View
98 spec/multiple_records_spec.rb
@@ -0,0 +1,98 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+
+class Person
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+ belongs_to :company
+end
+
+#TODO write some tests with company or drop this
+class Company
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+
+ has n, :people
+end
+
+describe 'with multiple records saved' do
+ before(:each) do
+ @person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today }
+ @jeremy = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
+ @danielle = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26))
+ @keegan = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20))
+ sleep(0.4) #or the get calls might not have these created yet
+ end
+
+ after(:each) do
+ @jeremy.destroy
+ @danielle.destroy
+ @keegan.destroy
+ sleep(0.4) #or might not be destroyed by the next test
+ end
+
+ it 'should get all records' do
+ Person.all.length.should == 3
+ end
+
+ it 'should get records by eql matcher' do
+ people = Person.all(:age => 25)
+ people.length.should == 1
+ end
+
+ it 'should get record by eql matcher' do
+ person = Person.first(:conditions => {:age => 25})
+ person.should_not be_nil
+ end
+
+ it 'should get records by not matcher' do
+ people = Person.all(:age.not => 25)
+ people.length.should == 2
+ end
+
+ it 'should get record by not matcher' do
+ person = Person.first(:age.not => 25)
+ person.should_not be_nil
+ end
+
+ it 'should get records by gt matcher' do
+ people = Person.all(:age.gt => 25)
+ people.length.should == 1
+ end
+
+ it 'should get records by gte matcher' do
+ people = Person.all(:age.gte => 25)
+ people.length.should == 2
+ end
+
+ it 'should get records by lt matcher' do
+ people = Person.all(:age.lt => 25)
+ people.length.should == 1
+ end
+
+ it 'should get records by lte matcher' do
+ people = Person.all(:age.lte => 25)
+ people.length.should == 2
+ end
+
+ it 'should get record by lte matcher' do
+ person = Person.first(:age.lte => 25)
+ person.should_not be_nil
+ end
+
+ it 'should get records with multiple matchers' do
+ people = Person.all(:birthday => Date.today, :age.lte => 25)
+ people.length.should == 2
+ end
+
+ it 'should get records by the like matcher'
+end
View
46 spec/nils_spec.rb
@@ -0,0 +1,46 @@
+require 'pathname'
+require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
+require 'ruby-debug'
+
+class Enemy
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+ belongs_to :network
+end
+
+describe 'with nils records saved and retreived' do
+ before(:each) do
+ @person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today }
+ @jeremy = Enemy.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
+ @danielle = Enemy.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => nil, :age => 26, :birthday => nil))
+ sleep(0.4) #or the get calls might not have these created yet
+ end
+
+ after(:each) do
+ @jeremy.destroy
+ @danielle.destroy
+ sleep(0.4) #or might not be destroyed by the next test
+ end
+
+ it 'should get all records' do
+ Enemy.all.length.should == 2
+ end
+
+ it 'should get retrieve nil values' do
+ people = Enemy.all(:age => 26)
+ people.length.should == 1
+ people[0].name.should == nil
+ people[0].birthday.should == nil
+ end
+
+ #fails but might work if we switch to using the helena lib
+ it 'should find based on nil values'
+
+end
View
241 spec/simpledb_adapter_spec.rb
@@ -1,224 +1,75 @@
require 'pathname'
require Pathname(__FILE__).dirname.expand_path + 'spec_helper'
-require 'ruby-debug'
+
+class Friend
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+ property :age, Integer
+ property :wealth, Float
+ property :birthday, Date
+ property :created_at, DateTime
+
+ belongs_to :network
+end
+
+class Network
+ include DataMapper::Resource
+
+ property :id, String, :key => true
+ property :name, String, :key => true
+
+ has n, :friends
+end
describe DataMapper::Adapters::SimpleDBAdapter do
before(:each) do
- @person_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25,
- :wealth => 25.00, :birthday => Date.today }
- @person = Person.new(@person_attrs)
+ @friend_attrs = { :id => "person-#{Time.now.to_f.to_s}", :name => 'Jeremy Boles', :age => 25, :wealth => 25.00, :birthday => Date.today }
+ @friend = Friend.new(@friend_attrs)
end
it 'should create a record' do
- @person.save.should be_true
- @person.id.should_not be_nil
- @person.destroy
+ @friend.save.should be_true
+ @friend.id.should_not be_nil
+ @friend.destroy
end
describe 'with a saved record' do
- before(:each) { @person.save; sleep(0.2) } #sleep or it might not be on SDB at when the test checks it
- after(:each) { @person.destroy; sleep(0.2) } #same issues for the next test could still be there
+ before(:each) { @friend.save; sleep(0.4) } #sleep or it might not be on SDB at when the test checks it
+ after(:each) { @friend.destroy; sleep(0.4) } #same issues for the next test could still be there
it 'should get a record' do
- person = Person.get!(@person.id, @person.name)
+ person = Friend.get!(@friend.id, @friend.name)
person.should_not be_nil
- person.wealth.should == @person.wealth
+ person.wealth.should == @friend.wealth
end
it 'should not get records of the wrong type by id' do
- Company.get(@person.id, @person.name).should == nil
- lambda { Company.get!(@person.id, @person.name) }.should raise_error(DataMapper::ObjectNotFoundError)
+ Network.get(@friend.id, @friend.name).should == nil
+ lambda { Network.get!(@friend.id, @friend.name) }.should raise_error(DataMapper::ObjectNotFoundError)
end
it 'should update a record' do
- person = Person.get!(@person.id, @person.name)
+ person = Friend.get!(@friend.id, @friend.name)
person.wealth = 100.00
person.save
-
- person = Person.get!(@person.id, @person.name)
- person.wealth.should_not == @person.wealth
- person.age.should == @person.age
- person.id.should == @person.id
- person.name.should == @person.name
- end
-
- it 'should destroy a record' do
- @person.destroy.should be_true
- end
- end
-
- describe 'with nils records saved and retreived' do
- before(:each) do
- @jeremy = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
- @danielle = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => nil, :age => 26, :birthday => nil))
- sleep(0.3) #or the get calls might not have these created yet
- end
-
- after(:each) do
- @jeremy.destroy
- @danielle.destroy
- sleep(0.2) #or might not be destroyed by the next test
- end
-
- it 'should get all records' do
- Person.all.length.should == 2
- end
-
- it 'should get retrieve nil values' do
- people = Person.all(:age => 26)
- people.length.should == 1
- people[0].name.should == nil
- people[0].birthday.should == nil
+ sleep(0.3)
+ person = Friend.get!(@friend.id, @friend.name)
+ person.wealth.should_not == @friend.wealth
+ person.age.should == @friend.age
+ person.id.should == @friend.id
+ person.name.should == @friend.name
end
- end
-
- describe 'with multiple records saved' do
- before(:each) do
- @jeremy = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Jeremy Boles", :age => 25))
- @danielle = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Danille Boles", :age => 26))
- @keegan = Person.create(@person_attrs.merge(:id => Time.now.to_f.to_s, :name => "Keegan Jones", :age => 20))
- sleep(0.4) #or the get calls might not have these created yet
- end
-
- after(:each) do
- @jeremy.destroy
- @danielle.destroy
- @keegan.destroy
- sleep(0.4) #or might not be destroyed by the next test
- end
-
- it 'should get all records' do
- Person.all.length.should == 3
- end
-
- it 'should get records by eql matcher' do
- people = Person.all(:age => 25)
- people.length.should == 1
- end
-
- it 'should get record by eql matcher' do
- person = Person.first(:conditions => {:age => 25})
- person.should_not be_nil
- end
-
- it 'should get records by not matcher' do
- people = Person.all(:age.not => 25)
- people.length.should == 2
- end
-
- it 'should get record by not matcher' do
- person = Person.first(:age.not => 25)
- person.should_not be_nil
- end
-
- it 'should get records by gt matcher' do
- people = Person.all(:age.gt => 25)
- people.length.should == 1
- end
-
- it 'should get records by gte matcher' do
- people = Person.all(:age.gte => 25)
- people.length.should == 2
- end
-
- it 'should get records by lt matcher' do
- people = Person.all(:age.lt => 25)
- people.length.should == 1
- end
-
- it 'should get records by lte matcher' do
- people = Person.all(:age.lte => 25)
- people.length.should == 2
- end
-
- it 'should get record by lte matcher' do
- person = Person.first(:age.lte => 25)
- person.should_not be_nil
- end
-
- it 'should get records with multiple matchers' do
- people = Person.all(:birthday => Date.today, :age.lte => 25)
- people.length.should == 2
- end
-
- it 'should handle DateTime' do
- pending 'Need to figure out how to coerce DateTime'
- time = Time.now
- @jeremy.created_at = time
- @jeremy.save
- sleep(0.2)
- person = Person.get!(@jeremy.id, @jeremy.name)
- person.created_at.should == time
- end
-
- it 'should handle Date' do
- person = Person.get!(@jeremy.id, @jeremy.name)
- person.birthday.should == @jeremy.birthday
- end
-
- it 'should handle limit one case' do
- persons = Person.all(:limit => 1)
- persons.length.should ==1
- end
-
- #it would be really slow to create over 100 entires to test this until we have batch creation
- it 'should handle limits over the default SDB 100 results limit'
-
- #it would be really slow to create over 100 entires to test this until we have batch creation
- it 'should get all results over the default SDB 100 results limit'
-
- it 'should handle ordering asc results' do
- persons = Person.all(:order => [:age.asc])
- persons.inspect #can't access via array until loaded? Weird
- persons[0].should == @keegan
- persons[1].should == @jeremy
- persons[2].should == @danielle
- end
-
- it 'should handle ordering desc results' do
- persons = Person.all(:order => [:age.desc])
- persons.inspect #can't access via array until loaded? Weird
- persons[0].should == @danielle
- persons[1].should == @jeremy
- persons[2].should == @keegan
+ it 'should destroy a record' do
+ @friend.destroy.should be_true
+ sleep(0.4) #make sure SDB propigates change
+ lambda {Friend.get!(@friend.id, @friend.name)}.should raise_error(DataMapper::ObjectNotFoundError)
+ persons = Friend.all(:name => @friend.name)
+ persons.length.should == 0
end
- it 'should order records'
- it 'should get records by the like matcher'
- end
-
- describe 'support migrations' do
-
- before do
- @adapter = repository(:default).adapter
- end
-
- it "should destroy model storage" do
- ENV['destroy']='true'
- @adapter.destroy_model_storage(repository(:default), Person)
- @adapter.storage_exists?("missionaries").should == false
- ENV['destroy']='false'
- @adapter.create_model_storage(repository(:default), Person)
- @adapter.storage_exists?("missionaries").should == true
- end
-
- it "should create model storage" do
- Person.auto_migrate!
- @adapter.storage_exists?("missionaries").should == true
- end
-
- end
-
- describe 'associations' do
- it 'should work with belongs_to associations'
- it 'should work with has n associations'
- end
-
- describe 'STI' do
- it 'should override default type'
- it 'should load descendents on parent.all'
- it 'should raise an error if you have a column named couchdb_type'
end
end
View
30 spec/spec_helper.rb
@@ -1,34 +1,20 @@
require 'pathname'
require Pathname(__FILE__).dirname.parent.expand_path + 'lib/simpledb_adapter'
+require 'ruby-debug'
access_key = ENV['AMAZON_ACCESS_KEY_ID']
secret_key = ENV['AMAZON_SECRET_ACCESS_KEY']
+#For those that don't like to mess up their ENV
+if access_key==nil && secret_key==nil
+ lines = File.readlines(File.join(File.dirname(__FILE__),'..','aws_config'))
+ access_key = lines[0].strip
+ secret_key = lines[1].strip
+end
+
DataMapper.setup(:default, {
:adapter => 'simpledb',
:access_key => access_key,
:secret_key => secret_key,
:domain => 'missionaries'
})
-
-class Person
- include DataMapper::Resource
-
- property :id, String, :key => true
- property :name, String, :key => true
- property :age, Integer
- property :wealth, Float
- property :birthday, Date
- property :created_at, DateTime
-
- belongs_to :company
-end
-
-class Company
- include DataMapper::Resource
-
- property :id, String, :key => true
- property :name, String, :key => true
-
- has n, :people
-end
Please sign in to comment.
Something went wrong with that request. Please try again.