-
The command
bundle gem foodie
creates a scaffold directory named foodie. This command will also start saving files to a Git repository if Git is installed. -
The test files are put into the spec directory.
-
We write
spec.add_dependency "activesupport", "4.0.0"
-
Steps to write a generator:
- First, we define a generator class called
recipe
, and we require the file for the class. - We make sure to set inheritance so that
recipe
inherits fromThor::Group
, and we includeThor::Actions
to define helper methods. - We define arguments by calling
argument
, and define the methods in the class. - Next, we run the generator (without running Cucumber) by running
bundle exec bin/foodie recipe dinner steak
. - After we run
bundle exec bin/foodie recipe dinner steak
, we'll be asked define thesource_root
method, so we define it as a class method inFoodie::Generators::Recipe
. - Then, we put a
template
in lib/foodie/generators/recipe/recipe.txt using thetemplate
method. - Lastly, we run
bundle exec cucumber features
and see everything pass!