Module: GenSpec::GeneratorExampleGroup
- Includes:
- Matchers, RSpec::Matchers
- Defined in:
- lib/genspec/generator_example_group.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#generator_descriptor ⇒ Object
A hash containing the following:.
- #generator_init_blocks ⇒ Object
- #within_source_root(&block) ⇒ Object
Methods included from Matchers
add_shorthand_methods, #call_action, #delete, #generate, #output
Class Method Details
.included(base) ⇒ Object
6 7 8 9 |
# File 'lib/genspec/generator_example_group.rb', line 6 def self.included(base) base.send(:extend, GenSpec::GeneratorExampleGroup::ClassMethods) base.send(:subject) { generator_descriptor } end |
Instance Method Details
#generator_descriptor ⇒ Object
A hash containing the following:
:described - the generator to be tested, or the string/symbol representing it
:args - any arguments to be used when invoking the generator
:input - a string to be used as an input stream, or nil
:init_blocks - an array of blocks to be invoked prior to running the generator
:generator_options - a hash of options to be passed into the generator
This hash represents the subject
of the spec and this is the object that will ultimately be passed into the GenSpec matchers.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/genspec/generator_example_group.rb', line 30 def generator_descriptor { :described => self.class.generator, :args => self.class.generator_args, :input => self.class.generator_input, :output => self.class.generator_output, :init_blocks => generator_init_blocks, :generator_options => self.class. } end |
#generator_init_blocks ⇒ Object
15 16 17 |
# File 'lib/genspec/generator_example_group.rb', line 15 def generator_init_blocks @generator_init_blocks ||= self.class.generator_init_blocks.dup end |
#within_source_root(&block) ⇒ Object
11 12 13 |
# File 'lib/genspec/generator_example_group.rb', line 11 def within_source_root(&block) generator_init_blocks << block end |