spec/async_sender_spec.rb in quebert-0.0.4 vs spec/async_sender_spec.rb in quebert-0.0.6
- old
+ new
@@ -1,12 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-require 'active_record'
describe AsyncSender::Class do
before(:all) do
- @q = Backend::InProcess.new
+ @q = Quebert::Backend::InProcess.new
Quebert::AsyncSender::Object::ObjectJob.backend = @q
Quebert::AsyncSender::Instance::InstanceJob.backend = @q
end
class Greeter
@@ -37,42 +36,22 @@
end
describe AsyncSender::ActiveRecord do
- ActiveRecord::Base.establish_connection({
- :adapter => 'sqlite3',
- :database => ':memory:'
- })
-
- ActiveRecord::Schema.define do
- create_table "users", :force => true do |t|
- t.column "first_name", :text
- t.column "last_name", :text
- t.column "email", :text
- end
- end
-
- class User < ActiveRecord::Base
- include Quebert::AsyncSender::ActiveRecord
-
- def name
- "#{first_name} #{last_name}"
- end
-
- def self.emailizer(address)
- address
- end
- end
-
before(:all) do
+ Quebert.serializers.register :'ActiveRecord::Base', Serializer::ActiveRecord
+
@q = Backend::InProcess.new
- Quebert::AsyncSender::ActiveRecord::PersistedRecordJob.backend = @q
- Quebert::AsyncSender::ActiveRecord::UnpersistedRecordJob.backend = @q
+ Quebert::AsyncSender::ActiveRecord::RecordJob.backend = @q
Quebert::AsyncSender::Object::ObjectJob.backend = @q
end
+ after(:all) do
+ Quebert.serializers.unregister :'ActiveRecord::Base'
+ end
+
context "persisted" do
before(:each) do
@user = User.create!(:first_name => 'Brad', :last_name => 'Gessler', :email => 'brad@bradgessler.com')
end
@@ -97,6 +76,7 @@
it "should async_send class method" do
email = "brad@bradgessler.com"
User.async_send(:emailizer, email)
@q.reserve.perform.should eql(email)
end
+
end
\ No newline at end of file