-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaffolding commands #94
Changes from 3 commits
8a3829f
c9de2b2
405f2bb
fe1588e
a820155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ class ScaffoldingCommands < Thor | |
type: :boolean, required: false, desc: 'This will delete the selected page', aliases: '-d' | ||
|
||
def page(name) | ||
handle_scaffolding(name, 'page') | ||
return delete_scaffolding(name, 'page', options[:path]) if options[:delete] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reek] reported by reviewdog 🐶 |
||
|
||
generate_scaffolding(name, 'page', options[:path]) | ||
end | ||
|
||
desc 'feature [NAME]', 'Creates a new feature' | ||
|
@@ -27,7 +29,9 @@ def page(name) | |
required: false, desc: 'This will delete the selected feature', aliases: '-d' | ||
|
||
def feature(name) | ||
handle_scaffolding(name, 'feature') | ||
return delete_scaffolding(name, 'feature', options[:path]) if options[:delete] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reek] reported by reviewdog 🐶 |
||
|
||
generate_scaffolding(name, 'feature', options[:path]) | ||
end | ||
|
||
desc 'spec [SPEC_NAME]', 'Creates a new spec' | ||
|
@@ -37,7 +41,9 @@ def feature(name) | |
type: :boolean, required: false, desc: 'This will delete the selected spec', aliases: '-d' | ||
|
||
def spec(name) | ||
handle_scaffolding(name, 'spec') | ||
return delete_scaffolding(name, 'spec', options[:path]) if options[:delete] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reek] reported by reviewdog 🐶 |
||
|
||
generate_scaffolding(name, 'spec', options[:path]) | ||
end | ||
|
||
desc 'helper [HELPER_NAME]', 'Creates a new helper' | ||
|
@@ -47,7 +53,21 @@ def spec(name) | |
type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d' | ||
|
||
def helper(name) | ||
handle_scaffolding(name, 'helper') | ||
return delete_scaffolding(name, 'helper', options[:path]) if options[:delete] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reek] reported by reviewdog 🐶 |
||
|
||
generate_scaffolding(name, 'helper', options[:path]) | ||
end | ||
|
||
desc 'steps [STEPS_NAME]', 'Creates a new steps definition' | ||
option :path, | ||
type: :string, required: false, desc: 'The path where your steps will be created', aliases: '-p' | ||
option :delete, | ||
type: :boolean, required: false, desc: 'This will delete the selected steps', aliases: '-d' | ||
|
||
def steps(name) | ||
return delete_scaffolding(name, 'steps', options[:path]) if options[:delete] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [reek] reported by reviewdog 🐶 |
||
|
||
generate_scaffolding(name, 'steps', options[:path]) | ||
end | ||
|
||
desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating' | ||
|
@@ -57,46 +77,24 @@ def scaffold(name) | |
Scaffolding.new([name, load_config_path('spec')]).generate_spec | ||
else | ||
Scaffolding.new([name, load_config_path('feature')]).generate_feature | ||
Scaffolding.new([name, load_config_path('steps')]).generate_steps | ||
end | ||
Scaffolding.new([name, load_config_path('page')]).generate_class | ||
Scaffolding.new([name, load_config_path('page')]).generate_page | ||
end | ||
|
||
desc 'config', 'Creates configuration file' | ||
option :delete, | ||
type: :boolean, required: false, desc: 'This will delete the config file', aliases: '-d' | ||
|
||
no_commands do | ||
def load_config_path(type) | ||
YAML.load_file('config/config.yml')["#{type}_path"] if Pathname.new('config/config.yml').exist? | ||
end | ||
|
||
def handle_scaffolding(name, type) | ||
path = options[:path] || load_config_path(type) | ||
scaffolding = Scaffolding.new([name, path]) | ||
|
||
if options[:delete] | ||
case type | ||
when 'page' | ||
scaffolding.delete_class | ||
when 'feature' | ||
scaffolding.delete_feature | ||
when 'spec' | ||
scaffolding.delete_spec | ||
when 'helper' | ||
scaffolding.delete_helper | ||
end | ||
else | ||
case type | ||
when 'page' | ||
scaffolding.generate_class | ||
when 'feature' | ||
scaffolding.generate_feature | ||
when 'spec' | ||
scaffolding.generate_spec | ||
when 'helper' | ||
scaffolding.generate_helper | ||
end | ||
end | ||
def delete_scaffolding(name, type, path) | ||
path ||= load_config_path(type) | ||
Scaffolding.new([name, path]).send("delete_#{type}") | ||
end | ||
|
||
def generate_scaffolding(name, type, path) | ||
path ||= load_config_path(type) | ||
Scaffolding.new([name, path]).send("generate_#{type}") | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Feature: <%= name %> | ||
Feature: <%= name.capitalize %> | ||
|
||
Scenario: Scenario name | ||
Given I am | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require_relative 'base_spec' | ||
require_relative '../page_objects/pages/<%= name %>_page' | ||
require_relative '../page_objects/pages/<%= name %>' | ||
|
||
describe <%= name.split('_').map {|word| word.capitalize }.join + 'Page' %> do | ||
describe '<%= name.split('_').map {|word| word.capitalize }.join %>' do | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../page_objects/pages/<%= name %>' | ||
|
||
Given ('') do | ||
end | ||
|
||
When ('') do | ||
end | ||
|
||
Then ('') do | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[reek] reported by reviewdog 🐶
DuplicateMethodCall: ScaffoldingCommands#page calls 'options[:path]' 2 times [https://github.com/troessner/reek/blob/v6.3.0/docs/Duplicate-Method-Call.md]