metasploit-version 0.1.2
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
@@ -0,0 +1,234 @@
|
|
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 unset the environment variable "TRAVIS_BRANCH"
|
8
|
+
Given I set the environment variables to:
|
9
|
+
| variable | value |
|
10
|
+
| TRAVIS_PULL_REQUEST | false |
|
11
|
+
Given a git repository
|
12
|
+
And 2 commits
|
13
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
14
|
+
"""ruby
|
15
|
+
require 'my_namespace/my_gem/version'
|
16
|
+
|
17
|
+
module MyNamespace
|
18
|
+
module MyGem
|
19
|
+
end
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
Given a file named "spec/spec_helper.rb" with:
|
23
|
+
"""ruby
|
24
|
+
require 'metasploit/version'
|
25
|
+
require 'my_namespace/my_gem'
|
26
|
+
|
27
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
28
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
29
|
+
|
30
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
31
|
+
require f
|
32
|
+
end
|
33
|
+
"""
|
34
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
35
|
+
"""ruby
|
36
|
+
require 'spec_helper'
|
37
|
+
|
38
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
39
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
40
|
+
end
|
41
|
+
"""
|
42
|
+
|
43
|
+
Scenario Outline: PRERELEASE defined as branch relative name
|
44
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
45
|
+
"""ruby
|
46
|
+
module MyNamespace
|
47
|
+
module MyGem
|
48
|
+
module Version
|
49
|
+
#
|
50
|
+
# CONSTANTS
|
51
|
+
#
|
52
|
+
|
53
|
+
# The major version number
|
54
|
+
MAJOR = 1
|
55
|
+
|
56
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
57
|
+
MINOR = 2
|
58
|
+
|
59
|
+
# The patch number, scoped to the {MINOR} version number
|
60
|
+
PATCH = 3
|
61
|
+
|
62
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
63
|
+
PRERELEASE = '<prerelease>'
|
64
|
+
|
65
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
66
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
67
|
+
#
|
68
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
69
|
+
# other than master.
|
70
|
+
def self.full
|
71
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
72
|
+
|
73
|
+
if defined? PRERELEASE
|
74
|
+
version = "#{version}-#{PRERELEASE}"
|
75
|
+
end
|
76
|
+
|
77
|
+
version
|
78
|
+
end
|
79
|
+
|
80
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
81
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
82
|
+
#
|
83
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
84
|
+
# other than master.
|
85
|
+
def self.gem
|
86
|
+
full.gsub('-', '.pre.')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
"""
|
92
|
+
And a git checkout of "-b <branch>"
|
93
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
94
|
+
Then the output should contain:
|
95
|
+
"""
|
96
|
+
PRERELEASE
|
97
|
+
matches the <type> branch's name
|
98
|
+
"""
|
99
|
+
|
100
|
+
Examples:
|
101
|
+
| type | prerelease | branch |
|
102
|
+
| bug | nasty | bug/MSP-1234/nasty |
|
103
|
+
| feature | super-cool | feature/MSP-1234/super-cool |
|
104
|
+
| staging | rocket-motor | staging/rocket-motor |
|
105
|
+
|
106
|
+
Scenario Outline: PRERELEASE not defined
|
107
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
108
|
+
"""ruby
|
109
|
+
module MyNamespace
|
110
|
+
module MyGem
|
111
|
+
module Version
|
112
|
+
#
|
113
|
+
# CONSTANTS
|
114
|
+
#
|
115
|
+
|
116
|
+
# The major version number
|
117
|
+
MAJOR = 1
|
118
|
+
|
119
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
120
|
+
MINOR = 2
|
121
|
+
|
122
|
+
# The patch number, scoped to the {MINOR} version number
|
123
|
+
PATCH = 3
|
124
|
+
|
125
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
126
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
127
|
+
#
|
128
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
129
|
+
# other than master.
|
130
|
+
def self.full
|
131
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
132
|
+
|
133
|
+
if defined? PRERELEASE
|
134
|
+
version = "#{version}-#{PRERELEASE}"
|
135
|
+
end
|
136
|
+
|
137
|
+
version
|
138
|
+
end
|
139
|
+
|
140
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
141
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
142
|
+
#
|
143
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
144
|
+
# other than master.
|
145
|
+
def self.gem
|
146
|
+
full.gsub('-', '.pre.')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
"""
|
152
|
+
And a git checkout of "-b <branch>"
|
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 <type> branch's name"
|
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
|
+
| type | prerelease | branch |
|
170
|
+
| bug | nasty | bug/MSP-1234/nasty |
|
171
|
+
| feature | super-cool | feature/MSP-1234/super-cool |
|
172
|
+
| staging | rocket-motor | staging/rocket-motor |
|
173
|
+
|
174
|
+
Scenario Outline: Story branch without a story ID
|
175
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
176
|
+
"""ruby
|
177
|
+
module MyNamespace
|
178
|
+
module MyGem
|
179
|
+
module Version
|
180
|
+
#
|
181
|
+
# CONSTANTS
|
182
|
+
#
|
183
|
+
|
184
|
+
# The major version number
|
185
|
+
MAJOR = 1
|
186
|
+
|
187
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
188
|
+
MINOR = 2
|
189
|
+
|
190
|
+
# The patch number, scoped to the {MINOR} version number.
|
191
|
+
PATCH = 3
|
192
|
+
|
193
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
194
|
+
PRERELEASE = '<prerelease>'
|
195
|
+
|
196
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
197
|
+
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
198
|
+
#
|
199
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
200
|
+
# other than master.
|
201
|
+
def self.full
|
202
|
+
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
203
|
+
|
204
|
+
if defined? PRERELEASE
|
205
|
+
version = "#{version}-#{PRERELEASE}"
|
206
|
+
end
|
207
|
+
|
208
|
+
version
|
209
|
+
end
|
210
|
+
|
211
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
212
|
+
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
213
|
+
#
|
214
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
215
|
+
# other than master.
|
216
|
+
def self.gem
|
217
|
+
full.gsub('-', '.pre.')
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
"""
|
223
|
+
And a git checkout of "-b <branch>"
|
224
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
225
|
+
Then the output should contain:
|
226
|
+
"""
|
227
|
+
Do not know how to parse "<branch>" for PRERELEASE
|
228
|
+
"""
|
229
|
+
|
230
|
+
Examples:
|
231
|
+
| prerelease | branch |
|
232
|
+
| nasty | bug/nasty |
|
233
|
+
| recurring | chore/recurring |
|
234
|
+
| super-cool | feature/super-cool |
|
data/features/shared/examples/metasploit/version/version_module/prerelease/git/detached_head.feature
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in detached head build locally
|
2
|
+
|
3
|
+
The 'Metasploit::Version Version Module' shared example will not check that the described_class for an RSpec *_spec.rb
|
4
|
+
file defines PRERELEASE when the git repository is in a detached head state, such as when checking out a SHA and it
|
5
|
+
does not correspond to a pre-existing branch or tag.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I unset the environment variable "TRAVIS_BRANCH"
|
9
|
+
Given a git repository
|
10
|
+
And 2 commits
|
11
|
+
And a git checkout of "HEAD^"
|
12
|
+
And a file named "lib/my_namespace/my_gem.rb" with:
|
13
|
+
"""ruby
|
14
|
+
require 'my_namespace/my_gem/version'
|
15
|
+
|
16
|
+
module MyNamespace
|
17
|
+
module MyGem
|
18
|
+
end
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
And a file named "spec/spec_helper.rb" with:
|
22
|
+
"""ruby
|
23
|
+
require 'metasploit/version'
|
24
|
+
require 'my_namespace/my_gem'
|
25
|
+
|
26
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
27
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
28
|
+
|
29
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
30
|
+
require f
|
31
|
+
end
|
32
|
+
"""
|
33
|
+
And a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
34
|
+
"""ruby
|
35
|
+
require 'spec_helper'
|
36
|
+
|
37
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
38
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
|
42
|
+
Scenario: PRERELEASE defined
|
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
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
92
|
+
Then the output should contain:
|
93
|
+
"""
|
94
|
+
Pending:
|
95
|
+
MyNamespace::MyGem::Version it should behave like Metasploit::Version Version Module CONSTANTS PRERELEASE has an abbreviated reference that can be parsed for prerelease
|
96
|
+
# Cannot determine branch name in detached HEAD state. Set TRAVIS_BRANCH to supply branch name
|
97
|
+
"""
|
@@ -0,0 +1,94 @@
|
|
1
|
+
Feature: 'Metasploit::Version Version Module' shared example in master build locally
|
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 I unset the environment variable "TRAVIS_BRANCH"
|
8
|
+
Given I set the environment variables to:
|
9
|
+
| variable | value |
|
10
|
+
| TRAVIS_PULL_REQUEST | false |
|
11
|
+
Given a git repository
|
12
|
+
Given a git checkout of "master"
|
13
|
+
Given a file named "lib/my_namespace/my_gem.rb" with:
|
14
|
+
"""ruby
|
15
|
+
require 'my_namespace/my_gem/version'
|
16
|
+
|
17
|
+
module MyNamespace
|
18
|
+
module MyGem
|
19
|
+
end
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
Given a file named "spec/spec_helper.rb" with:
|
23
|
+
"""ruby
|
24
|
+
require 'metasploit/version'
|
25
|
+
require 'my_namespace/my_gem'
|
26
|
+
|
27
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
28
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
|
29
|
+
|
30
|
+
Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
|
31
|
+
require f
|
32
|
+
end
|
33
|
+
"""
|
34
|
+
Given a file named "spec/lib/my_namespace/my_gem/version_spec.rb" with:
|
35
|
+
"""ruby
|
36
|
+
require 'spec_helper'
|
37
|
+
|
38
|
+
RSpec.describe MyNamespace::MyGem::Version do
|
39
|
+
it_should_behave_like 'Metasploit::Version Version Module'
|
40
|
+
end
|
41
|
+
"""
|
42
|
+
|
43
|
+
Scenario: PRERELEASE defined
|
44
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
45
|
+
"""ruby
|
46
|
+
module MyNamespace
|
47
|
+
module MyGem
|
48
|
+
module Version
|
49
|
+
#
|
50
|
+
# CONSTANTS
|
51
|
+
#
|
52
|
+
|
53
|
+
# The major version number
|
54
|
+
MAJOR = 1
|
55
|
+
|
56
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
57
|
+
MINOR = 2
|
58
|
+
|
59
|
+
# The patch number, scoped to the {MINOR} version number
|
60
|
+
PATCH = 3
|
61
|
+
|
62
|
+
# The prerelease name of the given {MAJOR}.{MINOR}.{PATCH} version number. Will not be defined on master.
|
63
|
+
PRERELEASE = 'source-branch-relative-name'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
"""
|
68
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
69
|
+
Then the output should contain "expected MyNamespace::MyGem::Version::PRERELEASE not to be defined on master"
|
70
|
+
|
71
|
+
Scenario: PRERELEASE undefined
|
72
|
+
Given a file named "lib/my_namespace/my_gem/version.rb" with:
|
73
|
+
"""ruby
|
74
|
+
module MyNamespace
|
75
|
+
module MyGem
|
76
|
+
module Version
|
77
|
+
#
|
78
|
+
# CONSTANTS
|
79
|
+
#
|
80
|
+
|
81
|
+
# The major version number
|
82
|
+
MAJOR = 1
|
83
|
+
|
84
|
+
# The minor version number, scoped to the {MAJOR} version number.
|
85
|
+
MINOR = 2
|
86
|
+
|
87
|
+
# The patch number, scoped to the {MINOR} version number
|
88
|
+
PATCH = 3
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
"""
|
93
|
+
When I run `rspec spec/lib/my_namespace/my_gem/version_spec.rb --format documentation`
|
94
|
+
Then the output should not contain "expected MyNamespace::MyGem::Version::PRERELEASE not to be defined on master"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Given(/^I unset the environment variable "(.*?)"$/) do |variable|
|
2
|
+
# @note This will only work if the consumer of the environment variable treats a blank value for the environment
|
3
|
+
# variable as the same as the environment variable not being set
|
4
|
+
#
|
5
|
+
# ENV[variable] = nil and ENV.delete(variable) will not stop the parent process's environment variable from
|
6
|
+
# propagating to processes called by run_simple, so have to fake unsetting with blank values.
|
7
|
+
if RUBY_PLATFORM == 'java'
|
8
|
+
warn "Faking unsetting environment variable for JRuby by setting to blank string"
|
9
|
+
set_env(variable, '')
|
10
|
+
else
|
11
|
+
set_env(variable, nil)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
fail_on_error = true
|
2
|
+
|
3
|
+
Given /^a git repository$/ do
|
4
|
+
# git init will fail if account ident it not setup
|
5
|
+
if ENV['TRAVIS'] == 'true'
|
6
|
+
run_simple('git config --global user.email "cucumber@example.com"')
|
7
|
+
run_simple('git config --global user.name "Cucumber"')
|
8
|
+
end
|
9
|
+
|
10
|
+
run_simple('git init', fail_on_error)
|
11
|
+
path = '.gitignore'
|
12
|
+
write_file(path, '')
|
13
|
+
run_simple("git add #{path}", fail_on_error)
|
14
|
+
run_simple('git commit --message "Initial commit"', fail_on_error)
|
15
|
+
end
|
16
|
+
|
17
|
+
Given /^(\d+) commits$/ do |commits|
|
18
|
+
commits = commits.to_i
|
19
|
+
|
20
|
+
commits.times do |commit|
|
21
|
+
path = "file#{commit}"
|
22
|
+
write_file(path, '')
|
23
|
+
run_simple("git add #{path}", fail_on_error)
|
24
|
+
run_simple("git commit --message \"Commit #{commit} of #{commits}\"", fail_on_error)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Given /^a git checkout of "(.*?)"$/ do |treeish|
|
29
|
+
run_simple("git checkout #{treeish}", fail_on_error)
|
30
|
+
end
|