metasploit-version 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +10 -3
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +10 -44
- data/Gemfile +12 -8
- data/RELEASING.md +86 -0
- data/Rakefile +5 -4
- data/UPGRADING.md +1 -0
- data/app/templates/.rspec.tt +2 -0
- data/app/templates/CHANGELOG.md.tt +18 -0
- data/app/templates/CONTRIBUTING.md.tt +122 -0
- data/app/templates/RELEASING.md.tt +99 -0
- data/app/templates/Rakefile.tt +7 -0
- data/app/templates/UPGRADING.md.tt +1 -0
- data/app/templates/lib/versioned/version.rb.tt +64 -0
- data/app/templates/spec/lib/versioned/version_spec.rb.tt +3 -0
- data/app/templates/spec/lib/versioned_spec.rb.tt +4 -0
- data/app/templates/spec/spec_helper.rb.tt +76 -0
- data/bin/metasploit-version +12 -0
- data/config/cucumber.yml +3 -0
- data/features/metasploit-version/install/add_development_dependency.feature +68 -0
- data/features/metasploit-version/install/bundle_install.feature +24 -0
- data/features/metasploit-version/install/changelog.feature +29 -0
- data/features/metasploit-version/install/conflict.feature +45 -0
- data/features/metasploit-version/install/contributing.feature +139 -0
- data/features/metasploit-version/install/namespace_spec/gem_version_constant.feature +154 -0
- data/features/metasploit-version/install/namespace_spec/namespace.feature +33 -0
- data/features/metasploit-version/install/namespace_spec/version_constant.feature +179 -0
- data/features/metasploit-version/install/rake_spec.feature +27 -0
- data/features/metasploit-version/install/releasing/ruby_versions.feature +50 -0
- data/features/metasploit-version/install/releasing/versioning.feature +138 -0
- data/features/metasploit-version/install/steps/gemspec_steps.rb +19 -0
- data/features/metasploit-version/install/upgrading.feature +19 -0
- data/features/metasploit-version/install/version.feature +11 -0
- data/features/metasploit-version/install/version/namespace.feature +157 -0
- data/features/metasploit-version/install/version/prerelease.feature +154 -0
- data/features/metasploit-version/install/version_spec/namespace.feature +32 -0
- data/features/metasploit-version/install/version_spec/testing/branch_from_master.feature +40 -0
- data/features/metasploit-version/install/version_spec/testing/branching_from_branch.feature +161 -0
- data/features/metasploit-version/install/version_spec/testing/merge_branch_to_master.feature +97 -0
- data/features/{shared/examples/metasploit/version/version_module/prerelease/git/step_definitions → step_definitions}/environment_variable_steps.rb +1 -1
- data/features/{shared/examples/metasploit/version/version_module/prerelease/git/step_definitions → step_definitions}/git_steps.rb +11 -3
- data/features/support/env.rb +15 -11
- data/lib/metasploit/version.rb +1 -0
- data/lib/metasploit/version/cli.rb +321 -0
- data/lib/metasploit/version/version.rb +2 -2
- data/metasploit-version.gemspec +2 -2
- data/spec/lib/metasploit/version/branch_spec.rb +1 -3
- data/spec/lib/metasploit/version/cli_spec.rb +514 -0
- data/spec/lib/metasploit/version/version_spec.rb +2 -4
- data/spec/lib/metasploit/version_spec.rb +2 -4
- data/spec/spec_helper.rb +63 -1
- data/spec/support/shared/examples/metasploit/version/version_module.rb +3 -1
- metadata +82 -8
@@ -0,0 +1,19 @@
|
|
1
|
+
Then(/^metasploit\-version should be development dependency with semantic version restriction in "(.*?)"$/) do |gemspec_path|
|
2
|
+
version_requirement = if defined? Metasploit::Version::Version::PRERELEASE
|
3
|
+
# require exactly this pre-release in case there are multiple prereleases for the same
|
4
|
+
# version number due to parallel branches.
|
5
|
+
"= #{Metasploit::Version::GEM_VERSION}"
|
6
|
+
elsif Metasploit::Version::Version::MAJOR < 1
|
7
|
+
# can only allow the PATCH to wiggle pre-1.0.0
|
8
|
+
"~> #{Metasploit::Version::Version::MAJOR}.#{Metasploit::Version::Version::MINOR}.#{Metasploit::Version::Version::PATCH}"
|
9
|
+
else
|
10
|
+
# can allow the MINOR to wiggle 1.0.0+
|
11
|
+
"~> #{Metasploit::Version::Version::MAJOR}.#{Metasploit::Version::Version::MINOR}"
|
12
|
+
end
|
13
|
+
|
14
|
+
check_file_content(
|
15
|
+
gemspec_path,
|
16
|
+
%r{spec\.add_development_dependency\s*(?<quote>'|")metasploit-version\k<quote>,\s*\k<quote>#{version_requirement}\k<quote>},
|
17
|
+
true
|
18
|
+
)
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: metasploit-version install should add UPGRADING.md
|
2
|
+
|
3
|
+
`metasploit-version install` should generate UPGRADING.md which includes any information needed by downstream
|
4
|
+
consumers of the gem when upgrading to handle Deprecations or Incompatible Changes.
|
5
|
+
|
6
|
+
Scenario:
|
7
|
+
Given I successfully run `bundle gem upgraded`
|
8
|
+
And I cd to "upgraded"
|
9
|
+
And my git identity is configured
|
10
|
+
And I successfully run `git commit --message "bundle gem upgraded"`
|
11
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
12
|
+
And I set the environment variables to:
|
13
|
+
| variable | value |
|
14
|
+
| TRAVIS_PULL_REQUEST | false |
|
15
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
16
|
+
Then the file "UPGRADING.md" should contain:
|
17
|
+
"""
|
18
|
+
No Deprecations or Incompatible Changes have been introduced at this time
|
19
|
+
"""
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: metasploit-version install adds 'version.rb' to replace default 'version.rb'
|
2
|
+
|
3
|
+
The version.rb file from metasploit-version will follow semver.org and define `MAJOR`, `MINOR`, and `PATCH`. If on
|
4
|
+
a branch, the `PRERELEASE` will also be defined. Default implementations for `Version.full` and `Version.gem` will
|
5
|
+
be provided and `VERSION` and `GEM_VERSION` will be set to the respective method.
|
6
|
+
|
7
|
+
Scenario: No gemspec
|
8
|
+
Given a file matching %r<.*\.gemspec> should not exist
|
9
|
+
When I run `metasploit-version install`
|
10
|
+
Then the output should contain "No gemspec found"
|
11
|
+
And the exit status should not be 0
|
@@ -0,0 +1,157 @@
|
|
1
|
+
Feature: metasploit-version install's 'version.rb' generate proper namespace nesting
|
2
|
+
|
3
|
+
The version.rb file from metasploit-version will generate the appropriately indented nesting for single and multiple
|
4
|
+
namespaces with proper conversion of underscored and dashes in the gem name to camel case and separate modules,
|
5
|
+
respectively
|
6
|
+
|
7
|
+
Scenario Outline: Top-level namespace
|
8
|
+
Given I successfully run `bundle gem <gem_name>`
|
9
|
+
And I cd to "<gem_name>"
|
10
|
+
And my git identity is configured
|
11
|
+
And I successfully run `git commit --message "bundle gem <gem_name>"`
|
12
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
13
|
+
And I set the environment variables to:
|
14
|
+
| variable | value |
|
15
|
+
| TRAVIS_PULL_REQUEST | false |
|
16
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
17
|
+
Then the file "<version_rb_path>" should contain exactly:
|
18
|
+
"""
|
19
|
+
module <namespace_name>
|
20
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
21
|
+
module Version
|
22
|
+
#
|
23
|
+
# CONSTANTS
|
24
|
+
#
|
25
|
+
|
26
|
+
# The major version number.
|
27
|
+
MAJOR = 0
|
28
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
29
|
+
MINOR = 0
|
30
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
31
|
+
PATCH = 1
|
32
|
+
|
33
|
+
#
|
34
|
+
# Module Methods
|
35
|
+
#
|
36
|
+
|
37
|
+
# The full version string, including the {<namespace_name>::Version::MAJOR},
|
38
|
+
# {<namespace_name>::Version::MINOR}, {<namespace_name>::Version::PATCH}, and optionally, the
|
39
|
+
# `<namespace_name>::Version::PRERELEASE` in the
|
40
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
41
|
+
#
|
42
|
+
# @return [String] '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}' on master.
|
43
|
+
# '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}-PRERELEASE'
|
44
|
+
# on any branch other than master.
|
45
|
+
def self.full
|
46
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
47
|
+
|
48
|
+
if defined? PRERELEASE
|
49
|
+
version = "#{version}-#{PRERELEASE}"
|
50
|
+
end
|
51
|
+
|
52
|
+
version
|
53
|
+
end
|
54
|
+
|
55
|
+
# The full gem version string, including the {<namespace_name>::Version::MAJOR},
|
56
|
+
# {<namespace_name>::Version::MINOR}, {<namespace_name>::Version::PATCH}, and optionally, the
|
57
|
+
# `<namespace_name>::Version::PRERELEASE` in the
|
58
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
59
|
+
#
|
60
|
+
# @return [String] '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}'
|
61
|
+
# on master. '{<namespace_name>::Version::MAJOR}.{<namespace_name>::Version::MINOR}.{<namespace_name>::Version::PATCH}.PRERELEASE'
|
62
|
+
# on any branch other than master.
|
63
|
+
def self.gem
|
64
|
+
full.gsub('-', '.pre.')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# (see Version.gem)
|
69
|
+
GEM_VERSION = Version.gem
|
70
|
+
|
71
|
+
# (see Version.full)
|
72
|
+
VERSION = Version.full
|
73
|
+
end
|
74
|
+
|
75
|
+
"""
|
76
|
+
|
77
|
+
Examples:
|
78
|
+
| gem_name | version_rb_path | namespace_name |
|
79
|
+
| single | lib/single/version.rb | Single |
|
80
|
+
| two_words | lib/two_words/version.rb | TwoWords |
|
81
|
+
|
82
|
+
Scenario Outline: Two-level namespace
|
83
|
+
Given I successfully run `bundle gem <gem_name>`
|
84
|
+
And I cd to "<gem_name>"
|
85
|
+
And my git identity is configured
|
86
|
+
And I successfully run `git commit --message "bundle gem <gem_name>"`
|
87
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
88
|
+
And I set the environment variables to:
|
89
|
+
| variable | value |
|
90
|
+
| TRAVIS_PULL_REQUEST | false |
|
91
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
92
|
+
Then the file "<version_rb_path>" should contain exactly:
|
93
|
+
"""
|
94
|
+
module <parent_module_name>
|
95
|
+
module <child_module_name>
|
96
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
97
|
+
module Version
|
98
|
+
#
|
99
|
+
# CONSTANTS
|
100
|
+
#
|
101
|
+
|
102
|
+
# The major version number.
|
103
|
+
MAJOR = 0
|
104
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
105
|
+
MINOR = 0
|
106
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
107
|
+
PATCH = 1
|
108
|
+
|
109
|
+
#
|
110
|
+
# Module Methods
|
111
|
+
#
|
112
|
+
|
113
|
+
# The full version string, including the {<parent_module_name>::<child_module_name>::Version::MAJOR},
|
114
|
+
# {<parent_module_name>::<child_module_name>::Version::MINOR}, {<parent_module_name>::<child_module_name>::Version::PATCH}, and optionally, the
|
115
|
+
# `<parent_module_name>::<child_module_name>::Version::PRERELEASE` in the
|
116
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
117
|
+
#
|
118
|
+
# @return [String] '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}' on master.
|
119
|
+
# '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}-PRERELEASE'
|
120
|
+
# on any branch other than master.
|
121
|
+
def self.full
|
122
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
123
|
+
|
124
|
+
if defined? PRERELEASE
|
125
|
+
version = "#{version}-#{PRERELEASE}"
|
126
|
+
end
|
127
|
+
|
128
|
+
version
|
129
|
+
end
|
130
|
+
|
131
|
+
# The full gem version string, including the {<parent_module_name>::<child_module_name>::Version::MAJOR},
|
132
|
+
# {<parent_module_name>::<child_module_name>::Version::MINOR}, {<parent_module_name>::<child_module_name>::Version::PATCH}, and optionally, the
|
133
|
+
# `<parent_module_name>::<child_module_name>::Version::PRERELEASE` in the
|
134
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
135
|
+
#
|
136
|
+
# @return [String] '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}'
|
137
|
+
# on master. '{<parent_module_name>::<child_module_name>::Version::MAJOR}.{<parent_module_name>::<child_module_name>::Version::MINOR}.{<parent_module_name>::<child_module_name>::Version::PATCH}.PRERELEASE'
|
138
|
+
# on any branch other than master.
|
139
|
+
def self.gem
|
140
|
+
full.gsub('-', '.pre.')
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# (see Version.gem)
|
145
|
+
GEM_VERSION = Version.gem
|
146
|
+
|
147
|
+
# (see Version.full)
|
148
|
+
VERSION = Version.full
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
"""
|
153
|
+
|
154
|
+
Examples:
|
155
|
+
| gem_name | version_rb_path | parent_module_name | child_module_name |
|
156
|
+
| parent-single | lib/parent/single/version.rb | Parent | Single |
|
157
|
+
| parent-two_words | lib/parent/two_words/version.rb | Parent | TwoWords |
|
@@ -0,0 +1,154 @@
|
|
1
|
+
Feature: metasploit-version install conditionally defines PRERELEASE in version.rb
|
2
|
+
|
3
|
+
The version.rb file will define PRERELEASE to the branch's prerelease name when `metasploit-version install` is run on
|
4
|
+
a branch, while it will not define PRERELEASE on master.
|
5
|
+
|
6
|
+
Scenario: No PRERELEASE on master
|
7
|
+
Given I successfully run `bundle gem master`
|
8
|
+
And I cd to "master"
|
9
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
10
|
+
And I set the environment variables to:
|
11
|
+
| variable | value |
|
12
|
+
| TRAVIS_PULL_REQUEST | false |
|
13
|
+
And my git identity is configured
|
14
|
+
And I successfully run `git commit --message "bundle gem master"`
|
15
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
16
|
+
Then the file "lib/master/version.rb" should contain exactly:
|
17
|
+
"""
|
18
|
+
module Master
|
19
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
20
|
+
module Version
|
21
|
+
#
|
22
|
+
# CONSTANTS
|
23
|
+
#
|
24
|
+
|
25
|
+
# The major version number.
|
26
|
+
MAJOR = 0
|
27
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
28
|
+
MINOR = 0
|
29
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
30
|
+
PATCH = 1
|
31
|
+
|
32
|
+
#
|
33
|
+
# Module Methods
|
34
|
+
#
|
35
|
+
|
36
|
+
# The full version string, including the {Master::Version::MAJOR},
|
37
|
+
# {Master::Version::MINOR}, {Master::Version::PATCH}, and optionally, the
|
38
|
+
# `Master::Version::PRERELEASE` in the
|
39
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
40
|
+
#
|
41
|
+
# @return [String] '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}' on master.
|
42
|
+
# '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}-PRERELEASE'
|
43
|
+
# on any branch other than master.
|
44
|
+
def self.full
|
45
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
46
|
+
|
47
|
+
if defined? PRERELEASE
|
48
|
+
version = "#{version}-#{PRERELEASE}"
|
49
|
+
end
|
50
|
+
|
51
|
+
version
|
52
|
+
end
|
53
|
+
|
54
|
+
# The full gem version string, including the {Master::Version::MAJOR},
|
55
|
+
# {Master::Version::MINOR}, {Master::Version::PATCH}, and optionally, the
|
56
|
+
# `Master::Version::PRERELEASE` in the
|
57
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
58
|
+
#
|
59
|
+
# @return [String] '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}'
|
60
|
+
# on master. '{Master::Version::MAJOR}.{Master::Version::MINOR}.{Master::Version::PATCH}.PRERELEASE'
|
61
|
+
# on any branch other than master.
|
62
|
+
def self.gem
|
63
|
+
full.gsub('-', '.pre.')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# (see Version.gem)
|
68
|
+
GEM_VERSION = Version.gem
|
69
|
+
|
70
|
+
# (see Version.full)
|
71
|
+
VERSION = Version.full
|
72
|
+
end
|
73
|
+
|
74
|
+
"""
|
75
|
+
|
76
|
+
Scenario Outline: PRERELEASE on branch
|
77
|
+
Given I successfully run `bundle gem branch`
|
78
|
+
And I cd to "branch"
|
79
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
80
|
+
And I set the environment variables to:
|
81
|
+
| variable | value |
|
82
|
+
| TRAVIS_PULL_REQUEST | false |
|
83
|
+
And my git identity is configured
|
84
|
+
And I successfully run `git commit --message "bundle gem branch"`
|
85
|
+
And I successfully run `git checkout -b <branch>`
|
86
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
87
|
+
Then the file "lib/branch/version.rb" should contain exactly:
|
88
|
+
"""
|
89
|
+
module Branch
|
90
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
91
|
+
module Version
|
92
|
+
#
|
93
|
+
# CONSTANTS
|
94
|
+
#
|
95
|
+
|
96
|
+
# The major version number.
|
97
|
+
MAJOR = 0
|
98
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
99
|
+
MINOR = 0
|
100
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
101
|
+
PATCH = 1
|
102
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
|
103
|
+
PRERELEASE = '<prerelease>'
|
104
|
+
|
105
|
+
#
|
106
|
+
# Module Methods
|
107
|
+
#
|
108
|
+
|
109
|
+
# The full version string, including the {Branch::Version::MAJOR},
|
110
|
+
# {Branch::Version::MINOR}, {Branch::Version::PATCH}, and optionally, the
|
111
|
+
# `Branch::Version::PRERELEASE` in the
|
112
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
113
|
+
#
|
114
|
+
# @return [String] '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}' on master.
|
115
|
+
# '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}-PRERELEASE'
|
116
|
+
# on any branch other than master.
|
117
|
+
def self.full
|
118
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
119
|
+
|
120
|
+
if defined? PRERELEASE
|
121
|
+
version = "#{version}-#{PRERELEASE}"
|
122
|
+
end
|
123
|
+
|
124
|
+
version
|
125
|
+
end
|
126
|
+
|
127
|
+
# The full gem version string, including the {Branch::Version::MAJOR},
|
128
|
+
# {Branch::Version::MINOR}, {Branch::Version::PATCH}, and optionally, the
|
129
|
+
# `Branch::Version::PRERELEASE` in the
|
130
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
131
|
+
#
|
132
|
+
# @return [String] '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}'
|
133
|
+
# on master. '{Branch::Version::MAJOR}.{Branch::Version::MINOR}.{Branch::Version::PATCH}.PRERELEASE'
|
134
|
+
# on any branch other than master.
|
135
|
+
def self.gem
|
136
|
+
full.gsub('-', '.pre.')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# (see Version.gem)
|
141
|
+
GEM_VERSION = Version.gem
|
142
|
+
|
143
|
+
# (see Version.full)
|
144
|
+
VERSION = Version.full
|
145
|
+
end
|
146
|
+
|
147
|
+
"""
|
148
|
+
|
149
|
+
Examples:
|
150
|
+
| branch | prerelease |
|
151
|
+
| staging/flood-release | flood-release |
|
152
|
+
| bug/MSP-666/nasty | nasty |
|
153
|
+
| chore/MSP-1234/recurring | recurring |
|
154
|
+
| feature/MSP-1337/super-cool | super-cool |
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Feature: metasploit-version install's 'version_spec.rb' generates proper namespace from gem name
|
2
|
+
|
3
|
+
The version_spec.rb file from metasploit-version will use the fully-qualified name for the Version module under
|
4
|
+
the gem's namespace with proper conversion of underscored and dashes in the gem name to camel case and separate
|
5
|
+
modules, respectively
|
6
|
+
|
7
|
+
Scenario Outline:
|
8
|
+
Given I successfully run `bundle gem <gem_name>`
|
9
|
+
And I cd to "<gem_name>"
|
10
|
+
And my git identity is configured
|
11
|
+
And I successfully run `git commit --message "bundle gem <gem_name>"`
|
12
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
13
|
+
And I set the environment variables to:
|
14
|
+
| variable | value |
|
15
|
+
| TRAVIS_PULL_REQUEST | false |
|
16
|
+
When I successfully run `metasploit-version install --force --no-bundle-install`
|
17
|
+
Then the file "<version_spec_rb_path>" should contain exactly:
|
18
|
+
"""
|
19
|
+
RSpec.describe <fully_qualified_version_module> do
|
20
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
21
|
+
end
|
22
|
+
|
23
|
+
"""
|
24
|
+
|
25
|
+
Examples:
|
26
|
+
| gem_name | version_spec_rb_path | fully_qualified_version_module |
|
27
|
+
| single | spec/lib/single/version_spec.rb | Single::Version |
|
28
|
+
| two_words | spec/lib/two_words/version_spec.rb | TwoWords::Version |
|
29
|
+
| parent-child | spec/lib/parent/child/version_spec.rb | Parent::Child::Version |
|
30
|
+
| two_words-child | spec/lib/two_words/child/version_spec.rb | TwoWords::Child::Version |
|
31
|
+
| parent-two_words | spec/lib/parent/two_words/version_spec.rb | Parent::TwoWords::Version |
|
32
|
+
| two_words-more_words | spec/lib/two_words/more_words/version_spec.rb | TwoWords::MoreWords::Version |
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: metasploit-version install's 'version_spec.rb' catches when PRERELEASE is missing when branching from master
|
2
|
+
|
3
|
+
The version_spec.rb fiel from metasploit-version will catch errors if the user fails to add the PRERELEASE constant in
|
4
|
+
version.rb when branching from master.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I successfully run `bundle gem versioned`
|
8
|
+
And I cd to "versioned"
|
9
|
+
And my git identity is configured
|
10
|
+
And I successfully run `git commit --message "bundle gem versioned"`
|
11
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
12
|
+
And I set the environment variables to:
|
13
|
+
| variable | value |
|
14
|
+
| TRAVIS_PULL_REQUEST | false |
|
15
|
+
|
16
|
+
Scenario: Installing metasploit-version on feature branch
|
17
|
+
Given I successfully run `git checkout -b feature/MSP-1234/metasploit-version`
|
18
|
+
And I successfully run `metasploit-version install --force --no-bundle-install`
|
19
|
+
Then I successfully run `rake spec`
|
20
|
+
|
21
|
+
Scenario: Branching from master without adding PRERELEASE
|
22
|
+
And I successfully run `metasploit-version install --force --no-bundle-install`
|
23
|
+
And I successfully run `rake spec`
|
24
|
+
And I successfully run `git add *`
|
25
|
+
And I successfully run `git commit --all --message "metasploit-version install"`
|
26
|
+
And I successfully run `git checkout -b feature/MSP-1337/super-cool`
|
27
|
+
Then the file "lib/versioned/version.rb" should not contain " PRERELEASE ="
|
28
|
+
When I run `rake spec`
|
29
|
+
Then the exit status should not be 0
|
30
|
+
And the output should contain:
|
31
|
+
"""
|
32
|
+
expected Versioned::Version::PRERELEASE to be defined.
|
33
|
+
Add the following to Versioned::Version:
|
34
|
+
"""
|
35
|
+
And the output should contain:
|
36
|
+
"""
|
37
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
38
|
+
PRERELEASE = super-cool
|
39
|
+
"""
|
40
|
+
And the output should contain " 1 failure"
|
@@ -0,0 +1,161 @@
|
|
1
|
+
Feature: metasploit-version install's version_spec.rb catches errors with PRERELEASE when branching from another branch
|
2
|
+
|
3
|
+
The version_spec.rb file from metasploit-version will catch errors if the user fails to update the PRERELEASE
|
4
|
+
constant in version.rb to when going from one branch to another.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I successfully run `bundle gem double_branched`
|
8
|
+
And I cd to "double_branched"
|
9
|
+
And my git identity is configured
|
10
|
+
And I successfully run `git commit --message "bundle gem double_branched"`
|
11
|
+
And I unset the environment variable "TRAVIS_BRANCH"
|
12
|
+
And I set the environment variables to:
|
13
|
+
| variable | value |
|
14
|
+
| TRAVIS_PULL_REQUEST | false |
|
15
|
+
And I successfully run `metasploit-version install --force --no-bundle-install`
|
16
|
+
And I successfully run `rake spec`
|
17
|
+
And I successfully run `git add *`
|
18
|
+
And I successfully run `git commit --all --message "metasploit-version install"`
|
19
|
+
And I successfully run `git checkout -b feature/MSP-1337/super-cool`
|
20
|
+
And I overwrite "lib/double_branched/version.rb" with:
|
21
|
+
"""
|
22
|
+
module DoubleBranched
|
23
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
24
|
+
module Version
|
25
|
+
#
|
26
|
+
# CONSTANTS
|
27
|
+
#
|
28
|
+
|
29
|
+
# The major version number.
|
30
|
+
MAJOR = 0
|
31
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
32
|
+
MINOR = 0
|
33
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
34
|
+
PATCH = 1
|
35
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
|
36
|
+
PRERELEASE = 'super-cool'
|
37
|
+
|
38
|
+
#
|
39
|
+
# Module Methods
|
40
|
+
#
|
41
|
+
|
42
|
+
# The full version string, including the {DoubleBranched::Version::MAJOR},
|
43
|
+
# {DoubleBranched::Version::MINOR}, {DoubleBranched::Version::PATCH}, and optionally, the
|
44
|
+
# `DoubleBranched::Version::PRERELEASE` in the
|
45
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
46
|
+
#
|
47
|
+
# @return [String] '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}' on master.
|
48
|
+
# '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}-PRERELEASE'
|
49
|
+
# on any branch other than master.
|
50
|
+
def self.full
|
51
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
52
|
+
|
53
|
+
if defined? PRERELEASE
|
54
|
+
version = "#{version}-#{PRERELEASE}"
|
55
|
+
end
|
56
|
+
|
57
|
+
version
|
58
|
+
end
|
59
|
+
|
60
|
+
# The full gem version string, including the {DoubleBranched::Version::MAJOR},
|
61
|
+
# {DoubleBranched::Version::MINOR}, {DoubleBranched::Version::PATCH}, and optionally, the
|
62
|
+
# `DoubleBranched::Version::PRERELEASE` in the
|
63
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
64
|
+
#
|
65
|
+
# @return [String] '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}'
|
66
|
+
# on master. '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}.PRERELEASE'
|
67
|
+
# on any branch other than master.
|
68
|
+
def self.gem
|
69
|
+
full.gsub('-', '.pre.')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# (see Version.gem)
|
74
|
+
GEM_VERSION = Version.gem
|
75
|
+
|
76
|
+
# (see Version.full)
|
77
|
+
VERSION = Version.full
|
78
|
+
end
|
79
|
+
|
80
|
+
"""
|
81
|
+
And I successfully run `rake spec`
|
82
|
+
And I successfully run `git checkout -b bug/MSP-666/needed-for-super-cool`
|
83
|
+
|
84
|
+
Scenario: With changing PRERELEASE
|
85
|
+
Given I overwrite "lib/double_branched/version.rb" with:
|
86
|
+
"""
|
87
|
+
module DoubleBranched
|
88
|
+
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
89
|
+
module Version
|
90
|
+
#
|
91
|
+
# CONSTANTS
|
92
|
+
#
|
93
|
+
|
94
|
+
# The major version number.
|
95
|
+
MAJOR = 0
|
96
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
97
|
+
MINOR = 0
|
98
|
+
# The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
|
99
|
+
PATCH = 1
|
100
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
|
101
|
+
PRERELEASE = 'needed-for-super-cool'
|
102
|
+
|
103
|
+
#
|
104
|
+
# Module Methods
|
105
|
+
#
|
106
|
+
|
107
|
+
# The full version string, including the {DoubleBranched::Version::MAJOR},
|
108
|
+
# {DoubleBranched::Version::MINOR}, {DoubleBranched::Version::PATCH}, and optionally, the
|
109
|
+
# `DoubleBranched::Version::PRERELEASE` in the
|
110
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
111
|
+
#
|
112
|
+
# @return [String] '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}' on master.
|
113
|
+
# '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}-PRERELEASE'
|
114
|
+
# on any branch other than master.
|
115
|
+
def self.full
|
116
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
117
|
+
|
118
|
+
if defined? PRERELEASE
|
119
|
+
version = "#{version}-#{PRERELEASE}"
|
120
|
+
end
|
121
|
+
|
122
|
+
version
|
123
|
+
end
|
124
|
+
|
125
|
+
# The full gem version string, including the {DoubleBranched::Version::MAJOR},
|
126
|
+
# {DoubleBranched::Version::MINOR}, {DoubleBranched::Version::PATCH}, and optionally, the
|
127
|
+
# `DoubleBranched::Version::PRERELEASE` in the
|
128
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
129
|
+
#
|
130
|
+
# @return [String] '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}'
|
131
|
+
# on master. '{DoubleBranched::Version::MAJOR}.{DoubleBranched::Version::MINOR}.{DoubleBranched::Version::PATCH}.PRERELEASE'
|
132
|
+
# on any branch other than master.
|
133
|
+
def self.gem
|
134
|
+
full.gsub('-', '.pre.')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# (see Version.gem)
|
139
|
+
GEM_VERSION = Version.gem
|
140
|
+
|
141
|
+
# (see Version.full)
|
142
|
+
VERSION = Version.full
|
143
|
+
end
|
144
|
+
|
145
|
+
"""
|
146
|
+
Then I successfully run `rake spec`
|
147
|
+
|
148
|
+
Scenario: Without changing PRERELEASE
|
149
|
+
Given the file "lib/double_branched/version.rb" should contain:
|
150
|
+
"""
|
151
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version numbers.
|
152
|
+
PRERELEASE = 'super-cool'
|
153
|
+
"""
|
154
|
+
When I run `rake spec`
|
155
|
+
Then the exit status should not be 0
|
156
|
+
And the output should contain:
|
157
|
+
"""
|
158
|
+
expected: "needed-for-super-cool"
|
159
|
+
got: "super-cool"
|
160
|
+
"""
|
161
|
+
And the output should contain " 1 failure"
|