metasploit-version 0.1.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +32 -0
- data/.simplecov +60 -0
- data/.travis.yml +26 -0
- data/.yardopts +7 -0
- data/CONTRIBUTING.md +156 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +133 -0
- data/Rakefile +20 -0
- data/features/shared/examples/metasploit/version/gem_version_constant.feature +215 -0
- data/features/shared/examples/metasploit/version/version_constant.feature +183 -0
- data/features/shared/examples/metasploit/version/version_module.feature +275 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/git/branch.feature +234 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/git/detached_head.feature +97 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/git/master.feature +94 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/git/step_definitions/environment_variable_steps.rb +13 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/git/step_definitions/git_steps.rb +30 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/branch.feature +173 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/master.feature +90 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/pull_request.feature +99 -0
- data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/tag.feature +277 -0
- data/features/support/env.rb +41 -0
- data/features/support/simplecov_setup.rb +12 -0
- data/lib/metasploit/version.rb +19 -0
- data/lib/metasploit/version/branch.rb +172 -0
- data/lib/metasploit/version/version.rb +57 -0
- data/metasploit-version.gemspec +41 -0
- data/spec/lib/metasploit/version/branch_spec.rb +660 -0
- data/spec/lib/metasploit/version/version_spec.rb +5 -0
- data/spec/lib/metasploit/version_spec.rb +6 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/shared/examples/metasploit/version/gem_version_constant.rb +17 -0
- data/spec/support/shared/examples/metasploit/version/version_constant.rb +17 -0
- data/spec/support/shared/examples/metasploit/version/version_module.rb +226 -0
- metadata +173 -0
data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/branch.feature
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in branch build on Travis-CI
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file defines PRERELEASE to match the relative name of branch.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I set the environment variables to:
|
8
|
+
| variable | value |
|
9
|
+
| TRAVIS_PULL_REQUEST | false |
|
10
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
11
|
+
"""ruby
|
12
|
+
require 'my_namespace/my_gem/version'
|
13
|
+
|
14
|
+
module MyNamespace
|
15
|
+
module MyGem
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
Given a file named "spec/spec_helper.rb" with:
|
20
|
+
"""ruby
|
21
|
+
require 'metasploit/version'
|
22
|
+
require 'my_namespace/my_gem'
|
23
|
+
|
24
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
25
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
26
|
+
|
27
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
28
|
+
require f
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
32
|
+
"""ruby
|
33
|
+
require 'spec_helper'
|
34
|
+
|
35
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
36
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario Outline: PRERELEASE defined as branch relative name
|
41
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
42
|
+
"""ruby
|
43
|
+
module MyNamespace
|
44
|
+
module MyGem
|
45
|
+
module Version
|
46
|
+
#
|
47
|
+
# CONSTANTS
|
48
|
+
#
|
49
|
+
|
50
|
+
# The major version number
|
51
|
+
MAJOR = 1
|
52
|
+
|
53
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
54
|
+
MINOR = 2
|
55
|
+
|
56
|
+
# The patch number, scoped to the {MINOR} version number
|
57
|
+
PATCH = 3
|
58
|
+
|
59
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
60
|
+
PRERELEASE = '<prerelease>'
|
61
|
+
|
62
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
63
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
64
|
+
#
|
65
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
66
|
+
# other than master.
|
67
|
+
def self.full
|
68
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
69
|
+
|
70
|
+
if defined? PRERELEASE
|
71
|
+
version = "#{version}-#{PRERELEASE}"
|
72
|
+
end
|
73
|
+
|
74
|
+
version
|
75
|
+
end
|
76
|
+
|
77
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
78
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
79
|
+
#
|
80
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
81
|
+
# other than master.
|
82
|
+
def self.gem
|
83
|
+
full.gsub('-', '.pre.')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
"""
|
89
|
+
Given I set the environment variables to:
|
90
|
+
| variable | value |
|
91
|
+
| TRAVIS_BRANCH | <branch> |
|
92
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
93
|
+
Then the output should contain:
|
94
|
+
"""
|
95
|
+
PRERELEASE
|
96
|
+
matches the <type> branch's name
|
97
|
+
"""
|
98
|
+
|
99
|
+
Examples:
|
100
|
+
| type | prerelease | branch |
|
101
|
+
| bug | nasty | bug/MSP-1234/nasty |
|
102
|
+
| feature | super-cool | feature/MSP-1234/super-cool |
|
103
|
+
| staging | rocket-motor | staging/rocket-motor |
|
104
|
+
|
105
|
+
Scenario Outline: PRERELEASE not defined
|
106
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
107
|
+
"""ruby
|
108
|
+
module MyNamespace
|
109
|
+
module MyGem
|
110
|
+
module Version
|
111
|
+
#
|
112
|
+
# CONSTANTS
|
113
|
+
#
|
114
|
+
|
115
|
+
# The major version number
|
116
|
+
MAJOR = 1
|
117
|
+
|
118
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
119
|
+
MINOR = 2
|
120
|
+
|
121
|
+
# The patch number, scoped to the {MINOR} version number
|
122
|
+
PATCH = 3
|
123
|
+
|
124
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
125
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
126
|
+
#
|
127
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
128
|
+
# other than master.
|
129
|
+
def self.full
|
130
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
131
|
+
|
132
|
+
if defined? PRERELEASE
|
133
|
+
version = "#{version}-#{PRERELEASE}"
|
134
|
+
end
|
135
|
+
|
136
|
+
version
|
137
|
+
end
|
138
|
+
|
139
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
140
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
141
|
+
#
|
142
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
143
|
+
# other than master.
|
144
|
+
def self.gem
|
145
|
+
full.gsub('-', '.pre.')
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
"""
|
151
|
+
Given I set the environment variables to:
|
152
|
+
| variable | value |
|
153
|
+
| TRAVIS_BRANCH | <branch> |
|
154
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
155
|
+
Then the output should contain "MyNamespace::MyGem::Version it should behave like Metasploit::Version Version Module CONSTANTS PRERELEASE matches the <type> branch's name"
|
156
|
+
And the output should contain:
|
157
|
+
"""
|
158
|
+
expected MyNamespace::MyGem::Version::PRERELEASE to be defined.
|
159
|
+
Add the following to MyNamespace::MyGem::Version:
|
160
|
+
"""
|
161
|
+
# Can't do a continuous multiline string because editors will truncate whitespace in blank line and it won't match
|
162
|
+
# whitespace in rspec output.
|
163
|
+
And the output should contain:
|
164
|
+
"""
|
165
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
166
|
+
PRERELEASE = <prerelease>
|
167
|
+
"""
|
168
|
+
|
169
|
+
Examples:
|
170
|
+
| type | prerelease | branch |
|
171
|
+
| bug | nasty | bug/MSP-1234/nasty |
|
172
|
+
| feature | super-cool | feature/MSP-1234/super-cool |
|
173
|
+
| staging | rocket-motor | staging/rocket-motor |
|
data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/master.feature
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in master build on Travis-CI
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file does not define PRERELEASE.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
8
|
+
"""ruby
|
9
|
+
require 'my_namespace/my_gem/version'
|
10
|
+
|
11
|
+
module MyNamespace
|
12
|
+
module MyGem
|
13
|
+
end
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
Given a file named "spec/spec_helper.rb" with:
|
17
|
+
"""ruby
|
18
|
+
require 'metasploit/version'
|
19
|
+
require 'my_namespace/my_gem'
|
20
|
+
|
21
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
22
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
23
|
+
|
24
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
25
|
+
require f
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
29
|
+
"""ruby
|
30
|
+
require 'spec_helper'
|
31
|
+
|
32
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
33
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
Given I set the environment variables to:
|
37
|
+
| variable | value |
|
38
|
+
| TRAVIS_BRANCH | master |
|
39
|
+
| TRAVIS_PULL_REQUEST | false |
|
40
|
+
Scenario: PRERELEASE defined
|
41
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
42
|
+
"""ruby
|
43
|
+
module MyNamespace
|
44
|
+
module MyGem
|
45
|
+
module Version
|
46
|
+
#
|
47
|
+
# CONSTANTS
|
48
|
+
#
|
49
|
+
|
50
|
+
# The major version number
|
51
|
+
MAJOR = 1
|
52
|
+
|
53
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
54
|
+
MINOR = 2
|
55
|
+
|
56
|
+
# The patch number, scoped to the {MINOR} version number
|
57
|
+
PATCH = 3
|
58
|
+
|
59
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
60
|
+
PRERELEASE = 'source-branch-relative-name'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
66
|
+
Then the output should contain "expected MyNamespace::MyGem::Version::PRERELEASE not to be defined on master"
|
67
|
+
Scenario: PRERELEASE undefined
|
68
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
69
|
+
"""ruby
|
70
|
+
module MyNamespace
|
71
|
+
module MyGem
|
72
|
+
module Version
|
73
|
+
#
|
74
|
+
# CONSTANTS
|
75
|
+
#
|
76
|
+
|
77
|
+
# The major version number
|
78
|
+
MAJOR = 1
|
79
|
+
|
80
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
81
|
+
MINOR = 2
|
82
|
+
|
83
|
+
# The patch number, scoped to the {MINOR} version number
|
84
|
+
PATCH = 3
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
"""
|
89
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
90
|
+
Then the output should not contain "expected MyNamespace::MyGem::Version::PRERELEASE not to be defined on master"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in pull request build on Travis-CI
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example won't check PRERELEASE for pull request builds on Travis-CI
|
4
|
+
because the code is expected to have PRERELEASE set to the value appropriate to the source branch and not the
|
5
|
+
destination branch being built by the pull request build.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I unset the environment variable "TRAVIS_BRANCH"
|
9
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
10
|
+
"""ruby
|
11
|
+
require 'my_namespace/my_gem/version'
|
12
|
+
|
13
|
+
module MyNamespace
|
14
|
+
module MyGem
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
Given a file named "spec/spec_helper.rb" with:
|
19
|
+
"""ruby
|
20
|
+
require 'metasploit/version'
|
21
|
+
require 'my_namespace/my_gem'
|
22
|
+
|
23
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
24
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
25
|
+
|
26
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
27
|
+
require f
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
31
|
+
"""ruby
|
32
|
+
require 'spec_helper'
|
33
|
+
|
34
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
35
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
Given I set the environment variables to:
|
39
|
+
| variable | value |
|
40
|
+
| TRAVIS_BRANCH | master |
|
41
|
+
|
42
|
+
Scenario: PRERELEASE set to source branch relative name
|
43
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
44
|
+
"""ruby
|
45
|
+
module MyNamespace
|
46
|
+
module MyGem
|
47
|
+
module Version
|
48
|
+
#
|
49
|
+
# CONSTANTS
|
50
|
+
#
|
51
|
+
|
52
|
+
# The major version number
|
53
|
+
MAJOR = 1
|
54
|
+
|
55
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
56
|
+
MINOR = 2
|
57
|
+
|
58
|
+
# The patch number, scoped to the {MINOR} version number
|
59
|
+
PATCH = 3
|
60
|
+
|
61
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
62
|
+
PRERELEASE = 'source-branch-relative-name'
|
63
|
+
|
64
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
65
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
66
|
+
#
|
67
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
68
|
+
# other than master.
|
69
|
+
def self.full
|
70
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
71
|
+
|
72
|
+
if defined? PRERELEASE
|
73
|
+
version = "#{version}-#{PRERELEASE}"
|
74
|
+
end
|
75
|
+
|
76
|
+
version
|
77
|
+
end
|
78
|
+
|
79
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
80
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
81
|
+
#
|
82
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
83
|
+
# other than master.
|
84
|
+
def self.gem
|
85
|
+
full.gsub('-', '.pre.')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
"""
|
91
|
+
Given I set the environment variables to:
|
92
|
+
| variable | value |
|
93
|
+
| TRAVIS_PULL_REQUEST | true |
|
94
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
95
|
+
Then the output should contain:
|
96
|
+
"""
|
97
|
+
PRERELEASE
|
98
|
+
is not defined (PENDING: PRERELEASE can only be set appropriately for a merge by merging to the target branch and then updating PRERELEASE on the target branch before committing and/or pushing to github and travis-ci.)
|
99
|
+
"""
|
data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/tag.feature
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in tag build on Travis-CI
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file defines PRERELEASE to match the prerelease part of the tag converted from the gem prerelease format.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I set the environment variables to:
|
8
|
+
| variable | value |
|
9
|
+
| TRAVIS_PULL_REQUEST | false |
|
10
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
11
|
+
"""ruby
|
12
|
+
require 'my_namespace/my_gem/version'
|
13
|
+
|
14
|
+
module MyNamespace
|
15
|
+
module MyGem
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
Given a file named "spec/spec_helper.rb" with:
|
20
|
+
"""ruby
|
21
|
+
require 'metasploit/version'
|
22
|
+
require 'my_namespace/my_gem'
|
23
|
+
|
24
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
25
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
26
|
+
|
27
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
28
|
+
require f
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
32
|
+
"""ruby
|
33
|
+
require 'spec_helper'
|
34
|
+
|
35
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
36
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario Outline: PRERELEASE defined as tag relative name
|
41
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
42
|
+
"""ruby
|
43
|
+
module MyNamespace
|
44
|
+
module MyGem
|
45
|
+
module Version
|
46
|
+
#
|
47
|
+
# CONSTANTS
|
48
|
+
#
|
49
|
+
|
50
|
+
# The major version number
|
51
|
+
MAJOR = 1
|
52
|
+
|
53
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
54
|
+
MINOR = 2
|
55
|
+
|
56
|
+
# The patch number, scoped to the {MINOR} version number
|
57
|
+
PATCH = 3
|
58
|
+
|
59
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
60
|
+
PRERELEASE = '<prerelease>'
|
61
|
+
|
62
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
63
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
64
|
+
#
|
65
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
66
|
+
# other than master.
|
67
|
+
def self.full
|
68
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
69
|
+
|
70
|
+
if defined? PRERELEASE
|
71
|
+
version = "#{version}-#{PRERELEASE}"
|
72
|
+
end
|
73
|
+
|
74
|
+
version
|
75
|
+
end
|
76
|
+
|
77
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
78
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
79
|
+
#
|
80
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
81
|
+
# other than master.
|
82
|
+
def self.gem
|
83
|
+
full.gsub('-', '.pre.')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
"""
|
89
|
+
Given I set the environment variables to:
|
90
|
+
| variable | value |
|
91
|
+
| TRAVIS_BRANCH | <tag> |
|
92
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
93
|
+
Then the output should contain:
|
94
|
+
"""
|
95
|
+
PRERELEASE
|
96
|
+
matches the tag prerelease converted from a gem version to a VERSION
|
97
|
+
"""
|
98
|
+
|
99
|
+
Examples:
|
100
|
+
| prerelease | tag |
|
101
|
+
| nasty | v1.2.3.pre.nasty |
|
102
|
+
| super-cool | v1.2.3.pre.super.pre.cool |
|
103
|
+
|
104
|
+
Scenario Outline: PRERELEASE not defined as tag relative name
|
105
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
106
|
+
"""ruby
|
107
|
+
module MyNamespace
|
108
|
+
module MyGem
|
109
|
+
module Version
|
110
|
+
#
|
111
|
+
# CONSTANTS
|
112
|
+
#
|
113
|
+
|
114
|
+
# The major version number
|
115
|
+
MAJOR = 1
|
116
|
+
|
117
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
118
|
+
MINOR = 2
|
119
|
+
|
120
|
+
# The patch number, scoped to the {MINOR} version number
|
121
|
+
PATCH = 3
|
122
|
+
|
123
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
124
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
125
|
+
#
|
126
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
127
|
+
# other than master.
|
128
|
+
def self.full
|
129
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
130
|
+
|
131
|
+
if defined? PRERELEASE
|
132
|
+
version = "#{version}-#{PRERELEASE}"
|
133
|
+
end
|
134
|
+
|
135
|
+
version
|
136
|
+
end
|
137
|
+
|
138
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
139
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
140
|
+
#
|
141
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
142
|
+
# other than master.
|
143
|
+
def self.gem
|
144
|
+
full.gsub('-', '.pre.')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
"""
|
150
|
+
Given I set the environment variables to:
|
151
|
+
| variable | value |
|
152
|
+
| TRAVIS_BRANCH | <tag> |
|
153
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
154
|
+
Then the output should contain "MyNamespace::MyGem::Version it should behave like Metasploit::Version Version Module CONSTANTS PRERELEASE matches the tag prerelease converted from a gem version to a VERSION"
|
155
|
+
And the output should contain:
|
156
|
+
"""
|
157
|
+
expected MyNamespace::MyGem::Version::PRERELEASE to be defined.
|
158
|
+
Add the following to MyNamespace::MyGem::Version:
|
159
|
+
"""
|
160
|
+
# Can't do a continuous multiline string because editors will truncate whitespace in blank line and it won't match
|
161
|
+
# whitespace in rspec output.
|
162
|
+
And the output should contain:
|
163
|
+
"""
|
164
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
165
|
+
PRERELEASE = <prerelease>
|
166
|
+
"""
|
167
|
+
|
168
|
+
Examples:
|
169
|
+
| prerelease | tag |
|
170
|
+
| nasty | v1.2.3.pre.nasty |
|
171
|
+
| super-cool | v1.2.3.pre.super.pre.cool |
|
172
|
+
|
173
|
+
Scenario: PRERELEASE defined on release tag
|
174
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
175
|
+
"""ruby
|
176
|
+
module MyNamespace
|
177
|
+
module MyGem
|
178
|
+
module Version
|
179
|
+
#
|
180
|
+
# CONSTANTS
|
181
|
+
#
|
182
|
+
|
183
|
+
# The major version number
|
184
|
+
MAJOR = 1
|
185
|
+
|
186
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
187
|
+
MINOR = 2
|
188
|
+
|
189
|
+
# The patch number, scoped to the {MINOR} version number
|
190
|
+
PATCH = 3
|
191
|
+
|
192
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
193
|
+
PRERELEASE = 'left-over-from-branch'
|
194
|
+
|
195
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
196
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
197
|
+
#
|
198
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
199
|
+
# other than master.
|
200
|
+
def self.full
|
201
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
202
|
+
|
203
|
+
if defined? PRERELEASE
|
204
|
+
version = "#{version}-#{PRERELEASE}"
|
205
|
+
end
|
206
|
+
|
207
|
+
version
|
208
|
+
end
|
209
|
+
|
210
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
211
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
212
|
+
#
|
213
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
214
|
+
# other than master.
|
215
|
+
def self.gem
|
216
|
+
full.gsub('-', '.pre.')
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
"""
|
222
|
+
Given I set the environment variables to:
|
223
|
+
| variable | value |
|
224
|
+
| TRAVIS_BRANCH | v1.2.3 |
|
225
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
226
|
+
Then the output should contain "expected MyNamespace::MyGem::Version::PRERELEASE not to be defined on master"
|
227
|
+
|
228
|
+
Scenario: PRERELEASE not defined on release tag
|
229
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
230
|
+
"""ruby
|
231
|
+
module MyNamespace
|
232
|
+
module MyGem
|
233
|
+
module Version
|
234
|
+
#
|
235
|
+
# CONSTANTS
|
236
|
+
#
|
237
|
+
|
238
|
+
# The major version number
|
239
|
+
MAJOR = 1
|
240
|
+
|
241
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
242
|
+
MINOR = 2
|
243
|
+
|
244
|
+
# The patch number, scoped to the {MINOR} version number
|
245
|
+
PATCH = 3
|
246
|
+
|
247
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
248
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
249
|
+
#
|
250
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
251
|
+
# other than master.
|
252
|
+
def self.full
|
253
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
254
|
+
|
255
|
+
if defined? PRERELEASE
|
256
|
+
version = "#{version}-#{PRERELEASE}"
|
257
|
+
end
|
258
|
+
|
259
|
+
version
|
260
|
+
end
|
261
|
+
|
262
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
263
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
264
|
+
#
|
265
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
266
|
+
# other than master.
|
267
|
+
def self.gem
|
268
|
+
full.gsub('-', '.pre.')
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
"""
|
274
|
+
Given I set the environment variables to:
|
275
|
+
| variable | value |
|
276
|
+
| TRAVIS_BRANCH | v1.2.3 |
|
277
|
+
Then I successfully run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|