Skip to content

Commit

Permalink
[FIX] Assorted fixes for Ruby 1.8.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyza committed Mar 22, 2012
1 parent dcfb1da commit c34d86b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions test/integration/dsl_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class DSLSearchIntegrationTest < Test::Unit::TestCase
context "DSL" do

should "allow passing search payload as JSON" do
s = Tire.search 'articles-test', query: { query_string: { query: 'ruby' } },
facets: { 'current-tags' => { filter: { term: {tags: 'ruby' } } },
'global-tags' => { filter: { term: {tags: 'ruby'} }, global: true } }
s = Tire.search 'articles-test', :query => { :query_string => { :query => 'ruby' } },
:facets => { 'current-tags' => { :filter => { :term => {:tags => 'ruby' } } },
'global-tags' => { :filter => { :term => {:tags => 'ruby'} }, :global => true } }
# p s.results
assert_equal 2, s.results.count
assert_not_nil s.results.facets['current-tags']
Expand Down
2 changes: 1 addition & 1 deletion test/integration/text_query_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class QueryStringIntegrationTest < Test::Unit::TestCase

context "Text query" do
setup do
::RestClient.put "#{URL}/articles-test/article/plus-one", {title: "+1 !!!"}.to_json
::RestClient.put "#{URL}/articles-test/article/plus-one", {:title => "+1 !!!"}.to_json
::RestClient.post "#{URL}/articles-test/_refresh", ''
end

Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'sqlite3'

require 'shoulda'
require 'turn/autorun' unless ENV["TM_FILEPATH"] || ENV["CI"]
require 'turn/autorun' unless ENV["TM_FILEPATH"] || ENV["CI"] || defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
require 'mocha'

require 'active_support/core_ext/hash/indifferent_access'
Expand Down
10 changes: 5 additions & 5 deletions test/unit/index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ def self.count; DATA.size; end
end

should "pass the params to the passed method and bulk store the results" do
@index.expects(:bulk_store).with { |c| c == [1, 2] }.returns(true)
@index.expects(:bulk_store).with { |c| c == [3, 4] }.returns(true)
@index.expects(:bulk_store).with { |c,o| c == [1, 2] }.returns(true)
@index.expects(:bulk_store).with { |c,o| c == [3, 4] }.returns(true)

@index.import ImportData, :method => 'paginate', :page => 1, :per_page => 2
end

should "pass the class when method not passed" do
@index.expects(:bulk_store).with { |c| c == ImportData }.returns(true)
@index.expects(:bulk_store).with { |c,o| c == ImportData }.returns(true)

@index.import ImportData
end
Expand Down Expand Up @@ -500,8 +500,8 @@ def self.count; DATA.size; end
end

should "allow to manipulate the documents in passed block" do
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [2, 3] }
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [4, 5] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [2, 3] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [4, 5] }

@index.import ImportData, :method => :paginate, :per_page => 2 do |documents|
# Add 1 to every "document" and return them
Expand Down
8 changes: 4 additions & 4 deletions test/unit/model_import_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ImportTest < Test::Unit::TestCase
end

should "call the passed block on every batch, and NOT manipulate the documents array" do
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [1, 2] }
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [3, 4] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [1, 2] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [3, 4] }

runs = 0
ImportModel.import :per_page => 2 do |documents|
Expand All @@ -53,8 +53,8 @@ class ImportTest < Test::Unit::TestCase
end

should "manipulate the documents in passed block" do
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [2, 3] }
Tire::Index.any_instance.expects(:bulk_store).with { |c| c == [4, 5] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [2, 3] }
Tire::Index.any_instance.expects(:bulk_store).with { |c,o| c == [4, 5] }

ImportModel.import :per_page => 2 do |documents|
# Add 1 to every "document" and return them
Expand Down
2 changes: 1 addition & 1 deletion tire.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Gem::Specification.new do |s|
#
unless ENV["CI"]
s.add_development_dependency "rdoc"
s.add_development_dependency "turn", "~> 0.9"
s.add_development_dependency "turn", "~> 0.9" if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
end

s.description = <<-DESC
Expand Down

0 comments on commit c34d86b

Please sign in to comment.