diff --git a/.gitignore b/.gitignore index 560d1a6..fb28001 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ tmp .yardoc _yardoc doc/ +.DS_Store diff --git a/cloudsearchable.gemspec b/cloudsearchable.gemspec index e933b33..d63c8a5 100644 --- a/cloudsearchable.gemspec +++ b/cloudsearchable.gemspec @@ -47,7 +47,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" spec.add_development_dependency "yard" - spec.add_dependency 'aws-sdk-v1' + spec.add_dependency "aws-sdk", "~> 2" # testing dependencies spec.add_development_dependency "rspec", '~> 2' diff --git a/lib/cloudsearchable/cloud_search.rb b/lib/cloudsearchable/cloud_search.rb index 6254c1f..9d32cd0 100644 --- a/lib/cloudsearchable/cloud_search.rb +++ b/lib/cloudsearchable/cloud_search.rb @@ -1,11 +1,11 @@ -require 'aws-sdk-v1' +require 'aws-sdk' require 'json' module CloudSearch - API_VERSION = "2011-02-01" + API_VERSION = "2013-01-01" def self.client - @client ||= AWS::CloudSearch::Client.new + @client ||= Aws::CloudSearch::Client.new end def self.client=(client) diff --git a/spec/cloudsearchable/cloud_search_spec.rb b/spec/cloudsearchable/cloud_search_spec.rb index 452ebcc..3faa136 100644 --- a/spec/cloudsearchable/cloud_search_spec.rb +++ b/spec/cloudsearchable/cloud_search_spec.rb @@ -28,7 +28,7 @@ def initialize; end let(:success_response){ MockHTTPOK.new( {"status" => "success", "adds" => 1, "deletes" => 0}.to_json ) } it 'json parses the response' do - Net::HTTP.any_instance.stub(:start).and_return{success_response} + Net::HTTP.any_instance.stub(:start).and_return(success_response) response = described_class.post_sdf endpoint, sdf_document response.should eq JSON.parse success_response.body @@ -36,7 +36,7 @@ def initialize; end it 'triggers error! on response its no not a Net::HTTPSuccess' do response = MockHTTPBadRequest.new - Net::HTTP.any_instance.stub(:start).and_return{response} + Net::HTTP.any_instance.stub(:start).and_return(response) response.should_receive(:error!) described_class.post_sdf endpoint, sdf_document diff --git a/spec/cloudsearchable/cloudsearchable_spec.rb b/spec/cloudsearchable/cloudsearchable_spec.rb index 1b39a98..0dd3bd2 100644 --- a/spec/cloudsearchable/cloudsearchable_spec.rb +++ b/spec/cloudsearchable/cloudsearchable_spec.rb @@ -7,14 +7,14 @@ it 'can describe an index that returns ids for the class type' do test_index = clazz.cloudsearch_index test_index.should be_kind_of(Cloudsearchable::Domain) - test_index.fields.should have(4).items #3 explicit + 1 for the id of the object + expect(test_index.fields.size).to eq(4) end - + it 'has a default index' do clazz.cloudsearch_index.should be_kind_of(Cloudsearchable::Domain) clazz.cloudsearch_index(:test_index).should_not be(clazz.cloudsearch_index) end - + it 'names domains consistent with CloudSearch limitations' do clazz.cloudsearch_index(:test_index).name.should =~ /^[a-z][a-z0-9\-]+$/ end @@ -39,13 +39,13 @@ test_index.fields[:test_name].value_for(inst).should be(inst.name) test_index.fields[:helpfulness].value_for(inst).should be(1234) end - + it 'reindexes when told to' do clazz.cloudsearch_index( ).should_receive(:post_record).with(inst, inst.id, inst.lock_version) clazz.cloudsearch_index(:test_index).should_receive(:post_record).with(inst, inst.id, inst.lock_version) inst.update_indexes end - + it 'generates a sensible addition sdf document' do sdf = clazz.cloudsearch_index.send :addition_sdf, inst, inst.id, inst.lock_version sdf[:fields][:helpfulness].should be(1234) diff --git a/spec/cloudsearchable/field_spec.rb b/spec/cloudsearchable/field_spec.rb index f5c1df8..32b3414 100644 --- a/spec/cloudsearchable/field_spec.rb +++ b/spec/cloudsearchable/field_spec.rb @@ -2,6 +2,10 @@ require 'ostruct' describe Cloudsearchable::Field do + before(:each) do + ENV['AWS_REGION'] = 'us-test-1' + end + it 'has a name' do field = described_class.new 'fnord', :literal field.name.should eq(:fnord) @@ -23,7 +27,7 @@ field = described_class.new('fnord', :literal, :search_enabled => true) CloudSearch.client.should_receive(:define_index_field) do |call| call[:domain_name].should eq(domain_name) - call[:index_field][:literal_options][:search_enabled].should be_true + call[:index_field][:literal_options][:search_enabled].should be_truthy end field.define_in_domain domain_name end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a969768..5c30f37 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,4 +7,4 @@ require 'cloudsearchable' RSpec.configure do |config| -end \ No newline at end of file +end