Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epistrephein committed Dec 5, 2023
1 parent 131f2bc commit 04a72a9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
26 changes: 13 additions & 13 deletions spec/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,43 +63,43 @@

expect(json).to eq({
'status' => 'normal',
'branches' => ['2.7', '2.6'],
'latest' => ['2.7.2', '2.6.6']
'branches' => ['3.2', '3.1'],
'latest' => ['3.2.2', '3.1.4']
})
end
end

describe 'branch endpoint' do
let(:endpoint) { '/api/2.7' }
let(:endpoint) { '/api/3.2' }

it 'returns the branch info' do
get endpoint

expect(json).to eq({
'branch' => '2.7',
'branch' => '3.2',
'status' => 'normal',
'release_date' => '2019-12-25',
'release_date' => '2022-12-25',
'eol_date' => nil,
'latest' => '2.7.2',
'latest' => '3.2.2',
'releases' => [
'2.7.2', '2.7.1', '2.7.0', '2.7.0-rc2', '2.7.0-rc1',
'2.7.0-preview3', '2.7.0-preview2', '2.7.0-preview1'
'3.2.2', '3.2.1', '3.2.0', '3.2.0-rc1',
'3.2.0-preview3', '3.2.0-preview2', '3.2.0-preview1'
]
})
end
end

describe 'release endpoint' do
let(:endpoint) { '/api/2.7.0' }
let(:endpoint) { '/api/3.2.0' }

it 'returns the release info' do
get endpoint

expect(json).to eq({
'release' => '2.7.0',
'branch' => '2.7',
'release' => '3.2.0',
'branch' => '3.2',
'status' => 'normal',
'release_date' => '2019-12-25',
'release_date' => '2022-12-25',
'latest' => false,
'prerelease' => false
})
Expand All @@ -113,7 +113,7 @@
get endpoint

expect(json).to eq({
'last_update' => '2020-10-24 07:30:00 +0000'
'last_update' => '2023-12-03 11:23:35 +0000'
})
end
end
Expand Down
38 changes: 19 additions & 19 deletions spec/branch_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Branch, :github do
subject(:branch) { described_class['2.5'] }
subject(:branch) { described_class['3.0'] }

before(:each) do
Branch.build!
Expand All @@ -11,7 +11,7 @@
describe '#latest' do
it 'returns the latest version of the branch' do
expect(branch.latest).to be_a(Release)
expect(branch.latest.to_s).to eq('2.5.8')
expect(branch.latest.to_s).to eq('3.0.6')
end
end

Expand All @@ -23,47 +23,47 @@

describe '#to_s' do
it 'returns the branch name as string' do
expect(branch.to_s).to eq('2.5')
expect(branch.to_s).to eq('3.0')
end
end

describe '#to_json' do
it 'returns the branch attributes as JSON' do
expect(branch.to_json).to eq(
'{"branch":"2.5","status":"security","release_date":"2017-12-25",' \
'"eol_date":"2021-03-31","latest":"2.5.8","releases":["2.5.8","2.5.7",' \
'"2.5.6","2.5.5","2.5.4","2.5.3","2.5.2","2.5.1","2.5.0","2.5.0-rc1","2.5.0-preview1"]}'
'{"branch":"3.0","status":"security","release_date":"2020-12-25",' \
'"eol_date":null,"latest":"3.0.6","releases":["3.0.6","3.0.5",' \
'"3.0.4","3.0.3","3.0.2","3.0.1","3.0.0","3.0.0-rc1","3.0.0-preview2","3.0.0-preview1"]}'
)
end
end

describe '#attributes' do
it 'returns the branch attributes as hash' do
expect(branch.attributes).to eq({
branch: '2.5',
branch: '3.0',
status: 'security',
release_date: Date.new(2017, 12, 25),
eol_date: Date.new(2021, 3, 31),
latest: '2.5.8',
release_date: Date.new(2020, 12, 25),
eol_date: nil,
latest: '3.0.6',
releases: [
'2.5.8', '2.5.7', '2.5.6', '2.5.5', '2.5.4', '2.5.3',
'2.5.2', '2.5.1', '2.5.0', '2.5.0-rc1', '2.5.0-preview1'
'3.0.6', '3.0.5', '3.0.4', '3.0.3', '3.0.2', '3.0.1',
'3.0.0', '3.0.0-rc1', '3.0.0-preview2', '3.0.0-preview1'
]
})
end
end

describe '.[]' do
it 'returns the branch with the matching name' do
expect(described_class['2.5']).to be_a(described_class)
expect(described_class['2.5'].to_s).to eq('2.5')
expect(described_class['3.0']).to be_a(described_class)
expect(described_class['3.0'].to_s).to eq('3.0')
end
end

describe '.status' do
it 'returns the branches with the matching status' do
expect(described_class.status('security')).to all(be_a(described_class))
expect(described_class.status('security').first.to_s).to eq('2.5')
expect(described_class.status('security').first.to_s).to eq('3.0')
end
end

Expand All @@ -85,7 +85,7 @@
it 'returns the latest 4 branches as string' do
expect(described_class.examples_branches).to all(be_a String)
expect(described_class.examples_branches).to eq([
'3.0', '2.7', '2.6', '2.5'
'3.3', '3.2', '3.1', '3.0'
])
end
end
Expand All @@ -103,21 +103,21 @@
it 'returns 6 releases of the 4 most recent branches as string' do
expect(described_class.examples_releases).to all(be_a String)
expect(described_class.examples_releases).to eq([
'3.0.0-preview1', '2.7.2', '2.7.1', '2.6.6', '2.5.8', '2.4.10'
'3.3.0-preview3', '3.3.0-preview2', '3.2.2', '3.2.1', '3.1.4', '3.0.6'
])
end
end

describe '.sha' do
it 'returns the commit sha of the data' do
expect(described_class.sha).to eq('8c7d486e4ac97fc2aa31db3f16881e438b4cd863')
expect(described_class.sha).to eq('54cfc1f1332e0e7888c9266fcb0c351b3534a661')
end
end

describe '.all' do
it 'returns all branches' do
expect(described_class.all).to all(be_a(described_class))
expect(described_class.all.first.to_s).to eq('3.0')
expect(described_class.all.first.to_s).to eq('3.3')
expect(described_class.all.last.to_s).to eq('1.9')
end

Expand Down
28 changes: 14 additions & 14 deletions spec/release_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Release, :github do
subject(:release) { described_class['2.6.4'] }
subject(:release) { described_class['3.1.2'] }

before(:each) do
Branch.build!
Expand All @@ -23,7 +23,7 @@
describe '#branch' do
it 'returns the branch of the release' do
expect(release.branch).to be_a(Branch)
expect(release.branch.to_s).to eq('2.6')
expect(release.branch.to_s).to eq('3.1')
end
end

Expand All @@ -35,26 +35,26 @@

describe '#to_s' do
it 'returns the release version as string' do
expect(release.to_s).to eq('2.6.4')
expect(release.to_s).to eq('3.1.2')
end
end

describe '#to_json' do
it 'returns the release attributes as JSON' do
expect(release.to_json).to eq(
'{"release":"2.6.4","branch":"2.6","status":"normal","release_date":' \
'"2019-08-28","latest":false,"prerelease":false}'
'{"release":"3.1.2","branch":"3.1","status":"normal","release_date":' \
'"2022-04-12","latest":false,"prerelease":false}'
)
end
end

describe '#attributes' do
it 'returns the release attributes as hash' do
expect(release.attributes).to eq({
release: '2.6.4',
branch: '2.6',
release: '3.1.2',
branch: '3.1',
status: 'normal',
release_date: Date.new(2019, 8, 28),
release_date: '2022-04-12',
latest: false,
prerelease: false
})
Expand All @@ -63,17 +63,17 @@

describe '.[]' do
it 'returns the release with the matching version' do
expect(described_class['2.6.4']).to be_a(described_class)
expect(described_class['2.6.4'].to_s).to eq('2.6.4')
expect(described_class['3.1.2']).to be_a(described_class)
expect(described_class['3.1.2'].to_s).to eq('3.1.2')
end
end

describe '.branch' do
it 'returns the releases of a branch' do
branch = Branch['2.6']
branch = Branch['3.1']

expect(described_class.branch(branch)).to all(be_a(described_class))
expect(described_class.branch(branch).first.to_s).to eq('2.6.6')
expect(described_class.branch(branch).first.to_s).to eq('3.1.4')
end
end

Expand All @@ -86,14 +86,14 @@

describe '.sha' do
it 'returns the commit sha of the data' do
expect(described_class.sha).to eq('39f327ba6d87a745e9a695c80a1c443e328fcb99')
expect(described_class.sha).to eq('7333cd8e25691bbb2325f6d5d4e1a07b0805cd2b')
end
end

describe '.all' do
it 'returns all releases' do
expect(described_class.all).to all(be_a(described_class))
expect(described_class.all.first.to_s).to eq('3.0.0-preview1')
expect(described_class.all.first.to_s).to eq('3.3.0-preview3')
expect(described_class.all.last.to_s).to eq('1.9.0')
end

Expand Down

0 comments on commit 04a72a9

Please sign in to comment.