zdennis (owner)

Revisions

gist: 97819 Download_button fork
public
Public Clone URL: git://gist.github.com/97819.git
Embed All Files: show embed
item.rb #
1
2
3
4
5
6
7
8
9
10
11
12
class Item < ActiveRecord::Base
  def self.make_three_with_transactions
    transaction do
      transaction do
        Item.create!
        Item.create!
        Item.create!
      end
    end
  end
end
 
item_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
describe Item do
  it "should have 3 records" do
    Item.make_three_with_transactions
    Item.count.should == 3
  end
 
  it "should have 0 records" do
    Item.count.should == 0
  end
end