Dummier is a rails generator for automating the creation and customization of rails testing applications.
A smart gem with a dumb name; Dummier is a rails generator for automating the creation of rails testing applications.
Dummier was inspired by José Valim’s enginex which creates a standard gem structure for you. Enginex creates a test/dummy
app for you, but what if we want to re-create it? Or leave it out of git?
The idea behind Dummier is that we don’t check test/dummy
into git, but rather generate it on the fly for the gems we’re developing. It just seems DRY’er that way.
Dummier is simple; just run the binary from your gem’s root directory and it will generate a stripped-down & gem-dev-ready rails app in test/dummy
. While it’s doing it’s thing, Dummer triggers a few hooks along the way for easy customization.
To catch the hooks, just create appropriately named files in test/dummy_hooks
inside your gem. See Hooks below for more info.
To install from RubyGems:
gem install dummier
To install with bundler:
gem 'dummier', '>= 0.3.2'
To package for development in your gemspec:
s.add_development_dependency('dummier', '>= 0.3.2')
After you’ve installed Dummier, just cd
into the gem your developing and run the binary:
bundle exec dummier
Dummier calls the following hooks along the way, in this order:
Place appropriately named files in test/dummy_hooks
and dummier will find and execute them automatically!
You can use Rails::Generators::Actions as well as Thor::Actions in your hooks. Also, since hooks are just eval
’d into the Dummer::AppGenerator, you have access to all of those methods as well.
If a hook throws an error, Dummier will raise a Dummier::HookException
and exit immediately.
Here’s a before_migrate.rb
hook that will install Spree Commerce by running a generator before migrating the test/dummy
database.
# test/dummy_hooks/before_migrate.rb
run "rails g spree:install"
Here’s an example taken from has_magick_title:
# test/dummy_hooks/after_app_generator.rb
run "rails g scaffold post title:string"
gsub_file "app/models/post.rb", "end", %(
has_magick_title
end)
gsub_file "config/routes.rb", "resources :posts", %(
resources :posts
root :to => "posts#index")
gsub_file "app/views/posts/show.html.erb", "<%= @post.title %>", %(
<%= magick_title_for @post %>)
To get setup for testing, clone this repo, bundle up and run rake.
git clone git://github.com/citrus/dummier.git
cd dummier
bundle install
bundle exec rake
Enjoy!
0.3.2 - 2012/3/12
0.3.1 - 2012/3/12
0.3.0 - 2012/1/26
0.2.4 - 2011/9/7
0.2.3 - 2011/9/6
0.2.2 - 2011/8/31
0.2.1 - 2011/8/31
0.2.0 - 2011/6/18
0.1.1 - 2011/6/1
test/dummy_hooks/templates
folder into the generator’s source_paths
0.1.0 - 2011/5/20
0.1.0.rc1 - 2011/5/11
2011/5/10
Copyright © 2011 - 2012 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.