Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating to Bundler, MySQL2 for specs, and some Ruby 1.9 cleaning.

  • Loading branch information...
commit 711b6139239a5744aee374cdbd5a6ee02e5c8eef 1 parent feda068
@pat authored
Showing with 94 additions and 62 deletions.
  1. +8 −0 Gemfile
  2. +29 −0 Gemfile.lock
  3. +4 −3 Rakefile
  4. +1 −1  spec/fixtures/sql/structure.sql
  5. +4 −4 spec/functional/connection_spec.rb
  6. +1 −1  spec/functional/excerpt_spec.rb
  7. +1 −1  spec/functional/keywords_spec.rb
  8. +1 −1  spec/functional/persistance_spec.rb
  9. +1 −1  spec/functional/search_spec.rb
  10. +1 −1  spec/functional/status_spec.rb
  11. +1 −1  spec/functional/update_spec.rb
  12. +1 −1  spec/riddle/auto_version_spec.rb
  13. +1 −1  spec/riddle/client_spec.rb
  14. +1 −1  spec/riddle/configuration_spec.rb
  15. +1 −1  spec/riddle/controller_spec.rb
  16. +1 −1  spec/riddle_spec.rb
  17. +6 −3 spec/spec_helper.rb
  18. +13 −11 spec/sphinx_helper.rb
  19. +1 −1  spec/unit/client_spec.rb
  20. +1 −1  spec/unit/configuration/distributed_index_spec.rb
  21. +1 −1  spec/unit/configuration/index_spec.rb
  22. +1 −1  spec/unit/configuration/indexer_spec.rb
  23. +1 −1  spec/unit/configuration/realtime_index_spec.rb
  24. +1 −1  spec/unit/configuration/searchd_spec.rb
  25. +1 −1  spec/unit/configuration/source_spec.rb
  26. +1 −1  spec/unit/configuration/sql_source_spec.rb
  27. +1 −1  spec/unit/configuration/xml_source_spec.rb
  28. +1 −1  spec/unit/configuration_spec.rb
  29. +1 −1  spec/unit/filter_spec.rb
  30. +1 −1  spec/unit/message_spec.rb
  31. +1 −1  spec/unit/response_spec.rb
  32. +1 −1  spec/unit/riddle_spec.rb
  33. +0 −6 tasks/distribution.rb
  34. +4 −9 tasks/testing.rb
View
8 Gemfile
@@ -0,0 +1,8 @@
+source 'http://rubygems.org'
+
+group :development do
+ gem 'mysql2', '0.3.2'
+ gem 'jeweler', '1.5.1'
+ gem 'rspec', '>= 2.5.0'
+ gem 'yard', '>= 0.6.8'
+end
View
29 Gemfile.lock
@@ -0,0 +1,29 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ git (1.2.5)
+ jeweler (1.5.1)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ mysql2 (0.3.2)
+ rake (0.8.7)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.2)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ yard (0.6.8)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ jeweler (= 1.5.1)
+ mysql2 (= 0.3.2)
+ rspec (>= 2.5.0)
+ yard (>= 0.6.8)
View
7 Rakefile
@@ -1,6 +1,7 @@
require 'rubygems'
+require 'bundler'
-require 'tasks/distribution'
-require 'tasks/testing'
+Bundler.require :default, :development
-task :default => :spec
+require "#{File.dirname(__FILE__)}/tasks/distribution"
+require "#{File.dirname(__FILE__)}/tasks/testing"
View
2  spec/fixtures/sql/structure.sql
@@ -13,4 +13,4 @@ CREATE TABLE `people` (
`email` varchar(100) NOT NULL,
`birthday` datetime NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8
View
8 spec/functional/connection_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
class RiddleSpecConnectionProcError < StandardError; end
@@ -14,7 +14,7 @@ class RiddleSpecConnectionProcError < StandardError; end
describe '.connection' do
it "should use the given block" do
Riddle::Client.connection = lambda { |client|
- TCPsocket.new(client.server, client.port)
+ TCPSocket.new(client.server, client.port)
}
@client.query("smith").should be_kind_of(Hash)
end
@@ -31,7 +31,7 @@ class RiddleSpecConnectionProcError < StandardError; end
describe '#connection' do
it "use the given block" do
@client.connection = lambda { |client|
- TCPsocket.new(client.server, client.port)
+ TCPSocket.new(client.server, client.port)
}
@client.query("smith").should be_kind_of(Hash)
end
@@ -49,7 +49,7 @@ class RiddleSpecConnectionProcError < StandardError; end
raise RiddleSpecConnectionProcError
}
@client.connection = lambda { |client|
- TCPsocket.new(client.server, client.port)
+ TCPSocket.new(client.server, client.port)
}
lambda { @client.query("smith") }.should_not raise_error
View
2  spec/functional/excerpt_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Sphinx Excepts" do
before :each do
View
2  spec/functional/keywords_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Sphinx Keywords" do
before :each do
View
2  spec/functional/persistance_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Sphinx Persistance Connection" do
before :each do
View
2  spec/functional/search_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Sphinx Searches" do
before :each do
View
2  spec/functional/status_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
if Riddle.loaded_version == '0.9.9' || Riddle.loaded_version == '1.10'
describe "Sphinx Status" do
View
2  spec/functional/update_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Sphinx Updates" do
before :each do
View
2  spec/riddle/auto_version_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::AutoVersion do
describe '.configure' do
View
2  spec/riddle/client_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Client do
describe '#initialize' do
View
2  spec/riddle/configuration_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration do
#
View
2  spec/riddle/controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Controller do
describe '#sphinx_version' do
View
2  spec/riddle_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle do
describe '.version_warning' do
View
9 spec/spec_helper.rb
@@ -1,12 +1,15 @@
require 'rubygems'
+require 'bundler'
$:.unshift File.dirname(__FILE__) + '/../lib'
+$:.unshift File.dirname(__FILE__) + '/..'
+
+Bundler.require :default, :development
require 'riddle'
-require 'spec'
-require 'spec/sphinx_helper'
+require 'sphinx_helper'
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
sphinx = SphinxHelper.new
sphinx.setup_mysql
sphinx.generate_configuration
View
24 spec/sphinx_helper.rb
@@ -1,4 +1,3 @@
-require 'mysql'
require 'erb'
require 'yaml'
@@ -22,26 +21,29 @@ def initialize
end
def setup_mysql
- server = Mysql.new @host, @username, @password
- server.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)
+ client = Mysql2::Client.new(
+ :host => @host,
+ :username => @username,
+ :password => @password
+ )
- unless server.list_dbs.include?("riddle")
- server.query "CREATE DATABASE riddle;"
+ databases = client.query('SHOW DATABASES', :as => :array).to_a.flatten
+ unless databases.include?('riddle')
+ client.query 'CREATE DATABASE riddle'
end
- server.query "USE riddle;"
+ client.query "USE riddle"
structure = File.open("spec/fixtures/sql/structure.sql") { |f| f.read }
- # Block ensures multiple statement transaction is closed.
- server.query(structure) { |response| }
- server.query <<-QUERY
+ structure.split(/;/).each { |sql| client.query sql }
+ client.query <<-SQL
LOAD DATA LOCAL INFILE '#{@path}/fixtures/sql/data.tsv' INTO TABLE
`riddle`.`people` FIELDS TERMINATED BY ',' ENCLOSED BY "'" (gender,
first_name, middle_initial, last_name, street_address, city, state,
postcode, email, birthday)
- QUERY
+ SQL
- server.close
+ client.close
end
def reset
View
2  spec/unit/client_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Client do
it "should have the same keys for both commands and versions, except persist" do
View
2  spec/unit/configuration/distributed_index_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::DistributedIndex do
it "should not be valid without any indexes" do
View
2  spec/unit/configuration/index_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::DistributedIndex do
it "should be invalid without a name, sources or path if there's no parent" do
View
2  spec/unit/configuration/indexer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::Indexer do
it "should always be valid" do
View
2  spec/unit/configuration/realtime_index_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::RealtimeIndex do
let(:index) { Riddle::Configuration::RealtimeIndex.new('rt1') }
View
2  spec/unit/configuration/searchd_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::Searchd do
if Riddle.loaded_version == '0.9.9' || Riddle.loaded_version == '1.10'
View
2  spec/unit/configuration/source_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::Source do
#
View
2  spec/unit/configuration/sql_source_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::SQLSource do
it "should be invalid without a host, user, database, and query if there's no parent" do
View
2  spec/unit/configuration/xml_source_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration::XMLSource do
it "should be invalid without an xmlpipe command, name and type if there's no parent" do
View
2  spec/unit/configuration_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Configuration do
it "should render all given indexes and sources, plus the indexer and search sections" do
View
2  spec/unit/filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Client::Filter do
it "should render a filter that uses an array of ints correctly" do
View
2  spec/unit/message_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Client::Message do
it "should start with an empty string" do
View
2  spec/unit/response_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe Riddle::Client::Response do
it "should interpret an integer correctly" do
View
2  spec/unit/riddle_spec.rb
@@ -1,4 +1,4 @@
-require 'spec/spec_helper'
+require 'spec_helper'
describe "Riddle" do
it "should escape characters correctly" do
View
6 tasks/distribution.rb
@@ -1,6 +1,3 @@
-require 'jeweler'
-require 'yard'
-
YARD::Rake::YardocTask.new
Jeweler::Tasks.new do |gem|
@@ -11,9 +8,6 @@
gem.homepage = "http://freelancing-god.github.com/riddle/"
gem.authors = ["Pat Allan"]
- gem.add_development_dependency "rspec", ">= 1.2.9"
- gem.add_development_dependency "yard", ">= 0"
-
gem.files = FileList[
'lib/**/*.rb',
'LICENSE',
View
13 tasks/testing.rb
@@ -1,16 +1,11 @@
-require 'spec/rake/spectask'
+require 'rspec/core/rake_task'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/**/*_spec.rb']
- spec.spec_opts << "-c"
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
end
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
+RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems']
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end
-
-task :spec => :check_dependencies
Please sign in to comment.
Something went wrong with that request. Please try again.