Replace couchbase counters with drb version
This commit is contained in:
+17
-10
@@ -2,11 +2,12 @@
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require 'simplecov'
|
||||
SimpleCov.start 'rails'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require File.expand_path("../config/environment", File.dirname(__FILE__))
|
||||
require 'rspec/rails'
|
||||
require 'rspec/matchers'
|
||||
require 'capybara/rspec'
|
||||
require 'turnip/capybara'
|
||||
require 'in_memory_q_counter'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
@@ -44,10 +45,20 @@ module SpecSelectorHelpers
|
||||
end
|
||||
end
|
||||
|
||||
class Couchbase::View
|
||||
alias :old_initialize :initialize
|
||||
def initialize(bucket, endpoint, params = {})
|
||||
old_initialize(bucket, endpoint, params.merge(stale: false))
|
||||
class TestCounter < InMemoryQCounter
|
||||
def incr(*args)
|
||||
result = super
|
||||
puts "Counter incr called with #{args.inspect} giving result #{result}"
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(Couchbase)
|
||||
class Couchbase::View
|
||||
alias :old_initialize :initialize
|
||||
def initialize(bucket, endpoint, params = {})
|
||||
old_initialize(bucket, endpoint, params.merge(stale: false))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,11 +119,7 @@ RSpec.configure do |config|
|
||||
config.before :suite do
|
||||
Qwaiter::Couchbase.load_design_docs!
|
||||
# NOT THREADSAFE!!!!!! but good enough for testing since the real couchbase flush is slowwwwww....
|
||||
Qwaiter::Counter.connection = InMemoryQCounter.new
|
||||
# Threadsafe would be using the drb counter
|
||||
# require 'drb'
|
||||
# counter = DRbObject.new nil, 'druby://:9000'
|
||||
# Qwaiter::Counter.connection = counter
|
||||
Qwaiter::Counter.connection = TestCounter.new
|
||||
end
|
||||
|
||||
config.before :each do
|
||||
|
||||
Reference in New Issue
Block a user