Class: StepsTemplator
- Inherits:
-
Object
- Object
- StepsTemplator
- Includes:
- Templator
- Defined in:
- lib/generators/feature/steps_templator.rb
Direct Known Subclasses
Constant Summary collapse
- VALID_TYPES =
%w(given when then).map(&:to_sym)
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
Instance Method Summary collapse
- #create_methods(template) ⇒ Object
- #create_step(type, template) ⇒ Object
-
#initialize(generator, user, file) ⇒ StepsTemplator
constructor
A new instance of StepsTemplator.
Methods included from Templator
Constructor Details
#initialize(generator, user, file) ⇒ StepsTemplator
Returns a new instance of StepsTemplator.
8 9 10 11 12 |
# File 'lib/generators/feature/steps_templator.rb', line 8 def initialize(generator, user, file) @generator = generator @user = user @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/generators/feature/steps_templator.rb', line 5 def file @file end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
5 6 7 |
# File 'lib/generators/feature/steps_templator.rb', line 5 def generator @generator end |
Instance Method Details
#create_methods(template) ⇒ Object
14 15 16 17 18 |
# File 'lib/generators/feature/steps_templator.rb', line 14 def create_methods(template) generator.prepend_to_file file do render File.join('step_definitions', template) end if File.exists? file end |
#create_step(type, template) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/generators/feature/steps_templator.rb', line 20 def create_step(type, template) fail "type '#{type}' must be one of #{VALID_TYPES}" unless VALID_TYPES.include? type generator.insert_into_file file, after: "### #{type.to_s.upcase} ###\n\n" do render File.join('step_definitions', template) end if File.exists? file end |