Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move up to rspec in rake, drop old specs from pre connection pool days

  • Loading branch information...
commit a2862fe7f9d7c0f0518f8bd79b2d35aecf33a51b 1 parent 78ceb47
Matthew Beale authored
Showing with 23 additions and 53 deletions.
  1. +13 −1 Rakefile
  2. +1 −51 spec/shard_the_love_spec.rb
  3. +9 −1 spec/spec_helper.rb
View
14 Rakefile
@@ -1 +1,13 @@
-require 'lib/tasks'
+require 'rake'
+require 'spec/rake/spectask'
+
+Spec::Rake::SpecTask.new(:spec) do |t|
+ t.spec_files = FileList['spec/*_spec.rb']
+ t.ruby_opts = ['-v']
+ t.spec_opts = ['--colour', '--format profile', '--loadby mtime', '--timeout 6', '--reverse']
+ t.verbose = true
+ t.warning = true
+end
+
+task :default => :spec
+
View
52 spec/shard_the_love_spec.rb
@@ -7,17 +7,6 @@ class Directory < ActiveRecord::Base
describe ShardTheLove do
- it "should return LOGGER at .logger" do
- ShardTheLove::LOGGER = 'this is it!'
- ShardTheLove.logger.should == 'this is it!'
- end
-
- it "should clear the connection pool" do
- Thread.current[:shard_the_love_connections] = {}
- Thread.current[:shard_the_love_connections].expects(:clear)
- ShardTheLove.clear_connection_pool!
- end
-
it "should deactivate shards" do
Thread.current.expects(:delete).with(:shard)
ShardTheLove.deactivate_shard
@@ -102,48 +91,9 @@ class Shard; end
ShardTheLove.init
end
- it "should create a new proxy for each class" do
- Shard.acts_as_shard
- Directory.acts_as_directory
- ActiveRecord::Base.should have(2).active_connections
- end
-
- it "should raise an exception is allow_concurrency is used" do
- ActiveRecord::Base.allow_concurrency = true
- lambda { Shard.acts_as_shard }.should raise_error(ArgumentError)
- ActiveRecord::Base.allow_concurrency = false
- end
-
- it "should log the shard creation" do
- ShardTheLove.logger.expects(:info)
- Shard.acts_as_shard
- end
-
- it "should make a directory act like a shard" do
- Directory.expects(:acts_as_shard)
- Directory.acts_as_directory
- end
-
- it "should mark a directory" do
- Directory.expects(:mark_as_directory)
- Directory.acts_as_directory
- end
-
- it "should add the class to acting_as_directories on mark_as_directory" do
- ActiveRecord::Base::ClassMethods.send(:class_variable_set, :@@acting_as_directories, [])
- Directory.mark_as_directory
- ActiveRecord::Base::ClassMethods.send(:class_variable_get, :@@acting_as_directories).length.should == 1
- end
-
- it "should return directory as connection name for directories" do
- Directory.acts_as_directory
- Directory.connection_name.should == 'directory'
- end
-
it "should return the current shard as the connection name for shards" do
- Shard.acts_as_shard
ShardTheLove.with 'hewey' do
- Shard.connection_name.should == 'hewey'
+ ShardTheLove.current_shard.should == 'hewey'
end
end
View
10 spec/spec_helper.rb
@@ -6,5 +6,13 @@
Spec::Runner.configure do |config|
config.mock_with :mocha
- ShardTheLove::LOGGER = ActiveRecord::Base.logger
+
+ config.before(:all) do
+ unless Object.const_defined?(:CONFIG_RUN)
+ ShardTheLove::LOGGER = stub(:info => true )
+ ShardTheLove::ENV = 'test'
+ CONFIG_RUN = true
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.