Skip to content

Instantly share code, notes, and snippets.

@fidothe
Created March 18, 2015 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fidothe/5e1add59e0eeaa5eeb72 to your computer and use it in GitHub Desktop.
Save fidothe/5e1add59e0eeaa5eeb72 to your computer and use it in GitHub Desktop.
transaction-wrapped specs for Lotus::Model
require 'spec_helper'
RSpec.describe MyRepository, :db do
it "will be rolled back after completion" do
MyRepository.create(MyEntity.new)
expect(MyRepository.all.size).to eq(1)
end
it "will also be rolled back" do
MyRepository.create(MyEntity.new)
expect(MyRepository.all.size).to eq(1)
end
end
module RepositoryExampleGroup
def self.included(group)
group.around(:example) do |example|
described_class.transaction do
example.call
raise Sequel::Rollback
end
end
end
end
RSpec.configure do |config|
config.include RepositoryExampleGroup, db: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment