Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Better support test-unit or minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalermo committed Jul 4, 2016
1 parent ca57de3 commit b8fecd8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GEM
specs:
builder (3.2.2)
diff-lcs (1.2.5)
minitest (5.4.3)
pr_geohash (1.0.0)
rake (10.4.2)
rsolr (1.0.12)
Expand All @@ -34,6 +35,7 @@ PLATFORMS

DEPENDENCIES
bundler (>= 1.0.0)
minitest
rake
rspec
sunspot (~> 2.2.0)
Expand Down
1 change: 1 addition & 0 deletions lib/sunspot_matchers/sunspot_session_spy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def initialize(original_session)
# Support Sunspot random field in test -- Sunspot originally generate a random number for the field
# Only patch method if SunspotSessionSpy is initialized to prevent poisoning class simply by being included in Gemfile.
Sunspot::Query::Sort::RandomSort.class_eval do
remove_method :to_param
define_method :to_param do
"random #{direction_for_solr}"
end
Expand Down
7 changes: 5 additions & 2 deletions lib/sunspot_matchers/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'sunspot'
require 'minitest/autorun'
require File.expand_path('../matchers', __FILE__)
require File.expand_path('../sunspot_session_spy', __FILE__)
module SunspotMatchers
class HaveSearchParamsForSession
include MiniTest::Assertions
if defined?(MiniTest::Assertions)
include MiniTest::Assertions
else
include Test::Unit::Assertions
end

def initialize(session, method, *args, &block)
@session = session
Expand Down
1 change: 1 addition & 0 deletions sunspot_matchers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec"
s.add_development_dependency "sunspot", "~> 2.2.0"
s.add_development_dependency "rake"
s.add_development_dependency "minitest"

s.files = `git ls-files`.split("\n")
s.require_path = 'lib'
Expand Down
3 changes: 2 additions & 1 deletion test/sunspot_matchers_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rubygems'
require 'bundler'
require 'minitest/autorun'
require 'sunspot_matchers/test_helper'

class Post; end
Expand All @@ -22,7 +23,7 @@ class Person; end
string :name
end

class SunspotMatchersTest < MiniTest::Unit::TestCase
class SunspotMatchersTest < MiniTest::Test
include SunspotMatchers::TestHelper

def setup
Expand Down

0 comments on commit b8fecd8

Please sign in to comment.