spec/lifeboat_spec.rb in lifeboat-0.2.5 vs spec/lifeboat_spec.rb in lifeboat-0.3.0

- old
+ new

@@ -9,33 +9,41 @@ ActiveRecord::Base.establish_connection(config['test']) def rebuild_model options = {} # ActiveRecord::Base.connection.create_database('lifeboat_test') - ActiveRecord::Base.connection.create_table :fake_models, :force => true do |table| table.column :name, :string table.column :phone, :string table.column :email, :string end ActiveRecord::Base.connection.create_table :fakes, :force => true do |table| table.column :name, :string end + ActiveRecord::Base.connection.create_table :xml_records, :force => true do |table| + table.column :name, :string + end + end rebuild_model class FakeModel < ActiveRecord::Base attr_accessor :name, :email, :phone - include LifeBoat + has_lifeboat end class Fake < ActiveRecord::Base attr_accessor :name - include LifeBoat + has_lifeboat end +class XMLRecord < ActiveRecord::Base + attr_accessor :name + has_lifeboat :format => :xml +end + RAILS_ENV = "test" class Helper def self.clean_all_queues @sqs = RightAws::SqsGen2.new(Credentials.key,Credentials.secret) @@ -55,11 +63,11 @@ end end describe "An simple object " do it "raises for not having callbacks" do - lambda{ class BadModel ; include LifeBoat ; end }.should raise_error + lambda{ class BadModel ; has_lifeboat ; end }.should raise_error end end describe FakeModel, " We hook into callbacks to send the messages" do @@ -108,11 +116,11 @@ f = Fake.create(:name => "ivan") q = LifeBoat.read_queue("create_fake_test") q[0].body.should == f.attributes.to_json end - it "deletes SQS queue when parent is deleted" do + it "creates a destroy SQS queue when parent is destroyed" do f = Fake.create(:name => "updated") f.destroy messages = LifeBoat.read_queue("destroy_fake_test") messages.size.should == 1 end @@ -121,7 +129,15 @@ f = Fake.create(:name => "Er Update") f.name= "28347834" ; f.save messages= LifeBoat.read_queue("update_fake_test") messages.size.should == 1 end +end +describe LifeBoat, " does XML" do + it "serialices the objects to xml" do + f = XMLRecord.create(:name => "Yo soy XML") + messages = LifeBoat.read_queue("create_xmlrecord_test") + messages.size.should == 1 + messages[0].body.should == f.attributes.to_xml + end end