Multi App Engine
Similar to enginex but can generate and setup multiple individual dummy apps (configured for either Mongoid or Active Record) for testing your gem. The gem comes with the following executables:
- mangine – Create new Engine with Dummy apps
- dummy – operate on Dummy apps
$ mengine ENGINE_NAME [options]
Use —help to see supported options.
Create a default engine called ‘MyEngine’
$ mangine my-engine
Dummy apps generated:
Design considerations and TODO
The goal is to implement the functionality described in this section.
Multi app Export/Import
The problem is, that the rails command doesn’t work right within a directory with its own Gemfile. You need to first export the app to a sandbox, then run the
rails new or
rails g command in this sandbox environment and then importa the app again.
This functionality should be integrated into export and import commands on the dummy generator.
dummy export cancan_active_record --sandbox ~/rails-dummies [--bundle]
dummy import cancan_active_record --sandbox ~/rails-dummies
The sandbox command will export the dummy app to the sandbox (if not there), execute a given command on the dummy app then import the dummy app back in.
dummy sandbox cancan_active_record --command "bundle update"
Release dummy app
There could also be a command to easily release a dummy app. The dummy should be linked to the current version of the gem/engine. Hence the VERSION file (or gemspec version)
could be used to version stamp the gem statement in the dummy apps’ Gemfile. The optional —github option could be used to indicate that the app should draw its engine from an alternative github source. This is useful if someone forks off the original engine and thus wants to demonstrate how the dummy app functions with his version of the engine gem.
dummy release cancan_active_record --github mike
Multi app Generation
There is also a need to be able to run a generator command across all dummy apps, such as fx:
rails g scaffold post name:string
Then for each dummy app, the generator will run via the dummy apps configuration.
The dummy generate command will use the sandbox command internally for execution and is merely a “shorthand” for this common operation.
dummy generate ALL "scaffold post name:string"
The ALL name runs the scaffold on all dymmy apps.
dummy generate cancan devise --command "scaffold post name:string" --orms active_record
When the —orms option is used, the command is only run on dummy apps with matching orm postfix
For this example it would generate a Mongoid Post model for the mongoid dummy and an AR model for the AR dummy etc.
Multi app Gem configuration
The multiengine should also have a way to update a set of apps with gems.
dummy update cancan-mongoid cancan-active_record
Run bundle update on each dummy app
dummy install cancan-mongoid cancan-active_record --gems devise cancan
Run bundle install after inserting gems into Gemfile of each dummy app
This command should also attempt to run
These commands should make it much easier to update the dummy apps with some configuration!
This update and install commands will also use the sandbox command internally for execution.
Notes on scaffolding
Would be a cool thing to get rolling…
Dummies for ORMs
Create engine named ‘MyEngine’ and dummy apps configured for A.R and Mongoid
$ mangine my-engine --orms mongoid ar
Create engine named ‘Demox’ and a single dummy app configured for Mongoid.
Use Rspec as the testing framework for the engine.
$ mangine demox --orms mongoid -t rspec
Dummy application types
Create engine named ‘Demox’ and create dummy apps for cancan and devise (types).
For each type create dummy apps for A.R and Mongoid. Use Rspec as the testing framework.
$ mangine demo --orms mongoid ar --types cancan devise -t rspec
Bugs and Feedback
If you discover any bugs, feel free to send me a message or create an issue on GitHub tracker
MIT License. Copyright 2011 Kristian Mandrup