diff --git a/.travis.yml b/.travis.yml index c096bc95..288ca16f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,38 +2,16 @@ sudo: required language: ruby rvm: - - ruby-2.0.0-p648 - - ruby-2.1.10 - - ruby-2.2.7 - - ruby-2.3.4 - - ruby-2.4.1 - - jruby-9.1.9.0 + - ruby-2.3.7 + - ruby-2.4.4 + - ruby-2.5.1 + - jruby-9.1.17.0 gemfile: gemfile: - - gemfiles/rails_4_0.gemfile - - gemfiles/rails_4_1.gemfile - gemfiles/rails_4_2.gemfile - gemfiles/rails_5_0.gemfile - gemfiles/rails_5_1.gemfile - gemfiles/rails_5_2.gemfile -matrix: - exclude: - - rvm: ruby-2.0.0-p648 - gemfile: gemfiles/rails_5_0.gemfile - - rvm: ruby-2.0.0-p648 - gemfile: gemfiles/rails_5_1.gemfile - - rvm: ruby-2.0.0-p648 - gemfile: gemfiles/rails_5_2.gemfile - - rvm: ruby-2.1.10 - gemfile: gemfiles/rails_5_0.gemfile - - rvm: ruby-2.1.10 - gemfile: gemfiles/rails_5_1.gemfile - - rvm: ruby-2.1.10 - gemfile: gemfiles/rails_5_2.gemfile - - rvm: ruby-2.4.1 - gemfile: gemfiles/rails_4_0.gemfile - - rvm: ruby-2.4.1 - gemfile: gemfiles/rails_4_1.gemfile ### BUILD LIFECYCLE STEPS ### @@ -47,7 +25,7 @@ before_install: - docker ps after_install: - - gem install bundler -v 1.15.4 + - gem install bundler -v 1.16.2 - bundle install before_script: diff --git a/CHANGELOG.md b/CHANGELOG.md index 07800001..ebea381d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Breaking -* Improvement: [#267](https://github.com/Dynamoid/Dynamoid/pull/267) Upgrade AWS SDK to V3 (@andrykonchin) +* Maintenace: [#267](https://github.com/Dynamoid/Dynamoid/pull/267) Upgrade AWS SDK to V3 (@andrykonchin) +* Maintenace: [#268](https://github.com/Dynamoid/Dynamoid/pull/268) Drop support of old Ruby and Rails versions (@andrykonchin) ## Improvements diff --git a/README.md b/README.md index 402cad4e..805f037a 100644 --- a/README.md +++ b/README.md @@ -92,21 +92,20 @@ Then you need to initialize Dynamoid config to get it going. Put code similar to config.namespace = "dynamoid_app_development" # To namespace tables created by Dynamoid from other tables you might have. Set to nil to avoid namespacing. config.endpoint = 'http://localhost:3000' # [Optional]. If provided, it communicates with the DB listening at the endpoint. This is useful for testing with [Amazon Local DB] (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html). end - ``` -### Ruby & Rails Compatibility Matrix +### Ruby & Rails Compatibility + +Dynamoid supports Ruby >= 2.3 and Rails >= 4.2. + +Its compatibility is tested in following way: -| Ruby / Active Record | 4.0.x | 4.1.x | 4.2.x | 5.0.x | +| Ruby / Active Record | 4.2.x | 5.0.x | 5.1.x | 5.2.x | |:---------------------:|:-----:|:-----:|:-----:|:-----:| -| 2.0.0 | ✓ | ✓ | ✓ | | -| 2.1.x | ✓ | ✓ | ✓ | | -| 2.2.0-2.2.1 | ✓ | ✓ | ✓ | | -| 2.2.2+ | ✓ | ✓ | ✓ | ✓ | -| 2.3.x | ✓ | ✓ | ✓ | ✓ | -| 2.3.x | ✓ | ✓ | ✓ | ✓ | -| 2.4.x | | | ✓ | ✓ | -| jruby-9.X | ✓ | ✓ | ✓ | ✓ | +| 2.3.7 | ✓ | ✓ | ✓ | ✓ | +| 2.4.4 | ✓ | ✓ | ✓ | ✓ | +| 2.5.1 | ✓ | ✓ | ✓ | ✓ | +| jruby-9.1.17.0 | ✓ | ✓ | ✓ | ✓ | ## Setup diff --git a/gemfiles/rails_4_0.gemfile b/gemfiles/rails_4_0.gemfile deleted file mode 100644 index 603cdb36..00000000 --- a/gemfiles/rails_4_0.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "pry-byebug", platforms: :ruby -gem "rails", "~> 4.0.0" -gem "nokogiri", "~> 1.6.8" - -gemspec path: "../" diff --git a/gemfiles/rails_4_1.gemfile b/gemfiles/rails_4_1.gemfile deleted file mode 100644 index d7089d7c..00000000 --- a/gemfiles/rails_4_1.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "pry-byebug", platforms: :ruby -gem "rails", "~> 4.1.0" -gem "nokogiri", "~> 1.6.8" - -gemspec path: "../" diff --git a/spec/dynamoid/criteria/chain_spec.rb b/spec/dynamoid/criteria/chain_spec.rb index 4cda8ca4..0247e802 100644 --- a/spec/dynamoid/criteria/chain_spec.rb +++ b/spec/dynamoid/criteria/chain_spec.rb @@ -43,7 +43,7 @@ it 'Scans when there is only not-equal operator for hash key' do chain = Dynamoid::Criteria::Chain.new(Address) - chain.query = { 'id.in' => ['test'] } + chain.query = { 'id.in': ['test'] } expect(chain).to receive(:records_via_scan) chain.all end @@ -145,7 +145,7 @@ def request_params customer2 = model.create(name: 'Bob', age: 9) customer3 = model.create(name: 'Bob', age: 12) - expect(model.where(name: 'Bob', 'age.lt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'Bob', 'age.lt': 10).all).to contain_exactly(customer1, customer2) end it 'supports gt' do @@ -153,7 +153,7 @@ def request_params customer2 = model.create(name: 'Bob', age: 12) customer3 = model.create(name: 'Bob', age: 9) - expect(model.where(name: 'Bob', 'age.gt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'Bob', 'age.gt': 10).all).to contain_exactly(customer1, customer2) end it 'supports lte' do @@ -161,7 +161,7 @@ def request_params customer2 = model.create(name: 'Bob', age: 9) customer3 = model.create(name: 'Bob', age: 12) - expect(model.where(name: 'Bob', 'age.lte' => 9).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'Bob', 'age.lte': 9).all).to contain_exactly(customer1, customer2) end it 'supports gte' do @@ -169,7 +169,7 @@ def request_params customer2 = model.create(name: 'Bob', age: 12) customer3 = model.create(name: 'Bob', age: 9) - expect(model.where(name: 'Bob', 'age.gte' => 11).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'Bob', 'age.gte': 11).all).to contain_exactly(customer1, customer2) end it 'supports begins_with' do @@ -183,7 +183,7 @@ def request_params customer2 = model.create(name: 'Bob', job_title: 'Environmental Project Manager') customer3 = model.create(name: 'Bob', job_title: 'Creative Consultant') - expect(model.where(name: 'Bob', 'job_title.begins_with' => 'Environmental').all) + expect(model.where(name: 'Bob', 'job_title.begins_with': 'Environmental').all) .to contain_exactly(customer1, customer2) end @@ -193,7 +193,7 @@ def request_params customer3 = model.create(name: 'Bob', age: 30) customer4 = model.create(name: 'Bob', age: 40) - expect(model.where(name: 'Bob', 'age.between' => [19, 31]).all).to contain_exactly(customer2, customer3) + expect(model.where(name: 'Bob', 'age.between': [19, 31]).all).to contain_exactly(customer2, customer3) end end @@ -251,7 +251,7 @@ def request_params customer1 = model.create(name: 'a', last_name: 'a', age: 5) customer2 = model.create(name: 'a', last_name: 'b', age: 9) - expect(model.where(name: 'a', 'age.ne' => 9).all).to contain_exactly(customer1) + expect(model.where(name: 'a', 'age.ne': 9).all).to contain_exactly(customer1) end it 'supports lt' do @@ -259,7 +259,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', age: 9) customer3 = model.create(name: 'a', last_name: 'c', age: 12) - expect(model.where(name: 'a', 'age.lt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'a', 'age.lt': 10).all).to contain_exactly(customer1, customer2) end it 'supports gt' do @@ -267,7 +267,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', age: 12) customer3 = model.create(name: 'a', last_name: 'c', age: 9) - expect(model.where(name: 'a', 'age.gt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'a', 'age.gt': 10).all).to contain_exactly(customer1, customer2) end it 'supports lte' do @@ -275,7 +275,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', age: 9) customer3 = model.create(name: 'a', last_name: 'c', age: 12) - expect(model.where(name: 'a', 'age.lte' => 9).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'a', 'age.lte': 9).all).to contain_exactly(customer1, customer2) end it 'supports gte' do @@ -283,7 +283,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', age: 12) customer3 = model.create(name: 'a', last_name: 'c', age: 9) - expect(model.where(name: 'a', 'age.gte' => 11).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'a', 'age.gte': 11).all).to contain_exactly(customer1, customer2) end it 'supports begins_with' do @@ -298,7 +298,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', job_title: 'Environmental Project Manager') customer3 = model.create(name: 'a', last_name: 'c', job_title: 'Creative Consultant') - expect(model.where(name: 'a', 'job_title.begins_with' => 'Environmental').all) + expect(model.where(name: 'a', 'job_title.begins_with': 'Environmental').all) .to contain_exactly(customer1, customer2) end @@ -308,7 +308,7 @@ def request_params customer3 = model.create(name: 'a', last_name: 'c', age: 30) customer4 = model.create(name: 'a', last_name: 'd', age: 40) - expect(model.where(name: 'a', 'age.between' => [19, 31]).all).to contain_exactly(customer2, customer3) + expect(model.where(name: 'a', 'age.between': [19, 31]).all).to contain_exactly(customer2, customer3) end it 'supports in' do @@ -316,7 +316,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', age: 20) customer3 = model.create(name: 'a', last_name: 'c', age: 30) - expect(model.where(name: 'a', 'age.in' => [10, 20]).all).to contain_exactly(customer1, customer2) + expect(model.where(name: 'a', 'age.in': [10, 20]).all).to contain_exactly(customer1, customer2) end it 'supports contains' do @@ -331,7 +331,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', job_title: 'Environmental Project Manager') customer3 = model.create(name: 'a', last_name: 'c', job_title: 'Creative Consultant') - expect(model.where(name: 'a', 'job_title.contains' => 'Consul').all) + expect(model.where(name: 'a', 'job_title.contains': 'Consul').all) .to contain_exactly(customer1, customer3) end @@ -347,7 +347,7 @@ def request_params customer2 = model.create(name: 'a', last_name: 'b', job_title: 'Environmental Project Manager') customer3 = model.create(name: 'a', last_name: 'c', job_title: 'Creative Consultant') - expect(model.where(name: 'a', 'job_title.not_contains' => 'Consul').all) + expect(model.where(name: 'a', 'job_title.not_contains': 'Consul').all) .to contain_exactly(customer2) end end @@ -399,7 +399,7 @@ def request_params customer1 = model.create(age: 5) customer2 = model.create(age: 9) - expect(model.where('age.ne' => 9).all).to contain_exactly(customer1) + expect(model.where('age.ne': 9).all).to contain_exactly(customer1) end it 'supports lt' do @@ -407,7 +407,7 @@ def request_params customer2 = model.create(age: 9) customer3 = model.create(age: 12) - expect(model.where('age.lt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where('age.lt': 10).all).to contain_exactly(customer1, customer2) end it 'supports gt' do @@ -415,7 +415,7 @@ def request_params customer2 = model.create(age: 12) customer3 = model.create(age: 9) - expect(model.where('age.gt' => 10).all).to contain_exactly(customer1, customer2) + expect(model.where('age.gt': 10).all).to contain_exactly(customer1, customer2) end it 'supports lte' do @@ -423,7 +423,7 @@ def request_params customer2 = model.create(age: 9) customer3 = model.create(age: 12) - expect(model.where('age.lte' => 9).all).to contain_exactly(customer1, customer2) + expect(model.where('age.lte': 9).all).to contain_exactly(customer1, customer2) end it 'supports gte' do @@ -431,7 +431,7 @@ def request_params customer2 = model.create(age: 12) customer3 = model.create(age: 9) - expect(model.where('age.gte' => 11).all).to contain_exactly(customer1, customer2) + expect(model.where('age.gte': 11).all).to contain_exactly(customer1, customer2) end it 'supports begins_with' do @@ -439,7 +439,7 @@ def request_params customer2 = model.create(job_title: 'Environmental Project Manager') customer3 = model.create(job_title: 'Creative Consultant') - expect(model.where('job_title.begins_with' => 'Environmental').all) + expect(model.where('job_title.begins_with': 'Environmental').all) .to contain_exactly(customer1, customer2) end @@ -449,7 +449,7 @@ def request_params customer3 = model.create(age: 30) customer4 = model.create(age: 40) - expect(model.where('age.between' => [19, 31]).all).to contain_exactly(customer2, customer3) + expect(model.where('age.between': [19, 31]).all).to contain_exactly(customer2, customer3) end it 'supports in' do @@ -457,7 +457,7 @@ def request_params customer2 = model.create(age: 20) customer3 = model.create(age: 30) - expect(model.where('age.in' => [10, 20]).all).to contain_exactly(customer1, customer2) + expect(model.where('age.in': [10, 20]).all).to contain_exactly(customer1, customer2) end it 'supports contains' do @@ -465,7 +465,7 @@ def request_params customer2 = model.create(job_title: 'Environmental Project Manager') customer3 = model.create(job_title: 'Creative Consultant') - expect(model.where('job_title.contains' => 'Consul').all) + expect(model.where('job_title.contains': 'Consul').all) .to contain_exactly(customer1, customer3) end @@ -476,9 +476,9 @@ def request_params document1 = klass.create(set: ['a', 'b']) document2 = klass.create(set: ['b', 'c']) - expect(klass.where('set.contains' => 'a').all).to contain_exactly(document1) - expect(klass.where('set.contains' => 'b').all).to contain_exactly(document1, document2) - expect(klass.where('set.contains' => 'c').all).to contain_exactly(document2) + expect(klass.where('set.contains': 'a').all).to contain_exactly(document1) + expect(klass.where('set.contains': 'b').all).to contain_exactly(document1, document2) + expect(klass.where('set.contains': 'c').all).to contain_exactly(document2) end it 'supports contains for array' do @@ -488,9 +488,9 @@ def request_params document1 = klass.create(array: ['a', 'b']) document2 = klass.create(array: ['b', 'c']) - expect(klass.where('array.contains' => 'a').all).to contain_exactly(document1) - expect(klass.where('array.contains' => 'b').all).to contain_exactly(document1, document2) - expect(klass.where('array.contains' => 'c').all).to contain_exactly(document2) + expect(klass.where('array.contains': 'a').all).to contain_exactly(document1) + expect(klass.where('array.contains': 'b').all).to contain_exactly(document1, document2) + expect(klass.where('array.contains': 'c').all).to contain_exactly(document2) end it 'supports not_contains' do @@ -498,7 +498,7 @@ def request_params customer2 = model.create(job_title: 'Environmental Project Manager') customer3 = model.create(job_title: 'Creative Consultant') - expect(model.where('job_title.not_contains' => 'Consul').all) + expect(model.where('job_title.not_contains': 'Consul').all) .to contain_exactly(customer2) end end @@ -537,7 +537,7 @@ def request_params it 'supports query on local secondary index but always defaults to table range key' do chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:name => 'Bob', 'range.lt' => 3, 'range2.gt' => 15).count).to eq(1) + expect(chain.where(:name => 'Bob', 'range.lt': 3, 'range2.gt': 15).count).to eq(1) expect(chain.hash_key).to eq(:name) expect(chain.range_key).to eq(:range) expect(chain.index_name).to be_nil @@ -546,14 +546,14 @@ def request_params it 'supports query on local secondary index' do chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:name => 'Bob', 'range2.gt' => 15).count).to eq(2) + expect(chain.where(:name => 'Bob', 'range2.gt': 15).count).to eq(2) expect(chain.hash_key).to eq(:name) expect(chain.range_key).to eq(:range2) expect(chain.index_name).to eq(:range2index) chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:name => 'Bob', 'range3.lt' => 200).count).to eq(1) + expect(chain.where(:name => 'Bob', 'range3.lt': 200).count).to eq(1) expect(chain.hash_key).to eq(:name) expect(chain.range_key).to eq(:range3) expect(chain.index_name).to eq(:range3index) @@ -562,14 +562,14 @@ def request_params it 'supports query on local secondary index with start' do chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:name => 'Bob', 'range2.gt' => 15).count).to eq(2) + expect(chain.where(:name => 'Bob', 'range2.gt': 15).count).to eq(2) expect(chain.hash_key).to eq(:name) expect(chain.range_key).to eq(:range2) expect(chain.index_name).to eq(:range2index) chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:name => 'Bob', 'range2.gt' => 15).start(@customer2).all).to contain_exactly(@customer3) + expect(chain.where(:name => 'Bob', 'range2.gt': 15).start(@customer2).all).to contain_exactly(@customer3) expect(chain.hash_key).to eq(:name) expect(chain.range_key).to eq(:range2) expect(chain.index_name).to eq(:range2index) @@ -647,7 +647,7 @@ def request_params chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:city => 'San Francisco', 'age.gt' => 12).count).to eq(2) + expect(chain.where(:city => 'San Francisco', 'age.gt': 12).count).to eq(2) expect(chain.hash_key).to eq(:city) expect(chain.range_key).to eq(:age) expect(chain.index_name).to eq(:cityage) @@ -661,7 +661,7 @@ def request_params chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_query).and_call_original - expect(chain.where(:email => 'greg@test.com', 'age.gt' => 12).count).to eq(1) + expect(chain.where(:email => 'greg@test.com', 'age.gt': 12).count).to eq(1) expect(chain.hash_key).to eq(:email) expect(chain.range_key).to eq(:age) expect(chain.index_name).to eq(:emailage) @@ -705,7 +705,7 @@ def request_params it "does not use index if a condition for index hash key is other than 'equal'" do chain = Dynamoid::Criteria::Chain.new(model) expect(chain).to receive(:records_via_scan).and_call_original - expect(chain.where('city.begins_with' => 'San').count).to eq(3) + expect(chain.where('city.begins_with': 'San').count).to eq(3) expect(chain.hash_key).to be_nil expect(chain.range_key).to be_nil expect(chain.index_name).to be_nil @@ -745,7 +745,7 @@ def request_params customer3 = model.create(activated_at: Time.now - 2.hour) expect( - model.where('activated_at.gt' => Time.now - 1.5.hours).all + model.where('activated_at.gt': Time.now - 1.5.hours).all ).to contain_exactly(customer1, customer2) end @@ -762,7 +762,7 @@ def request_params customer3 = model.create(registered_on: Date.today - 4.days) expect( - model.where('registered_on.gt' => Date.today - 3.days).all + model.where('registered_on.gt': Date.today - 3.days).all ).to contain_exactly(customer1, customer2) end @@ -779,7 +779,7 @@ def request_params customer3 = model.create(birthday: '1991-11-28'.to_date) expect( - model.where('birthday.between' => ['1980-01-01'.to_date, '1990-01-01'.to_date]).all + model.where('birthday.between': ['1980-01-01'.to_date, '1990-01-01'.to_date]).all ).to contain_exactly(customer2) end @@ -831,7 +831,7 @@ def request_params customer3 = model.create(first_name: 'Alice', registered_on: Date.today - 4.days) expect( - model.where(first_name: 'Alice', 'registered_on.gt' => Date.today - 3.days).all + model.where(first_name: 'Alice', 'registered_on.gt': Date.today - 3.days).all ).to contain_exactly(customer1, customer2) end @@ -868,7 +868,7 @@ def request_params customer3 = model.create(first_name: 'Alice', last_name: 'Smit', registered_on: Date.today - 4.days) expect( - model.where(first_name: 'Alice', 'registered_on.gt' => Date.today - 3.days).all + model.where(first_name: 'Alice', 'registered_on.gt': Date.today - 3.days).all ).to contain_exactly(customer1, customer2) end end @@ -899,7 +899,7 @@ def request_params customer1 = model.create(birthday: '1978-08-21'.to_date) customer2 = model.create(birthday: '1984-05-13'.to_date) - expect(model.where('birthday.gt' => '1980-01-01').all).to contain_exactly(customer2) + expect(model.where('birthday.gt': '1980-01-01').all).to contain_exactly(customer2) end end end @@ -1123,7 +1123,7 @@ def request_params post1 = Post.create(post_id: 'x', posted_at: time) post2 = Post.create(post_id: 'x', posted_at: (time + 1.hour)) chain = Dynamoid::Criteria::Chain.new(Post) - query = { :post_id => 'x', 'posted_at.gt' => (time + ts_epsilon) } + query = { :post_id => 'x', 'posted_at.gt': (time + ts_epsilon) } resultset = chain.send(:where, query) expect(resultset.count).to eq 1 stored_record = resultset.first @@ -1140,7 +1140,7 @@ def request_params post1 = Post.create(post_id: 'x', posted_at: time) post2 = Post.create(post_id: 'x', posted_at: (time + 1.hour)) chain = Dynamoid::Criteria::Chain.new(Post) - query = { :post_id => 'x', 'posted_at.lt' => (time + 1.hour - ts_epsilon) } + query = { :post_id => 'x', 'posted_at.lt': (time + 1.hour - ts_epsilon) } resultset = chain.send(:where, query) expect(resultset.count).to eq 1 stored_record = resultset.first @@ -1157,7 +1157,7 @@ def request_params post1 = Post.create(post_id: 'x', posted_at: time) post2 = Post.create(post_id: 'x', posted_at: (time + 1.hour)) chain = Dynamoid::Criteria::Chain.new(Post) - query = { :post_id => 'x', 'posted_at.between' => [time - ts_epsilon, time + ts_epsilon]} + query = { :post_id => 'x', 'posted_at.between': [time - ts_epsilon, time + ts_epsilon]} resultset = chain.send(:where, query) expect(resultset.count).to eq 1 stored_record = resultset.first diff --git a/spec/dynamoid/finders_spec.rb b/spec/dynamoid/finders_spec.rb index 9e570bd1..fd48df73 100644 --- a/spec/dynamoid/finders_spec.rb +++ b/spec/dynamoid/finders_spec.rb @@ -261,7 +261,7 @@ def time_to_decimal(time) last_visit = Bar.create(name: 'Drank', visited_at: (time + 1.day).to_i) bars = Bar.find_all_by_secondary_index( - {name: 'Drank'}, range: {'visited_at.lte' => (time + 10.days).to_i} + {name: 'Drank'}, range: {'visited_at.lte': (time + 10.days).to_i} ) first_bar = bars.first last_bar = bars.last @@ -278,7 +278,7 @@ def time_to_decimal(time) last_visit = Bar.create(name: 'Drank', visited_at: time + 1.day) different_bar = Bar.create(name: 'Junk', visited_at: time + 7.days) bars = Bar.find_all_by_secondary_index( - {name: 'Drank'}, range: {'visited_at.lte' => (time + 10.days).to_i}, + {name: 'Drank'}, range: {'visited_at.lte': (time + 10.days).to_i}, scan_index_forward: false ) first_bar = bars.first @@ -321,7 +321,7 @@ def time_to_decimal(time) Post.create(post_id: 1, posted_at: time + 1.day, name: 'blog_post') posts = Post.find_all_by_secondary_index( - {post_id: '1'}, range: {'name.begins_with' => 'blog_'} + {post_id: '1'}, range: {'name.begins_with': 'blog_'} ) expect(posts.map(&:name)).to eql ['blog_post'] end @@ -338,7 +338,7 @@ def time_to_decimal(time) it 'filters based on gt (greater than)' do posts = Post.find_all_by_secondary_index( {name: 'post'}, - range: {'posted_at.gt' => time_to_decimal(@time + 1.day)} + range: {'posted_at.gt': time_to_decimal(@time + 1.day)} ) expect(posts.map(&:post_id).sort).to eql ['3'] end @@ -346,7 +346,7 @@ def time_to_decimal(time) it 'filters based on lt (less than)' do posts = Post.find_all_by_secondary_index( {name: 'post'}, - range: {'posted_at.lt' => time_to_decimal(@time + 1.day)} + range: {'posted_at.lt': time_to_decimal(@time + 1.day)} ) expect(posts.map(&:post_id).sort).to eql ['1'] end @@ -354,7 +354,7 @@ def time_to_decimal(time) it 'filters based on gte (greater than or equal to)' do posts = Post.find_all_by_secondary_index( {name: 'post'}, - range: {'posted_at.gte' => time_to_decimal(@time + 1.day)} + range: {'posted_at.gte': time_to_decimal(@time + 1.day)} ) expect(posts.map(&:post_id).sort).to eql ['2', '3'] end @@ -362,7 +362,7 @@ def time_to_decimal(time) it 'filters based on lte (less than or equal to)' do posts = Post.find_all_by_secondary_index( {name: 'post'}, - range: {'posted_at.lte' => time_to_decimal(@time + 1.day)} + range: {'posted_at.lte': time_to_decimal(@time + 1.day)} ) expect(posts.map(&:post_id).sort).to eql ['1', '2'] end @@ -371,7 +371,7 @@ def time_to_decimal(time) between = [time_to_decimal(@time - 1.day), time_to_decimal(@time + 1.5.day)] posts = Post.find_all_by_secondary_index( {name: 'post'}, - range: {'posted_at.between' => between} + range: {'posted_at.between': between} ) expect(posts.map(&:post_id).sort).to eql ['1', '2'] end diff --git a/spec/dynamoid/persistence_spec.rb b/spec/dynamoid/persistence_spec.rb index f46eddd4..9d396403 100644 --- a/spec/dynamoid/persistence_spec.rb +++ b/spec/dynamoid/persistence_spec.rb @@ -947,7 +947,7 @@ def self.name; 'Doc'; end pending 'casting to declared type is not supported yet' # With the primary key, we're forcing a Query rather than a Scan because of https://github.com/Dynamoid/Dynamoid/issues/6 primary_key = subject.id - expect(doc_class.where(id: primary_key).where('price.gt' => 4).first).to_not be_nil + expect(doc_class.where(id: primary_key).where('price.gt': 4).first).to_not be_nil end end end