Commit 9ae8b574 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg
parent 0f18d489
......@@ -1688,41 +1688,33 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
describe '#languages' do
shared_examples 'languages' do
it 'returns exactly the expected results' do
languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6')
expected_languages = [
{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
{ value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
{ value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26" },
{ value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" }
]
it 'returns exactly the expected results' do
languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6')
expected_languages = [
{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
{ value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
{ value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26" },
{ value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" }
]
expect(languages.size).to eq(expected_languages.size)
expect(languages.size).to eq(expected_languages.size)
expected_languages.size.times do |i|
a = expected_languages[i]
b = languages[i]
expected_languages.size.times do |i|
a = expected_languages[i]
b = languages[i]
expect(a.keys.sort).to eq(b.keys.sort)
expect(a[:value]).to be_within(0.1).of(b[:value])
expect(a.keys.sort).to eq(b.keys.sort)
expect(a[:value]).to be_within(0.1).of(b[:value])
non_float_keys = a.keys - [:value]
expect(a.values_at(*non_float_keys)).to eq(b.values_at(*non_float_keys))
end
end
it "uses the repository's HEAD when no ref is passed" do
lang = repository.languages.first
expect(lang[:label]).to eq('Ruby')
non_float_keys = a.keys - [:value]
expect(a.values_at(*non_float_keys)).to eq(b.values_at(*non_float_keys))
end
end
it_behaves_like 'languages'
it "uses the repository's HEAD when no ref is passed" do
lang = repository.languages.first
context 'with rugged', :skip_gitaly_mock do
it_behaves_like 'languages'
expect(lang[:label]).to eq('Ruby')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment