Skip to content

Commit

Permalink
Add Rspec2 macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutto committed Jun 10, 2012
1 parent 47e01ff commit 579c7b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reversible_data.rb
Expand Up @@ -8,6 +8,7 @@ module ReversibleData
autoload :Table, 'reversible_data/table'
autoload :TableManager, 'reversible_data/table_manager'
autoload :ShouldaMacros, 'reversible_data/shoulda_macros'
autoload :RSpec2Macros, 'reversible_data/rspec2_macros'

def self.add(name, opts = {}, &blk)
Table.new(name, opts, &blk)
Expand Down
13 changes: 13 additions & 0 deletions lib/reversible_data/rspec2_macros.rb
@@ -0,0 +1,13 @@
module ReversibleData
module RSpec2Macros

def use_reversible_tables(*tables)
options = tables.extract_options!
scope = options.fetch(:scope, :each)
table_manager = ReversibleData.manager_for(*tables)
before(scope) { table_manager.up! }
after(scope) { table_manager.down! }
end

end
end

0 comments on commit 579c7b4

Please sign in to comment.