Created
March 18, 2015 09:37
-
-
Save fidothe/5e1add59e0eeaa5eeb72 to your computer and use it in GitHub Desktop.
transaction-wrapped specs for Lotus::Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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