cucumber_generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/lib/cucumber_generator/version.rb +3 -0
- data/lib/generators/feature/USAGE +8 -0
- data/lib/generators/feature/delete_steps.rb +12 -0
- data/lib/generators/feature/edit_steps.rb +13 -0
- data/lib/generators/feature/feature_generator.rb +57 -0
- data/lib/generators/feature/index_steps.rb +13 -0
- data/lib/generators/feature/new_steps.rb +13 -0
- data/lib/generators/feature/show_steps.rb +13 -0
- data/lib/generators/feature/steps_templator.rb +26 -0
- data/lib/generators/feature/templates/features/delete.feature +10 -0
- data/lib/generators/feature/templates/features/edit.feature +22 -0
- data/lib/generators/feature/templates/features/index.feature +9 -0
- data/lib/generators/feature/templates/features/new.feature +22 -0
- data/lib/generators/feature/templates/features/show.feature +9 -0
- data/lib/generators/feature/templates/features/users/background_steps.feature +4 -0
- data/lib/generators/feature/templates/features/users/login_steps.feature +1 -0
- data/lib/generators/feature/templates/step_definitions/blank_steps_file.rb +6 -0
- data/lib/generators/feature/templates/step_definitions/delete_given_steps.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/delete_then_steps.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/delete_when_steps.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/edit_given_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/edit_methods.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/edit_then_steps.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/edit_when_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/index_given_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/index_methods.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/index_then_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/new_methods.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/new_then_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/new_when_steps.rb +8 -0
- data/lib/generators/feature/templates/step_definitions/show_given_steps.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/show_methods.rb +4 -0
- data/lib/generators/feature/templates/step_definitions/show_then_steps.rb +4 -0
- data/lib/generators/feature/templator.rb +8 -0
- data/lib/generators/feature/user.rb +21 -0
- data/lib/tasks/cucumber_generator_tasks.rake +4 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OGI3Zjk2YWFhNjc2ZWMzZmY1MDAzNDM0NWVmYWIyMzNiNzE0MjM2NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDU0ZGQ0OGNhMThlNTZlMTA5MGFjMzMwNzE1NTgwMDYzMDI1MGMzOA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmI5NWQ0Y2EyZWJkMjRlNGM5NGM4ZGQ4ZWMxZDI3MWVjNGViNmZjYmU0ZDkw
|
10
|
+
YWIwZjQ4NTk3MWUzNzc4NmY1YjM2ZmJiZWRhODEwODMyNWVjZWQ3OTM4NGMx
|
11
|
+
M2Q3MmRlNzM3MjgzMzFiY2U0NWEzMTQyZWRkMjFhZjkwNGUyNTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTM5ZGZjNmZiZTNlYWZhYTZmNmU1OWI1ZjQ4NDcxZjJmNThhNDEwYmI0YWVl
|
14
|
+
NjYwY2UxZjFjNmMwNzBmNmRlNmMzMTRkNTljYmU5MDYxZDdlNmIzMjlhNGE1
|
15
|
+
MTcxNWEwOGZjNGRjZjcyNWZjZmYyYTJiMWMyZjIwY2Q5NjJiMGE=
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CucumberGenerator'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'steps_templator'
|
2
|
+
|
3
|
+
class EditSteps < StepsTemplator
|
4
|
+
def initialize(generator, user, file)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
create_methods('edit_methods.rb')
|
10
|
+
create_step(:when, 'edit_when_steps.rb')
|
11
|
+
create_step(:then, 'edit_then_steps.rb')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative 'user'
|
2
|
+
require_relative 'index_steps'
|
3
|
+
require_relative 'new_steps'
|
4
|
+
require_relative 'show_steps'
|
5
|
+
require_relative 'delete_steps'
|
6
|
+
require_relative 'edit_steps'
|
7
|
+
require_relative 'templator'
|
8
|
+
|
9
|
+
class FeatureGenerator < Rails::Generators::NamedBase
|
10
|
+
include Templator
|
11
|
+
source_root File.expand_path('../templates', __FILE__)
|
12
|
+
|
13
|
+
ALL_ACTIONS = %w(index new show edit delete)
|
14
|
+
desc 'Creates feature files and step definitions'
|
15
|
+
argument :actions, type: :array, default: ALL_ACTIONS, banner: 'actions'
|
16
|
+
class_option :user, type: :string, default: nil, desc: 'add user steps'
|
17
|
+
|
18
|
+
def feature
|
19
|
+
validate
|
20
|
+
@user = User.new self, options[:user]
|
21
|
+
create_steps_file
|
22
|
+
actions.each do |action|
|
23
|
+
@action = action
|
24
|
+
create_feature(table_name, action)
|
25
|
+
create_steps(action)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def validate
|
32
|
+
actions.each do |action|
|
33
|
+
fail "'#{action}' is not valid must " \
|
34
|
+
"be one of #{ALL_ACTIONS}" unless ALL_ACTIONS.include? action
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_feature(name, action)
|
39
|
+
template File.join('features',"#{action}.feature"),
|
40
|
+
"features/#{name}/#{action}.feature"
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_steps_file
|
44
|
+
template File.join('step_definitions', 'blank_steps_file.rb'),
|
45
|
+
steps_file_path
|
46
|
+
end
|
47
|
+
|
48
|
+
def steps_file_path
|
49
|
+
"features/step_definitions/#{file_name}_steps.rb"
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_steps(action)
|
53
|
+
Object.const_get("#{action.capitalize}Steps").new(
|
54
|
+
self, @user, steps_file_path
|
55
|
+
).create
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'steps_templator'
|
2
|
+
|
3
|
+
class IndexSteps < StepsTemplator
|
4
|
+
def initialize(generator, user, file)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
create_methods('index_methods.rb')
|
10
|
+
create_step(:given, 'index_given_steps.rb')
|
11
|
+
create_step(:then, 'index_then_steps.rb')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'steps_templator'
|
2
|
+
|
3
|
+
class NewSteps < StepsTemplator
|
4
|
+
def initialize(generator, user, file)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
create_methods('new_methods.rb')
|
10
|
+
create_step(:when, 'new_when_steps.rb')
|
11
|
+
create_step(:then, 'new_then_steps.rb')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'steps_templator'
|
2
|
+
|
3
|
+
class ShowSteps < StepsTemplator
|
4
|
+
def initialize(generator, user, file)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
create_methods('show_methods.rb')
|
10
|
+
create_step(:given, 'show_given_steps.rb')
|
11
|
+
create_step(:then, 'show_then_steps.rb')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'templator'
|
2
|
+
|
3
|
+
class StepsTemplator
|
4
|
+
include Templator
|
5
|
+
attr_reader :generator, :file
|
6
|
+
VALID_TYPES = %w(given when then).map(&:to_sym)
|
7
|
+
|
8
|
+
def initialize(generator, user, file)
|
9
|
+
@generator = generator
|
10
|
+
@user = user
|
11
|
+
@file = file
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_methods(template)
|
15
|
+
generator.prepend_to_file file do
|
16
|
+
render File.join('step_definitions', template)
|
17
|
+
end if File.exists? file
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_step(type, template)
|
21
|
+
fail "type '#{type}' must be one of #{VALID_TYPES}" unless VALID_TYPES.include? type
|
22
|
+
generator.insert_into_file file, after: "### #{type.to_s.upcase} ###\n\n" do
|
23
|
+
render File.join('step_definitions', template)
|
24
|
+
end if File.exists? file
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Feature: As a user I would like to view
|
2
|
+
my <%= table_name %>
|
3
|
+
|
4
|
+
<%- if @user.set? -%>
|
5
|
+
<%= @user.background_steps(:delete) %>
|
6
|
+
<%- end -%>
|
7
|
+
Scenario: I am deleting the <%= file_name %>
|
8
|
+
Given I am on the <%= table_name %> page
|
9
|
+
When I destroy one <%= file_name %>
|
10
|
+
Then I should see one less <%= file_name %> content
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: As a user I would like to edit
|
2
|
+
a <%= file_name %>
|
3
|
+
|
4
|
+
<%- if @user.set? -%>
|
5
|
+
<%= @user.background_steps(:edit) %>
|
6
|
+
<%- end -%>
|
7
|
+
@Happy
|
8
|
+
Scenario: I edit the <%= file_name %>
|
9
|
+
Given I am on the <%= file_name %> page
|
10
|
+
When I click "Edit"
|
11
|
+
And I enter edit <%= file_name %> info
|
12
|
+
And I click "Save"
|
13
|
+
Then I should see edited <%= file_name %> info
|
14
|
+
|
15
|
+
@Sad
|
16
|
+
Scenario: I edit the <%= file_name %>
|
17
|
+
Given I am on the <%= file_name %> page
|
18
|
+
When I click "Edit"
|
19
|
+
And I enter invalid edit <%= file_name %> info
|
20
|
+
And I click "Save"
|
21
|
+
Then I should see invalid <%= file_name %> input message
|
22
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: As a user I would like to view
|
2
|
+
my <%= table_name %>
|
3
|
+
|
4
|
+
<%- if @user.set? -%>
|
5
|
+
<%= @user.background_steps(:index) %>
|
6
|
+
<%- end -%>
|
7
|
+
Scenario: I am viewing the <%= table_name %> page
|
8
|
+
Given I am on the <%= table_name %> page
|
9
|
+
Then I should see <%= table_name %> content
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: As a user I would like to create
|
2
|
+
a new <%= file_name %>
|
3
|
+
|
4
|
+
<%- if @user.set? -%>
|
5
|
+
<%= @user.background_steps(:new) %>
|
6
|
+
<%- end -%>
|
7
|
+
@Happy
|
8
|
+
Scenario: I create the <%= file_name %>
|
9
|
+
Given I am on the <%= table_name %> page
|
10
|
+
When I click "New <%= class_name %>"
|
11
|
+
And I enter new <%= file_name %> info
|
12
|
+
And I click "Save"
|
13
|
+
Then I should see the new <%= file_name %> info
|
14
|
+
|
15
|
+
@Sad
|
16
|
+
Scenario: I create the <%= file_name %>
|
17
|
+
Given I am on the <%= table_name %> page
|
18
|
+
When I click "New <%= class_name %>"
|
19
|
+
And I enter invalid new <%= file_name %> info
|
20
|
+
And I click "Save"
|
21
|
+
Then I should see invalid <%= file_name %> input message
|
22
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: As a user I would like to view
|
2
|
+
a <%= file_name %>
|
3
|
+
|
4
|
+
<%- if @user.set? -%>
|
5
|
+
<%= @user.background_steps(:show) %>
|
6
|
+
<%- end -%>
|
7
|
+
Scenario: I am viewing the <%= file_name %> page
|
8
|
+
Given I am on the <%= file_name %> page
|
9
|
+
Then I should see the <%= file_name %> content
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'templator'
|
2
|
+
|
3
|
+
class User
|
4
|
+
include Templator
|
5
|
+
attr_reader :name, :generator
|
6
|
+
|
7
|
+
def initialize(generator, name)
|
8
|
+
@generator = generator
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def background_steps(action = nil)
|
13
|
+
@action = action
|
14
|
+
render File.join('features', 'users', 'background_steps.feature')
|
15
|
+
end
|
16
|
+
|
17
|
+
def set?
|
18
|
+
!@name.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John McConnell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Description of CucumberGenerator.
|
42
|
+
email:
|
43
|
+
- johnnyillinois@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- Rakefile
|
50
|
+
- lib/cucumber_generator/version.rb
|
51
|
+
- lib/generators/feature/USAGE
|
52
|
+
- lib/generators/feature/delete_steps.rb
|
53
|
+
- lib/generators/feature/edit_steps.rb
|
54
|
+
- lib/generators/feature/feature_generator.rb
|
55
|
+
- lib/generators/feature/index_steps.rb
|
56
|
+
- lib/generators/feature/new_steps.rb
|
57
|
+
- lib/generators/feature/show_steps.rb
|
58
|
+
- lib/generators/feature/steps_templator.rb
|
59
|
+
- lib/generators/feature/templates/features/delete.feature
|
60
|
+
- lib/generators/feature/templates/features/edit.feature
|
61
|
+
- lib/generators/feature/templates/features/index.feature
|
62
|
+
- lib/generators/feature/templates/features/new.feature
|
63
|
+
- lib/generators/feature/templates/features/show.feature
|
64
|
+
- lib/generators/feature/templates/features/users/background_steps.feature
|
65
|
+
- lib/generators/feature/templates/features/users/login_steps.feature
|
66
|
+
- lib/generators/feature/templates/step_definitions/blank_steps_file.rb
|
67
|
+
- lib/generators/feature/templates/step_definitions/delete_given_steps.rb
|
68
|
+
- lib/generators/feature/templates/step_definitions/delete_then_steps.rb
|
69
|
+
- lib/generators/feature/templates/step_definitions/delete_when_steps.rb
|
70
|
+
- lib/generators/feature/templates/step_definitions/edit_given_steps.rb
|
71
|
+
- lib/generators/feature/templates/step_definitions/edit_methods.rb
|
72
|
+
- lib/generators/feature/templates/step_definitions/edit_then_steps.rb
|
73
|
+
- lib/generators/feature/templates/step_definitions/edit_when_steps.rb
|
74
|
+
- lib/generators/feature/templates/step_definitions/index_given_steps.rb
|
75
|
+
- lib/generators/feature/templates/step_definitions/index_methods.rb
|
76
|
+
- lib/generators/feature/templates/step_definitions/index_then_steps.rb
|
77
|
+
- lib/generators/feature/templates/step_definitions/new_methods.rb
|
78
|
+
- lib/generators/feature/templates/step_definitions/new_then_steps.rb
|
79
|
+
- lib/generators/feature/templates/step_definitions/new_when_steps.rb
|
80
|
+
- lib/generators/feature/templates/step_definitions/show_given_steps.rb
|
81
|
+
- lib/generators/feature/templates/step_definitions/show_methods.rb
|
82
|
+
- lib/generators/feature/templates/step_definitions/show_then_steps.rb
|
83
|
+
- lib/generators/feature/templator.rb
|
84
|
+
- lib/generators/feature/user.rb
|
85
|
+
- lib/tasks/cucumber_generator_tasks.rake
|
86
|
+
homepage: https://github.com/johnmcconnell/cucumber_generator
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Summary of CucumberGenerator.
|
110
|
+
test_files: []
|