Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackc/doublecheck_view
Ruby gem for integrating doublecheck view pattern with database integration tests
https://github.com/jackc/doublecheck_view
Last synced: 24 days ago
JSON representation
Ruby gem for integrating doublecheck view pattern with database integration tests
- Host: GitHub
- URL: https://github.com/jackc/doublecheck_view
- Owner: jackc
- License: mit
- Created: 2016-05-14T16:11:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-14T16:16:03.000Z (over 8 years ago)
- Last Synced: 2024-04-24T12:26:15.466Z (7 months ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Doublecheck View
doublecheck_view is a Ruby gem that makes it easy to validate doublecheck views
during automated tests. See https://github.com/jackc/doublecheck for more
information about the doublecheck view pattern.## Installation
Add this line to your application's Gemfile:
```ruby
gem 'doublecheck_view'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install doublecheck_view
## Usage
You can check for errors manually at any time. The following code will select from every view in the `doublecheck` schema and `check_result` will only be valid if no rows are returned from any view.
```ruby
doublecheck = DoublecheckView::Doublecheck.new
check_result = doublecheck.check
assert check_result.valid?, check_result.errors
```However, the preferred approach is to run doublecheck after every test that uses
the database.```ruby
# Inside a MiniTest or ActiveSupport::TestCase class bodydef before_teardown
doublecheck = DoublecheckView::Doublecheck.new
check_result = doublecheck.check
assert check_result.valid?, check_result.errors
super
end
```Or for RSpec:
```ruby
RSpec.configure do |config|
# ...
config.before(:each) do
doublecheck = DoublecheckView::Doublecheck.new
check_result = doublecheck.check
expect(check_result).to be_valid, "doublecheck views: #{check_result.errors}"
end
end
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jackc/doublecheck.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).