Skip to content

Commit

Permalink
Specs and docs for transactional examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
pk committed May 8, 2009
1 parent 740f28b commit a8bbcfa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.rdoc
Expand Up @@ -34,6 +34,17 @@ Sequel 2.12.0:: All pass except session spec failing due to Marshall issues.
Sequel 3.0.0:: All pass except session spec failing due to Marshall issues.


== RSpec transactional examples

If you want to cut significantly runtime of your test suite which is using
Sequel you can enable transactional examples. Just add following line to
your spec_helper.rb or any spec you want to be transactional:

require 'merb_sequel/rspec/sequel'

Now <b>each example is wrapped in a Sequel transaction and when example finishes
Sequel::Error::Rollback is raised which cause transaction to rollback</b>.

== Connection options

Merb Sequel plug-in uses config/database.yml for connection configuration.
Expand Down
23 changes: 23 additions & 0 deletions spec/rspec/sequel_spec.rb
@@ -0,0 +1,23 @@
require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/../../lib/merb_sequel/rspec/sequel'

describe "Transaction enabled examples" do

before(:all) do
CreateSpecModel.apply(SpecModel.db, :up)
end

after(:all) do
CreateSpecModel.apply(SpecModel.db, :down)
end

it "should wrap each example in transaction and rollback" do
a = SpecModel.create(:name => 'Pavel')
a.should_not be_new
end

it "should not have Pavel in the database" do
a = SpecModel.find(:name => 'Pavel')
a.should be_nil
end
end

0 comments on commit a8bbcfa

Please sign in to comment.