JamJar
JamJar dynamically creates ActiveRecord models, backed by in-memory SQLite, to help you test your ActiveRecord extensions.
Installation
Add this line to your application's Gemfile:
gem "jamjar"
And then execute:
$ bundle
Usage
To generate a new model, simply call:
JamJar.model
You can pass a block, which will be evaluated in the model's class context:
model = JamJar.model do
def self.foo
"bar"
end
end
model.foo #=> "bar"
You can add columns to your model's table with column
.
JamJar.model do
column :foo, :string
end
You can pass any options for your column that are supported by Rails, as described in the Rails API Documentation.
JamJar.model do
column :foo, :string, default: "bar"
end
Contributing
- Fork it
- Create a branch (
git checkout -b super-foo
) - Add your feature and specs.
- Commit your changes (
git commit -am 'Extra-super foo-matic.'
) - Push to the branch (
git push origin super-foo
) - Create new Pull Request