Created
September 7, 2012 13:25
-
-
Save artemk/3666238 to your computer and use it in GitHub Desktop.
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 DatabaseHelper | |
def next_id(obj) | |
table_name = obj.class.table_name | |
seq = ActiveRecord::Base.connection.default_sequence_name(table_name) | |
ActiveRecord::Base.connection.select_value("SELECT last_value FROM #{seq}").to_i + 1 | |
end | |
end | |
RSpec.configure do |config| | |
config.include DatabaseHelper | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment