Permalink
Browse files

Specs and docs for transactional examples.

  • Loading branch information...
1 parent 740f28b commit a8bbcfaa741d70e1deccc73d80dc41ca78d71e3f @pk committed May 8, 2009
Showing with 34 additions and 0 deletions.
  1. +11 −0 README.rdoc
  2. +23 −0 spec/rspec/sequel_spec.rb
View
@@ -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.
View
@@ -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.