Skip to content

Commit

Permalink
add SB version.rb style mock and test
Browse files Browse the repository at this point in the history
  • Loading branch information
peaky76 committed Jan 15, 2024
1 parent e54e1c5 commit d9bfecc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@
expect(action.fetch_version(ref: ref)).to eq("1.2.3")
end

it 'returns the correct version for a sb algo-generated version.rb file' do
mock_response('my_branch', mock_sb_algo_version_content('1.2.3'))

expect(action.fetch_version(ref: ref)).to eq("1.2.3")
end

it 'returns the correct version for a gemspec file' do
mock_response('my_branch', mock_gemspec_content('1.2.3'))

Expand Down Expand Up @@ -248,6 +254,17 @@ module TestRepo
)
end

def mock_sb_algo_version_content(version)
%(
module TestRepo
base = '#{version}'
# SB-specific versioning "algorithm" to accommodate BNW/Jenkins/gemstash
VERSION = (pre = ENV.fetch('GEM_PRE_RELEASE', '')).empty? ? base : "\#{base}.\#{pre}"
end
)
end

def mock_gemspec_content(version)
%(
Gem::Specification.new do |s|
Expand Down

0 comments on commit d9bfecc

Please sign in to comment.