Nosql
A simple ActiveRecord 'adapter' that raises an exception whenever the database is used. This is to ensure unit tests do not integrate with a database.
When testing scopes and complex queries, applying a tag can disable this gem and replace the normal adapter implementation.
Installation
Add this line to your application's Gemfile:
gem 'nosql'
And then execute:
$ bundle
Or install it yourself as:
$ gem install nosql
Usage
If you were using RSpec and tagged tests which did hit the datbase with ':db', then you could use the following.
config.around(:each, type: :model) do |example|
if example.metadata[:db]
Nosql::Connection.disable!
example.run
else
Nosql::Connection.enable!
example.run
Nosql::Connection.disable!
end
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request