Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Commit

Permalink
Added JRuby compatibility
Browse files Browse the repository at this point in the history
* Added skipping MRI/YARV gems on JRuby in .gemspec
* Added JRuby specific gems into Gemfile
* Added skipping Curb tests on JRuby
* Added `jruby-19mode` into Travis-CI matrix

Closes #555
  • Loading branch information
dwbutler authored and karmi committed Jan 4, 2013
1 parent 087d3c8 commit ea80f3e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 23 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -8,6 +8,7 @@ rvm:
- 1.9.3
- 1.8.7
- ree
- jruby-19mode

env:
- TEST_COMMAND="rake test:unit"
Expand Down
13 changes: 13 additions & 0 deletions Gemfile
Expand Up @@ -2,3 +2,16 @@ source "http://rubygems.org"

# Specify your gem's dependencies in tire.gemspec
gemspec

unless defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
gem "turn", "~> 0.9"
end

platform :jruby do
gem "jdbc-sqlite3"
gem "activerecord-jdbcsqlite3-adapter"

if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
gem "json"
end
end
13 changes: 12 additions & 1 deletion test/test_helper.rb
Expand Up @@ -6,13 +6,24 @@
require 'pathname'
require 'test/unit'

JRUBY = defined?(JRUBY_VERSION)

if ENV['JSON_LIBRARY']
puts "Using '#{ENV['JSON_LIBRARY']}' JSON library"
require ENV['JSON_LIBRARY']
elsif JRUBY
require 'json'
else
require 'yajl/json_gem'
end
require 'sqlite3'

if JRUBY
require 'jdbc/sqlite3'
require 'active_record'
require 'active_record/connection_adapters/jdbcsqlite3_adapter'
else
require 'sqlite3'
end

require 'shoulda'
require 'turn/autorun' unless ENV["TM_FILEPATH"] || defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
Expand Down
35 changes: 19 additions & 16 deletions test/unit/http_client_test.rb
@@ -1,5 +1,4 @@
require 'test_helper'
require 'tire/http/clients/curb'

module Tire
module HTTP
Expand Down Expand Up @@ -46,27 +45,31 @@ class ClientTest < Test::Unit::TestCase

end

context "Curb" do
setup do
Configuration.client Client::Curb
end
if defined?(Curl)
require 'tire/http/clients/curb'

context "Curb" do
setup do
Configuration.client Client::Curb
end

teardown do
Configuration.client Client::RestClient
end
teardown do
Configuration.client Client::RestClient
end

should "use POST method if request body passed" do
::Curl::Easy.any_instance.expects(:http_post)
should "use POST method if request body passed" do
::Curl::Easy.any_instance.expects(:http_post)

response = Configuration.client.get "http://localhost:3000", '{ "query_string" : { "query" : "apple" }}'
end
response = Configuration.client.get "http://localhost:3000", '{ "query_string" : { "query" : "apple" }}'
end

should "use GET method if request body is nil" do
::Curl::Easy.any_instance.expects(:http_get)
should "use GET method if request body is nil" do
::Curl::Easy.any_instance.expects(:http_get)

response = Configuration.client.get "http://localhost:9200/articles/article/1"
end
response = Configuration.client.get "http://localhost:9200/articles/article/1"
end

end
end


Expand Down
15 changes: 9 additions & 6 deletions tire.gemspec
Expand Up @@ -35,18 +35,21 @@ Gem::Specification.new do |s|
# = Development dependencies
#
s.add_development_dependency "bundler", "~> 1.0"
s.add_development_dependency "yajl-ruby", "~> 1.0"
s.add_development_dependency "shoulda"
s.add_development_dependency "mocha"
s.add_development_dependency "minitest", "~> 2.12"
s.add_development_dependency "activerecord", ">= 3.0"
s.add_development_dependency "sqlite3"
s.add_development_dependency "mongoid", "~> 2.2"
s.add_development_dependency "bson_ext"
s.add_development_dependency "redis-persistence"
s.add_development_dependency "curb"
s.add_development_dependency "oj"
s.add_development_dependency "turn", "~> 0.9" if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
s.add_development_dependency "faraday"

unless defined?(JRUBY_VERSION)
s.add_development_dependency "yajl-ruby", "~> 1.0"
s.add_development_dependency "sqlite3"
s.add_development_dependency "bson_ext"
s.add_development_dependency "curb"
s.add_development_dependency "oj"
end

s.description = <<-DESC
Tire is a Ruby client for the ElasticSearch search engine/database.
Expand Down

0 comments on commit ea80f3e

Please sign in to comment.