Skip to content

Commit

Permalink
Merge pull request itstommymorgan#26 from lgleasain/master
Browse files Browse the repository at this point in the history
Fixing Tests and added Travis Support
  • Loading branch information
lgleasain committed Apr 15, 2014
2 parents 8a6c05b + ebe85a7 commit 03dd584
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
Gemfile.lock
pkg/*
*.swp
coverage/
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: ruby
rvm:
- 1.9.3
- jruby-19mode
- jruby-head
- 2.0.0
- 2.1.0
- ruby-head
- rbx

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Description

[![Build Status](https://travis-ci.org/lgleasain/asari.svg?branch=master)](https://travis-ci.org/lgleasain/asari)

Asari is a Ruby wrapper for AWS CloudSearch, with optional ActiveRecord support
for easy integration with your Rails apps.

Expand All @@ -28,7 +30,7 @@ Amazon Cloud Search will give you a Search Endpoint and Document Endpoint. When
#### Boolean Query Usage

asari.search(filter: { and: { title: "donut", type: "cruller" }})
asari.search("boston creme", filter: { and: { title: "donut", or: { type: "cruller", type: "twist" }}}) # Full text search and nested boolean logic
asari.search("boston creme", filter: { and: { title: "donut", or: { type: "cruller|twist" }}}) # Full text search and nested boolean logic

For more information on how to use Cloudsearch boolean queries, [see the
documentation.](http://docs.aws.amazon.com/cloudsearch/latest/developerguide/booleansearch.html)
Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
2 changes: 2 additions & 0 deletions asari.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "httparty"

s.add_development_dependency "rspec"
s.add_development_dependency "simplecov"
s.add_development_dependency "rake"
end
10 changes: 6 additions & 4 deletions spec/documents_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
end

it "converts Time, DateTime, and Date fields to timestamp integers for rankability" do
HTTParty.should_receive(:post).with("http://doc-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/documents/batch", { :body => [{ "type" => "add", "id" => "1", "version" => 1, "lang" => "en", "fields" => { :time => 1333263600, :datetime => 1333238400, :date => 1333252800 }}].to_json, :headers => { "Content-Type" => "application/json"}})
date = Date.new(2012, 4, 1)
HTTParty.should_receive(:post).with("http://doc-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/documents/batch", { :body => [{ "type" => "add", "id" => "1", "version" => 1, "lang" => "en", "fields" => { :time => 1333263600, :datetime => 1333238400, :date => date.to_time.to_i }}].to_json, :headers => { "Content-Type" => "application/json"}})

expect(@asari.add_item("1", {:time => Time.at(1333263600), :datetime => DateTime.new(2012, 4, 1), :date => Date.new(2012, 4, 1)})).to eq(nil)
expect(@asari.add_item("1", {:time => Time.at(1333263600), :datetime => DateTime.new(2012, 4, 1), :date => date})).to eq(nil)
end

it "allows you to update an item to the index." do
Expand All @@ -41,9 +42,10 @@
end

it "converts Time, DateTime, and Date fields to timestamp integers for rankability on update as well" do
HTTParty.should_receive(:post).with("http://doc-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/documents/batch", { :body => [{ "type" => "add", "id" => "1", "version" => 1, "lang" => "en", "fields" => { :time => 1333263600, :datetime => 1333238400, :date => 1333252800 }}].to_json, :headers => { "Content-Type" => "application/json"}})
date = Date.new(2012, 4, 1)
HTTParty.should_receive(:post).with("http://doc-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/documents/batch", { :body => [{ "type" => "add", "id" => "1", "version" => 1, "lang" => "en", "fields" => { :time => 1333263600, :datetime => 1333238400, :date => date.to_time.to_i }}].to_json, :headers => { "Content-Type" => "application/json"}})

expect(@asari.update_item("1", {:time => Time.at(1333263600), :datetime => DateTime.new(2012, 4, 1), :date => Date.new(2012, 4, 1)})).to eq(nil)
expect(@asari.update_item("1", {:time => Time.at(1333263600), :datetime => DateTime.new(2012, 4, 1), :date => date})).to eq(nil)
end

it "allows you to delete an item from the index." do
Expand Down
2 changes: 1 addition & 1 deletion spec/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

describe "geography searching" do
it "builds a proper query string" do
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=%28and+lat%3A2505771415..2506771417+lng%3A111275735..111322958%29&size=10")
HTTParty.should_receive(:get).with("http://search-testdomain.us-east-1.cloudsearch.amazonaws.com/2011-02-01/search?q=&bq=%28and+lat%3A2505771415..2506771417+lng%3A2358260777..2359261578%29&size=10")
@asari.search filter: { and: Asari::Geography.coordinate_box(meters: 5000, lat: 45.52, lng: 122.6819) }
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'asari'
require 'asari/active_record'
require 'ostruct'
require 'simplecov'
SimpleCov.start

# Fake production mode to test.
Asari.mode = :production
Expand Down

0 comments on commit 03dd584

Please sign in to comment.