metasploit-version 0.1.2-java
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 +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/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
7
|
+
|
8
|
+
require 'cucumber'
|
9
|
+
require 'cucumber/rake/task'
|
10
|
+
|
11
|
+
Cucumber::Rake::Task.new do |t|
|
12
|
+
t.cucumber_opts = 'features --format pretty'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
16
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
|
17
|
+
|
18
|
+
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
|
19
|
+
load rake
|
20
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
Feature: 'Metasploit::Version VERSION constant' shared example
|
2
|
+
|
3
|
+
The 'Metasploit::Version VERSION constant' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file has a VERSION constant equal to described_class::Version.full, which indicates that VERSION is setup to
|
5
|
+
use the full module method.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
9
|
+
"""ruby
|
10
|
+
require 'my_namespace/my_gem/version'
|
11
|
+
|
12
|
+
module MyNamespace
|
13
|
+
module MyGem
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
Given a file named "spec/spec_helper.rb" with:
|
18
|
+
"""ruby
|
19
|
+
require 'metasploit/version'
|
20
|
+
require 'my_namespace/my_gem'
|
21
|
+
|
22
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
23
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
24
|
+
|
25
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
26
|
+
require f
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
Given a file named "spec/lib/my_namespace/my_gem_spec.rb" with:
|
30
|
+
"""ruby
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
RSpec.describe MyNamespace::MyGem do
|
34
|
+
it_should_behave_like 'Metasploit::Version GEM_VERSION constant'
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
|
38
|
+
Scenario: GEM_VERSION is not defined
|
39
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
40
|
+
"""ruby
|
41
|
+
require 'metasploit/version'
|
42
|
+
|
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
|
+
#
|
63
|
+
# Module Methods
|
64
|
+
#
|
65
|
+
|
66
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
67
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
68
|
+
#
|
69
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
70
|
+
# other than master.
|
71
|
+
def self.full
|
72
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
73
|
+
|
74
|
+
if defined? PRERELEASE
|
75
|
+
version = "#{version}-#{PRERELEASE}"
|
76
|
+
end
|
77
|
+
|
78
|
+
version
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# (see Version.full)
|
83
|
+
VERSION = Version.full
|
84
|
+
end
|
85
|
+
end
|
86
|
+
"""
|
87
|
+
When I run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
88
|
+
Then the output should contain "expected MyNamespace::MyGem::GEM_VERSION to be defined"
|
89
|
+
|
90
|
+
Scenario: GEM_VERSION is not equal to Version.gem
|
91
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
92
|
+
"""ruby
|
93
|
+
require 'metasploit/version'
|
94
|
+
|
95
|
+
module MyNamespace
|
96
|
+
module MyGem
|
97
|
+
module Version
|
98
|
+
#
|
99
|
+
# CONSTANTS
|
100
|
+
#
|
101
|
+
|
102
|
+
# The major version number
|
103
|
+
MAJOR = 1
|
104
|
+
|
105
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
106
|
+
MINOR = 2
|
107
|
+
|
108
|
+
# The patch number, scoped to the {MINOR} version number.
|
109
|
+
PATCH = 3
|
110
|
+
|
111
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
112
|
+
PRERELEASE = 'prerelease'
|
113
|
+
|
114
|
+
#
|
115
|
+
# Module Methods
|
116
|
+
#
|
117
|
+
|
118
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
119
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
120
|
+
#
|
121
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
122
|
+
# other than master.
|
123
|
+
def self.full
|
124
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
125
|
+
|
126
|
+
if defined? PRERELEASE
|
127
|
+
version = "#{version}-#{PRERELEASE}"
|
128
|
+
end
|
129
|
+
|
130
|
+
version
|
131
|
+
end
|
132
|
+
|
133
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
134
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
135
|
+
#
|
136
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
137
|
+
# other than master.
|
138
|
+
def self.gem
|
139
|
+
full.gsub('-', '.pre.')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# (see Version.full)
|
144
|
+
GEM_VERSION = Version.full
|
145
|
+
|
146
|
+
# (see Version.full)
|
147
|
+
VERSION = Version.full
|
148
|
+
end
|
149
|
+
end
|
150
|
+
"""
|
151
|
+
When I run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
152
|
+
Then the output should contain "expected MyNamespace::MyGem::GEM_VERSION to equal MyNamespace::MyGem::Version.gem"
|
153
|
+
|
154
|
+
Scenario: GEM_VERSION is equal to Version.gem
|
155
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
156
|
+
"""ruby
|
157
|
+
require 'metasploit/version'
|
158
|
+
|
159
|
+
module MyNamespace
|
160
|
+
module MyGem
|
161
|
+
module Version
|
162
|
+
#
|
163
|
+
# CONSTANTS
|
164
|
+
#
|
165
|
+
|
166
|
+
# The major version number
|
167
|
+
MAJOR = 1
|
168
|
+
|
169
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
170
|
+
MINOR = 2
|
171
|
+
|
172
|
+
# The patch number, scoped to the {MINOR} version number.
|
173
|
+
PATCH = 3
|
174
|
+
|
175
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
176
|
+
PRERELEASE = 'prerelease'
|
177
|
+
|
178
|
+
#
|
179
|
+
# Module Methods
|
180
|
+
#
|
181
|
+
|
182
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
183
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
184
|
+
#
|
185
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
186
|
+
# other than master.
|
187
|
+
def self.full
|
188
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
189
|
+
|
190
|
+
if defined? PRERELEASE
|
191
|
+
version = "#{version}-#{PRERELEASE}"
|
192
|
+
end
|
193
|
+
|
194
|
+
version
|
195
|
+
end
|
196
|
+
|
197
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
198
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
199
|
+
#
|
200
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
201
|
+
# other than master.
|
202
|
+
def self.gem
|
203
|
+
full.gsub('-', '.pre.')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# (see Version.gem)
|
208
|
+
GEM_VERSION = Version.gem
|
209
|
+
|
210
|
+
# (see Version.full)
|
211
|
+
VERSION = Version.full
|
212
|
+
end
|
213
|
+
end
|
214
|
+
"""
|
215
|
+
Then I successfully run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
@@ -0,0 +1,183 @@
|
|
1
|
+
Feature: 'Metasploit::Version VERSION constant' shared example
|
2
|
+
|
3
|
+
The 'Metasploit::Version VERSION constant' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file has a VERSION constant equal to described_class::Version.full, which indicates that VERSION is setup to
|
5
|
+
use the full module method.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
9
|
+
"""ruby
|
10
|
+
require 'my_namespace/my_gem/version'
|
11
|
+
|
12
|
+
module MyNamespace
|
13
|
+
module MyGem
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
Given a file named "spec/spec_helper.rb" with:
|
18
|
+
"""ruby
|
19
|
+
require 'metasploit/version'
|
20
|
+
require 'my_namespace/my_gem'
|
21
|
+
|
22
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
23
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
24
|
+
|
25
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
26
|
+
require f
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
Given a file named "spec/lib/my_namespace/my_gem_spec.rb" with:
|
30
|
+
"""ruby
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
RSpec.describe MyNamespace::MyGem do
|
34
|
+
it_should_behave_like 'Metasploit::Version VERSION constant'
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
Scenario: VERSION is not defined
|
38
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
39
|
+
"""ruby
|
40
|
+
require 'metasploit/version'
|
41
|
+
|
42
|
+
module MyNamespace
|
43
|
+
module MyGem
|
44
|
+
module Version
|
45
|
+
#
|
46
|
+
# CONSTANTS
|
47
|
+
#
|
48
|
+
|
49
|
+
# The major version number
|
50
|
+
MAJOR = 1
|
51
|
+
|
52
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
53
|
+
MINOR = 2
|
54
|
+
|
55
|
+
# The patch number, scoped to the {MINOR} version number.
|
56
|
+
PATCH = 3
|
57
|
+
|
58
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
59
|
+
PRERELEASE = 'prerelease'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
"""
|
64
|
+
When I run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
65
|
+
Then the output should contain "expected MyNamespace::MyGem::VERSION to be defined"
|
66
|
+
Scenario: VERSION is not equal to Version.full
|
67
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
68
|
+
"""ruby
|
69
|
+
require 'metasploit/version'
|
70
|
+
|
71
|
+
module MyNamespace
|
72
|
+
module MyGem
|
73
|
+
module Version
|
74
|
+
#
|
75
|
+
# CONSTANTS
|
76
|
+
#
|
77
|
+
|
78
|
+
# The major version number
|
79
|
+
MAJOR = 1
|
80
|
+
|
81
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
82
|
+
MINOR = 2
|
83
|
+
|
84
|
+
# The patch number, scoped to the {MINOR} version number.
|
85
|
+
PATCH = 3
|
86
|
+
|
87
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
88
|
+
PRERELEASE = 'prerelease'
|
89
|
+
|
90
|
+
#
|
91
|
+
# Module Methods
|
92
|
+
#
|
93
|
+
|
94
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
95
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
96
|
+
#
|
97
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
98
|
+
# other than master.
|
99
|
+
def self.full
|
100
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
101
|
+
|
102
|
+
if defined? PRERELEASE
|
103
|
+
version = "#{version}-#{PRERELEASE}"
|
104
|
+
end
|
105
|
+
|
106
|
+
version
|
107
|
+
end
|
108
|
+
|
109
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
110
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
111
|
+
#
|
112
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
113
|
+
# other than master.
|
114
|
+
def self.gem
|
115
|
+
full.gsub('-', '.pre.')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
VERSION = '7.8.9'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
"""
|
123
|
+
When I run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
124
|
+
Then the output should contain "expected MyNamespace::MyGem::VERSION to equal MyNamespace::MyGem::Version.full"
|
125
|
+
|
126
|
+
Scenario: VERSION is equal to Version.full
|
127
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
128
|
+
"""ruby
|
129
|
+
require 'metasploit/version'
|
130
|
+
|
131
|
+
module MyNamespace
|
132
|
+
module MyGem
|
133
|
+
module Version
|
134
|
+
#
|
135
|
+
# CONSTANTS
|
136
|
+
#
|
137
|
+
|
138
|
+
# The major version number
|
139
|
+
MAJOR = 1
|
140
|
+
|
141
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
142
|
+
MINOR = 2
|
143
|
+
|
144
|
+
# The patch number, scoped to the {MINOR} version number.
|
145
|
+
PATCH = 3
|
146
|
+
|
147
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
148
|
+
PRERELEASE = 'prerelease'
|
149
|
+
|
150
|
+
#
|
151
|
+
# Module Methods
|
152
|
+
#
|
153
|
+
|
154
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
155
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
156
|
+
#
|
157
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
158
|
+
# other than master.
|
159
|
+
def self.full
|
160
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
161
|
+
|
162
|
+
if defined? PRERELEASE
|
163
|
+
version = "#{version}-#{PRERELEASE}"
|
164
|
+
end
|
165
|
+
|
166
|
+
version
|
167
|
+
end
|
168
|
+
|
169
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
170
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
171
|
+
#
|
172
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
173
|
+
# other than master.
|
174
|
+
def self.gem
|
175
|
+
full.gsub('-', '.pre.')
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
VERSION = Version.full
|
180
|
+
end
|
181
|
+
end
|
182
|
+
"""
|
183
|
+
Then I successfully run `rspec spec/lib/my_namespace/my_gem_spec.rb --format documentation`
|
@@ -0,0 +1,275 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example will check that the described_class for an RSpec *_spec.rb
|
4
|
+
file defined the MAJOR, MINOR, and PATCH constants as Integers; the full module method combines those constants
|
5
|
+
(and PRERELEASE when present) into a version string; and
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
9
|
+
"""ruby
|
10
|
+
require 'my_namespace/my_gem/version'
|
11
|
+
|
12
|
+
module MyNamespace
|
13
|
+
module MyGem
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
Given a file named "spec/spec_helper.rb" with:
|
18
|
+
"""ruby
|
19
|
+
require 'metasploit/version'
|
20
|
+
require 'my_namespace/my_gem'
|
21
|
+
|
22
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
23
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
24
|
+
|
25
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
26
|
+
require f
|
27
|
+
end
|
28
|
+
"""
|
29
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
30
|
+
"""ruby
|
31
|
+
require 'spec_helper'
|
32
|
+
|
33
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
34
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
|
38
|
+
Scenario: With String MAJOR, MINOR, and PATCH
|
39
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
40
|
+
"""ruby
|
41
|
+
module MyNamespace
|
42
|
+
module MyGem
|
43
|
+
module Version
|
44
|
+
#
|
45
|
+
# Constants
|
46
|
+
#
|
47
|
+
|
48
|
+
# The major version number
|
49
|
+
MAJOR = '1'
|
50
|
+
|
51
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
52
|
+
MINOR = '2'
|
53
|
+
|
54
|
+
# The patch number, scoped to the {MINOR} version number
|
55
|
+
PATCH = '3'
|
56
|
+
|
57
|
+
#
|
58
|
+
# Module Methods
|
59
|
+
#
|
60
|
+
|
61
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
62
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
63
|
+
#
|
64
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
65
|
+
# other than master.
|
66
|
+
def self.full
|
67
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
68
|
+
|
69
|
+
if defined? PRERELEASE
|
70
|
+
version = "#{version}-#{PRERELEASE}"
|
71
|
+
end
|
72
|
+
|
73
|
+
version
|
74
|
+
end
|
75
|
+
|
76
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
77
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
78
|
+
#
|
79
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
80
|
+
# other than master.
|
81
|
+
def self.gem
|
82
|
+
full.gsub('-', '.pre.')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
"""
|
88
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
89
|
+
Then the output should contain:
|
90
|
+
"""
|
91
|
+
expected "1" to be a kind of Integer
|
92
|
+
"""
|
93
|
+
And the output should contain:
|
94
|
+
"""
|
95
|
+
expected "2" to be a kind of Integer
|
96
|
+
"""
|
97
|
+
And the output should contain:
|
98
|
+
"""
|
99
|
+
expected "3" to be a kind of Integer
|
100
|
+
"""
|
101
|
+
|
102
|
+
Scenario: Without full method, example implementation is given
|
103
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
104
|
+
"""ruby
|
105
|
+
module MyNamespace
|
106
|
+
module MyGem
|
107
|
+
module Version
|
108
|
+
#
|
109
|
+
# Constants
|
110
|
+
#
|
111
|
+
|
112
|
+
# The major version number
|
113
|
+
MAJOR = 1
|
114
|
+
|
115
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
116
|
+
MINOR = 2
|
117
|
+
|
118
|
+
# The patch number, scoped to the {MINOR} version number
|
119
|
+
PATCH = 3
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
"""
|
124
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
125
|
+
# Need to break up the expected message due to blank lines in expected output
|
126
|
+
Then the output should contain:
|
127
|
+
"""
|
128
|
+
expected MyNamespace::MyGem::Version to define self.full().
|
129
|
+
Add the following to MyNamespace::MyGem::Version
|
130
|
+
"""
|
131
|
+
And the output should contain:
|
132
|
+
"""
|
133
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
134
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
135
|
+
#
|
136
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
137
|
+
# other than master.
|
138
|
+
def self.full
|
139
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
140
|
+
"""
|
141
|
+
And the output should contain:
|
142
|
+
"""
|
143
|
+
if defined? PRERELEASE
|
144
|
+
version = "#{version}-#{PRERELEASE}"
|
145
|
+
end
|
146
|
+
"""
|
147
|
+
And the output should contain:
|
148
|
+
"""
|
149
|
+
version
|
150
|
+
end
|
151
|
+
"""
|
152
|
+
|
153
|
+
Scenario: Without gem method, example implementation is given
|
154
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
155
|
+
"""ruby
|
156
|
+
module MyNamespace
|
157
|
+
module MyGem
|
158
|
+
module Version
|
159
|
+
#
|
160
|
+
# Constants
|
161
|
+
#
|
162
|
+
|
163
|
+
# The major version number
|
164
|
+
MAJOR = 1
|
165
|
+
|
166
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
167
|
+
MINOR = 2
|
168
|
+
|
169
|
+
# The patch number, scoped to the {MINOR} version number
|
170
|
+
PATCH = 3
|
171
|
+
|
172
|
+
#
|
173
|
+
# Module Methods
|
174
|
+
#
|
175
|
+
|
176
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
177
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
178
|
+
#
|
179
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
180
|
+
# other than master.
|
181
|
+
def self.full
|
182
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
183
|
+
|
184
|
+
if defined? PRERELEASE
|
185
|
+
version = "#{version}-#{PRERELEASE}"
|
186
|
+
end
|
187
|
+
|
188
|
+
version
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
"""
|
194
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
195
|
+
Then the output should contain "Add the following to MyNamespace::MyGem::Version:"
|
196
|
+
And the output should contain:
|
197
|
+
"""
|
198
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
199
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
200
|
+
#
|
201
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
202
|
+
# other than master.
|
203
|
+
def self.gem
|
204
|
+
full.gsub('-', '.pre.')
|
205
|
+
end
|
206
|
+
"""
|
207
|
+
Scenario: With integer MAJOR, MINOR, PATCH and both full and gem methods
|
208
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
209
|
+
"""ruby
|
210
|
+
module MyNamespace
|
211
|
+
module MyGem
|
212
|
+
module Version
|
213
|
+
#
|
214
|
+
# Constants
|
215
|
+
#
|
216
|
+
|
217
|
+
# The major version number
|
218
|
+
MAJOR = 1
|
219
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
220
|
+
MINOR = 2
|
221
|
+
# The patch number, scoped to the {MINOR} version number
|
222
|
+
PATCH = 3
|
223
|
+
|
224
|
+
#
|
225
|
+
# Module Methods
|
226
|
+
#
|
227
|
+
|
228
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
229
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
230
|
+
#
|
231
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
232
|
+
# other than master.
|
233
|
+
def self.full
|
234
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
235
|
+
|
236
|
+
if defined? PRERELEASE
|
237
|
+
version = "#{version}-#{PRERELEASE}"
|
238
|
+
end
|
239
|
+
|
240
|
+
version
|
241
|
+
end
|
242
|
+
|
243
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
244
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
245
|
+
#
|
246
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
247
|
+
# other than master.
|
248
|
+
def self.gem
|
249
|
+
full.gsub('-', '.pre.')
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
"""
|
255
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
256
|
+
Then the output should contain:
|
257
|
+
"""
|
258
|
+
CONSTANTS
|
259
|
+
MAJOR
|
260
|
+
should be a kind of Integer
|
261
|
+
MINOR
|
262
|
+
should be a kind of Integer
|
263
|
+
PATCH
|
264
|
+
should be a kind of Integer
|
265
|
+
"""
|
266
|
+
And the output should contain:
|
267
|
+
"""
|
268
|
+
full
|
269
|
+
with PRERELEASE defined
|
270
|
+
is <MAJOR>.<MINOR>.<PATCH>-<PRERELEASE>
|
271
|
+
without PRERELEASE defined
|
272
|
+
is <MAJOR>.<MINOR>.<PATCH>
|
273
|
+
gem
|
274
|
+
replaces '-' with '.pre.' to be compatible with rubygems 1.8.6
|
275
|
+
"""
|