Решение на Четвърта задача - Unit тестване от Теодора Петкова

Обратно към всички решения

Към профила на Теодора Петкова

Резултати

  • 5 точки от тестове
  • 0 бонус точки
  • 5 точки общо
  • 17 успешни тест(а)
  • 2 неуспешни тест(а)

Код

describe Version do
describe '#initialize' do
def get_message(invalid_version)
'Invalid version string \'%s\'' % invalid_version
end
it 'initializes with a string' do
expect(Version.new('1.1.5')).to eq('1.1.5')
end
it 'initializes with an empty string as 0' do
expect(Version.new('')).to eq('0')
end
it 'initializes with white spaces \' \'' do
expect { Version.new(' ') }
.to raise_error(ArgumentError, get_message(' '))
end
it 'initializes with no parameter as 0' do
expect(Version.new).to eq('0')
end
it 'raises an error with an incorrect string \'a.b.c\'' do
expect { Version.new('a.b.c') }
.to raise_error(ArgumentError, get_message('a.b.c'))
end
it 'raises an error with an incorrect string \'.6\'' do
expect { Version.new('.6') }
.to raise_error(ArgumentError, get_message('.6'))
end
it 'raises an error with an incorrect string \'0..6\'' do
expect { Version.new('0..6') }
.to raise_error(ArgumentError, get_message('0..6'))
end
end
let(:versions_first_bigger_than_second) do
[
[Version.new('1.3.1'), Version.new('1.2.3')],
[Version.new('1.0.2'), Version.new('1.0.1')],
[Version.new('1.3'), Version.new('1.2.3')],
[Version.new('1'), Version.new('0.1')]
]
end
let(:equal_versions) do
[
[Version.new('1.1.1'), Version.new('1.1.1')],
[Version.new('1.1.0'), Version.new('1.1')],
[Version.new('0.1'), Version.new('0.1.0')],
]
end
describe '#>' do
it 'a > b -> true' do
are_all_bigger = versions_first_bigger_than_second
.map { |v| v[0] > v[1] }.all?
expect(are_all_bigger).to eq(true)
end
it 'a > b -> false' do
are_all_not_bigger = versions_first_bigger_than_second
.map { |v| v[1] > v[0] }.all?
expect(are_all_not_bigger).to eq(false)
end
end
describe '#<' do
it 'a < b -> true' do
are_all_smaller = versions_first_bigger_than_second
.map { |v| v[1] < v[0] }.all?
expect(are_all_smaller).to eq(true)
end
it 'a < b -> false' do
are_all_not_smaller = versions_first_bigger_than_second
.map { |v| v[0] < v[1] }.all?
expect(are_all_not_smaller).to eq(false)
end
end
describe '#==' do
it 'a == b -> true' do
are_all_equal = equal_versions.map { |v| v[0] == v[1] }.all?
expect(are_all_equal).to eq(true)
end
it 'a == b -> false' do
are_all_not_equal = versions_first_bigger_than_second
.map { |v| v[0] == v[1] }.all?
expect(are_all_not_equal).to eq(false)
end
end
describe '#>=' do
it 'a >= b -> true' do
are_all_bigger_or_equal = versions_first_bigger_than_second
.concat(equal_versions).map { |v| v[0] >= v[1] }.all?
expect(are_all_bigger_or_equal).to eq(true)
end
it 'a >= b -> false' do
are_all_not_bigger_or_equal = versions_first_bigger_than_second
.map { |v| v[1] >= v[0] }.all?
expect(are_all_not_bigger_or_equal).to eq(false)
end
end
describe '#<=' do
it 'a <= b -> true' do
are_all_smaller_or_equal = versions_first_bigger_than_second
.concat(equal_versions).map { |v| v[1] <= v[0] }.all?
expect(are_all_smaller_or_equal).to eq(true)
end
it 'a <= b -> false' do
are_all_not_smaller_or_equal = versions_first_bigger_than_second
.map { |v| v[0] <= v[1] }.all?
expect(are_all_not_smaller_or_equal).to eq(false)
end
end
describe '#<=>' do
it 'a <=> b -> 0' do
are_all_equal = equal_versions
.map { |v| v[1] <=> v[0] }.all? { |r| r == 0 }
expect(are_all_equal).to eq(true)
end
it 'a <=> b -> 1' do
are_all_greater = versions_first_bigger_than_second
.map { |v| v[0] <=> v[1] }.all? { |r| r == 1 }
expect(are_all_greater).to eq(true)
end
it 'a <=> b -> -1' do
are_all_smaller = versions_first_bigger_than_second
.map { |v| v[1] <=> v[0] }.all? { |r| r == -1 }
expect(are_all_smaller).to eq(true)
end
end
describe '#to_s' do
it 'returns \'\' for new version' do
expect(Version.new.to_s).to eq('')
end
it 'returns \'\' for empty version' do
expect(Version.new('').to_s).to eq('')
end
it 'returns the version as a string' do
expect(Version.new('1.1.1.2.3.4').to_s).to eq('1.1.1.2.3.4')
end
it 'returns the version as a string without trailing zeros' do
expect(Version.new('1.1.0.0.0').to_s).to eq('1.1')
end
it 'returns the version as a string with inner zeros' do
expect(Version.new('0.0.1.0.0').to_s).to eq('0.0.1')
end
end
describe '#components' do
it 'returns all the components of the version' do
expect(Version.new('1.3.5').components).to eq([1, 3, 5])
end
it 'returns the components without trailing zeros' do
expect(Version.new('1.3.5.0').components).to eq([1, 3, 5])
end
it 'returns the components with inner zeros' do
expect(Version.new('0.3.0.5').components).to eq([0, 3, 0, 5])
end
# undefined behaviour
# it 'returns the components with a given number 0' do
# expect(Version.new('1.3.0.5').components(0)).to eq([1, 3, 0, 5])
# end
it 'returns all components equal to a given number' do
expect(Version.new('1.3.0.5').components(4)).to eq([1, 3, 0, 5])
end
it 'returns only components less than a given number' do
expect(Version.new('1.3.0.5').components(3)).to eq([1, 3, 0])
end
it 'returns the components with trailing zeros for a bigger number' do
expect(Version.new('1.0.5').components(6)).to eq([1, 0, 5, 0, 0, 0])
end
it 'does not mutate the version' do
version = Version.new('1.3.5')
expect(version.components).to eq([1, 3, 5])
expect(version.components.reverse!).to eq([5, 3, 1])
expect(version.components).to eq([1, 3, 5])
end
end
describe Range do
describe '#include?' do
context 'versions as objects' do
it 'a version is inside a given range' do
version1 = Version.new('1.1.1')
version2 = Version.new('2.2.1')
version3 = Version.new('1.5.1')
range = Version::Range.new(version1, version2)
expect(range.include?(version3)).to eq(true)
end
it 'a version equal to start is inside a given range' do
version1 = Version.new('1.1.1')
version2 = Version.new('2.2.1')
range = Version::Range.new(version1, version2)
expect(range.include?(version1)).to eq(true)
end
it 'a version is not inside a given range' do
version1 = Version.new('1.1.1')
version2 = Version.new('2.2.1')
version3 = Version.new('2.2.2')
range = Version::Range.new(version1, version2)
expect(range.include?(version3)).to eq(false)
end
it 'a version equal to end is not inside a given range' do
version1 = Version.new('1.1.1')
version2 = Version.new('2.2.1')
range = Version::Range.new(version1, version2)
expect(range.include?(version2)).to eq(false)
end
end
context 'versions as strings' do
it 'a version is inside a given range' do
range = Version::Range.new('1.1.1', '2.2.2')
expect(range.include?('1.5.1')).to eq(true)
end
it 'a version equal to start is inside a given range' do
range = Version::Range.new('1.1.1', '2.2.2')
expect(range.include?('1.1.1')).to eq(true)
end
it 'a version is not inside a given range' do
range = Version::Range.new('1.1.1', '2.2.2')
expect(range.include?('3.5.1')).to eq(false)
end
it 'a version equal to end is not inside a given range' do
range = Version::Range.new('1.1.1', '2.2.2')
expect(range.include?('2.2.2')).to eq(false)
end
end
end
describe '#to_a' do
it 'the array has the start version from the range' do
version1 = Version.new('1.1')
version2 = Version.new('1.2')
range = Version::Range.new(version1, version2)
expect(range.to_a.first).to eq(version1)
end
it 'the array does not have the end version from the range' do
version1 = Version.new('1.1')
version2 = Version.new('1.2')
range = Version::Range.new(version1, version2)
expect(range.to_a.last).not_to eq(version2)
end
it 'there is a difference of 1 between the versions in the range' do
version1 = Version.new('1.1.0')
version2 = Version.new('1.2.0')
range = Version::Range.new(version1, version2)
expected_range =
[
'1.1', '1.1.1', '1.1.2', '1.1.3', '1.1.4',
'1.1.5', '1.1.6', '1.1.7', '1.1.8', '1.1.9'
]
# result = range.to_a.each_cons(2).all? do |first, second|
# first.components(3).last + 1 == second.components.last
# end
# expect(result).to eq(true)
expect(range.to_a).to eq(expected_range)
end
it 'the next final number turns to 0 when the previous one is 9' do
version1 = Version.new('1.1.9')
version2 = Version.new('1.2.1')
range = Version::Range.new(version1, version2)
# expect(range.to_a.last.components(3).last).to eq(0)
expect(range.to_a.last).to eq('1.2.0')
end
it 'the first version after the start is with 3 components' do
version1 = Version.new('0')
version2 = Version.new('1')
range = Version::Range.new(version1, version2)
# expect(range.to_a[1].components.size).to eq(3)
expect(range.to_a[1]).to eq('0.0.1')
end
it 'returns an empty array in a range with the same start and end' do
version1 = Version.new('1.1')
version2 = Version.new('1.1')
range = Version::Range.new(version1, version2)
expected_range = []
expect(range.to_a).to eq(expected_range)
end
end
end
end

Лог от изпълнението

............F...F..

Failures:

  1) spec Version::Range tests constructing ranges with strings
     Failure/Error: expect(@solution).to_not pass_tests
       expected this solution to not pass the tests:
       
         class Version
           VALID_VERSION_REGEXP = /\A\z|\A[0-9]+(\.[0-9]+)*\z/
         
           include Comparable
         
           def initialize(version = '')
             unless VALID_VERSION_REGEXP.match(version.to_s)
               raise ArgumentError, "Invalid version string '#{version}'"
             end
         
             @components = version.to_s
               .split('.')
               .map(&:to_i)
               .reverse
               .drop_while(&:zero?)
               .reverse
           end
         
           def <=>(other)
             @components <=> Version.new(other).internal_components
           end
         
           def internal_components(positions = 0)
             padding_size = positions - @components.size
         
             if padding_size > 0
               @components + [0] * padding_size
             elsif positions != 0
               @components.take(positions)
             else
               @components.dup
             end
           end
         
           def components(positions = 0)
             padding_size = positions - @components.size
         
             if padding_size > 0
               @components + [0] * padding_size
             elsif positions != 0
               @components.take(positions)
             else
               @components.dup
             end
           end
         
           def to_s
             @components.join('.')
           end
         
           class Range
             include Enumerable
         
             def initialize(start_version, end_version)
               @start_version = start_version
               @end_version   = end_version
             end
         
             def include?(version)
               (@start_version <=> version) < 1 && (@end_version <=> version) == 1
             end
         
             def each
               current_version = @start_version
         
               while (current_version <=> @end_version) == -1
                 yield current_version
         
                 current_version = increment_version(current_version)
               end
             end
         
             private
         
             def increment_version(version)
               components = version.internal_components(3)
         
               components[2] += 1
         
               components.to_enum.with_index.reverse_each do |_, index|
                 component = components[index]
         
                 if component >= 10 && components[index - 1]
                   components[index]      = 0
                   components[index - 1] += 1
                 end
               end
         
               Version.new(components.join('.'))
             end
           end
         end
     # /tmp/d20161119-19072-nqdc8e/spec.rb:479:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

  2) spec Version::Range tests include? with versions lower than the start one
     Failure/Error: expect(@solution).to_not pass_tests
       expected this solution to not pass the tests:
       
         class Version
           VALID_VERSION_REGEXP = /\A\z|\A[0-9]+(\.[0-9]+)*\z/
         
           include Comparable
         
           def initialize(version = '')
             unless VALID_VERSION_REGEXP.match(version.to_s)
               raise ArgumentError, "Invalid version string '#{version}'"
             end
         
             @components = version.to_s
               .split('.')
               .map(&:to_i)
               .reverse
               .drop_while(&:zero?)
               .reverse
           end
         
           def <=>(other)
             @components <=> Version.new(other).internal_components
           end
         
           def internal_components(positions = 0)
             padding_size = positions - @components.size
         
             if padding_size > 0
               @components + [0] * padding_size
             elsif positions != 0
               @components.take(positions)
             else
               @components.dup
             end
           end
         
           def components(positions = 0)
             padding_size = positions - @components.size
         
             if padding_size > 0
               @components + [0] * padding_size
             elsif positions != 0
               @components.take(positions)
             else
               @components.dup
             end
           end
         
           def to_s
             @components.join('.')
           end
         
           class Range
             include Enumerable
         
             def initialize(start_version, end_version)
               @start_version = Version.new(start_version)
               @end_version   = Version.new(end_version)
             end
         
             def include?(version)
               @end_version > version
             end
         
             def each
               current_version = @start_version
         
               while (current_version <=> @end_version) == -1
                 yield current_version
         
                 current_version = increment_version(current_version)
               end
             end
         
             private
         
             def increment_version(version)
               components = version.internal_components(3)
         
               components[2] += 1
         
               components.to_enum.with_index.reverse_each do |_, index|
                 component = components[index]
         
                 if component >= 10 && components[index - 1]
                   components[index]      = 0
                   components[index - 1] += 1
                 end
               end
         
               Version.new(components.join('.'))
             end
           end
         end
     # /tmp/d20161119-19072-nqdc8e/spec.rb:522:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:7:in `block (2 levels) in <top (required)>'

Finished in 20.45 seconds
19 examples, 2 failures

Failed examples:

rspec /tmp/d20161119-19072-nqdc8e/spec.rb:471 # spec Version::Range tests constructing ranges with strings
rspec /tmp/d20161119-19072-nqdc8e/spec.rb:515 # spec Version::Range tests include? with versions lower than the start one

История (1 версия и 0 коментара)

Теодора обнови решението на 18.11.2016 23:20 (преди над 7 години)

+describe Version do
+ describe '#initialize' do
+ def get_message(invalid_version)
+ 'Invalid version string \'%s\'' % invalid_version
+ end
+
+ it 'initializes with a string' do
+ expect(Version.new('1.1.5')).to eq('1.1.5')
+ end
+
+ it 'initializes with an empty string as 0' do
+ expect(Version.new('')).to eq('0')
+ end
+
+ it 'initializes with white spaces \' \'' do
+ expect { Version.new(' ') }
+ .to raise_error(ArgumentError, get_message(' '))
+ end
+
+ it 'initializes with no parameter as 0' do
+ expect(Version.new).to eq('0')
+ end
+
+ it 'raises an error with an incorrect string \'a.b.c\'' do
+ expect { Version.new('a.b.c') }
+ .to raise_error(ArgumentError, get_message('a.b.c'))
+ end
+
+ it 'raises an error with an incorrect string \'.6\'' do
+ expect { Version.new('.6') }
+ .to raise_error(ArgumentError, get_message('.6'))
+ end
+
+ it 'raises an error with an incorrect string \'0..6\'' do
+ expect { Version.new('0..6') }
+ .to raise_error(ArgumentError, get_message('0..6'))
+ end
+ end
+
+ let(:versions_first_bigger_than_second) do
+ [
+ [Version.new('1.3.1'), Version.new('1.2.3')],
+ [Version.new('1.0.2'), Version.new('1.0.1')],
+ [Version.new('1.3'), Version.new('1.2.3')],
+ [Version.new('1'), Version.new('0.1')]
+ ]
+ end
+
+ let(:equal_versions) do
+ [
+ [Version.new('1.1.1'), Version.new('1.1.1')],
+ [Version.new('1.1.0'), Version.new('1.1')],
+ [Version.new('0.1'), Version.new('0.1.0')],
+ ]
+ end
+
+ describe '#>' do
+ it 'a > b -> true' do
+ are_all_bigger = versions_first_bigger_than_second
+ .map { |v| v[0] > v[1] }.all?
+ expect(are_all_bigger).to eq(true)
+ end
+ it 'a > b -> false' do
+ are_all_not_bigger = versions_first_bigger_than_second
+ .map { |v| v[1] > v[0] }.all?
+ expect(are_all_not_bigger).to eq(false)
+ end
+ end
+
+ describe '#<' do
+ it 'a < b -> true' do
+ are_all_smaller = versions_first_bigger_than_second
+ .map { |v| v[1] < v[0] }.all?
+ expect(are_all_smaller).to eq(true)
+ end
+ it 'a < b -> false' do
+ are_all_not_smaller = versions_first_bigger_than_second
+ .map { |v| v[0] < v[1] }.all?
+ expect(are_all_not_smaller).to eq(false)
+ end
+ end
+
+ describe '#==' do
+ it 'a == b -> true' do
+ are_all_equal = equal_versions.map { |v| v[0] == v[1] }.all?
+ expect(are_all_equal).to eq(true)
+ end
+ it 'a == b -> false' do
+ are_all_not_equal = versions_first_bigger_than_second
+ .map { |v| v[0] == v[1] }.all?
+ expect(are_all_not_equal).to eq(false)
+ end
+ end
+
+ describe '#>=' do
+ it 'a >= b -> true' do
+ are_all_bigger_or_equal = versions_first_bigger_than_second
+ .concat(equal_versions).map { |v| v[0] >= v[1] }.all?
+ expect(are_all_bigger_or_equal).to eq(true)
+ end
+ it 'a >= b -> false' do
+ are_all_not_bigger_or_equal = versions_first_bigger_than_second
+ .map { |v| v[1] >= v[0] }.all?
+ expect(are_all_not_bigger_or_equal).to eq(false)
+ end
+ end
+
+ describe '#<=' do
+ it 'a <= b -> true' do
+ are_all_smaller_or_equal = versions_first_bigger_than_second
+ .concat(equal_versions).map { |v| v[1] <= v[0] }.all?
+ expect(are_all_smaller_or_equal).to eq(true)
+ end
+ it 'a <= b -> false' do
+ are_all_not_smaller_or_equal = versions_first_bigger_than_second
+ .map { |v| v[0] <= v[1] }.all?
+ expect(are_all_not_smaller_or_equal).to eq(false)
+ end
+ end
+
+ describe '#<=>' do
+ it 'a <=> b -> 0' do
+ are_all_equal = equal_versions
+ .map { |v| v[1] <=> v[0] }.all? { |r| r == 0 }
+ expect(are_all_equal).to eq(true)
+ end
+ it 'a <=> b -> 1' do
+ are_all_greater = versions_first_bigger_than_second
+ .map { |v| v[0] <=> v[1] }.all? { |r| r == 1 }
+ expect(are_all_greater).to eq(true)
+ end
+ it 'a <=> b -> -1' do
+ are_all_smaller = versions_first_bigger_than_second
+ .map { |v| v[1] <=> v[0] }.all? { |r| r == -1 }
+ expect(are_all_smaller).to eq(true)
+ end
+ end
+
+ describe '#to_s' do
+ it 'returns \'\' for new version' do
+ expect(Version.new.to_s).to eq('')
+ end
+ it 'returns \'\' for empty version' do
+ expect(Version.new('').to_s).to eq('')
+ end
+ it 'returns the version as a string' do
+ expect(Version.new('1.1.1.2.3.4').to_s).to eq('1.1.1.2.3.4')
+ end
+ it 'returns the version as a string without trailing zeros' do
+ expect(Version.new('1.1.0.0.0').to_s).to eq('1.1')
+ end
+ it 'returns the version as a string with inner zeros' do
+ expect(Version.new('0.0.1.0.0').to_s).to eq('0.0.1')
+ end
+ end
+
+ describe '#components' do
+ it 'returns all the components of the version' do
+ expect(Version.new('1.3.5').components).to eq([1, 3, 5])
+ end
+ it 'returns the components without trailing zeros' do
+ expect(Version.new('1.3.5.0').components).to eq([1, 3, 5])
+ end
+ it 'returns the components with inner zeros' do
+ expect(Version.new('0.3.0.5').components).to eq([0, 3, 0, 5])
+ end
+ # undefined behaviour
+ # it 'returns the components with a given number 0' do
+ # expect(Version.new('1.3.0.5').components(0)).to eq([1, 3, 0, 5])
+ # end
+ it 'returns all components equal to a given number' do
+ expect(Version.new('1.3.0.5').components(4)).to eq([1, 3, 0, 5])
+ end
+ it 'returns only components less than a given number' do
+ expect(Version.new('1.3.0.5').components(3)).to eq([1, 3, 0])
+ end
+ it 'returns the components with trailing zeros for a bigger number' do
+ expect(Version.new('1.0.5').components(6)).to eq([1, 0, 5, 0, 0, 0])
+ end
+ it 'does not mutate the version' do
+ version = Version.new('1.3.5')
+ expect(version.components).to eq([1, 3, 5])
+ expect(version.components.reverse!).to eq([5, 3, 1])
+ expect(version.components).to eq([1, 3, 5])
+ end
+ end
+
+ describe Range do
+ describe '#include?' do
+ context 'versions as objects' do
+ it 'a version is inside a given range' do
+ version1 = Version.new('1.1.1')
+ version2 = Version.new('2.2.1')
+ version3 = Version.new('1.5.1')
+ range = Version::Range.new(version1, version2)
+ expect(range.include?(version3)).to eq(true)
+ end
+ it 'a version equal to start is inside a given range' do
+ version1 = Version.new('1.1.1')
+ version2 = Version.new('2.2.1')
+ range = Version::Range.new(version1, version2)
+ expect(range.include?(version1)).to eq(true)
+ end
+ it 'a version is not inside a given range' do
+ version1 = Version.new('1.1.1')
+ version2 = Version.new('2.2.1')
+ version3 = Version.new('2.2.2')
+ range = Version::Range.new(version1, version2)
+ expect(range.include?(version3)).to eq(false)
+ end
+ it 'a version equal to end is not inside a given range' do
+ version1 = Version.new('1.1.1')
+ version2 = Version.new('2.2.1')
+ range = Version::Range.new(version1, version2)
+ expect(range.include?(version2)).to eq(false)
+ end
+ end
+ context 'versions as strings' do
+ it 'a version is inside a given range' do
+ range = Version::Range.new('1.1.1', '2.2.2')
+ expect(range.include?('1.5.1')).to eq(true)
+ end
+ it 'a version equal to start is inside a given range' do
+ range = Version::Range.new('1.1.1', '2.2.2')
+ expect(range.include?('1.1.1')).to eq(true)
+ end
+ it 'a version is not inside a given range' do
+ range = Version::Range.new('1.1.1', '2.2.2')
+ expect(range.include?('3.5.1')).to eq(false)
+ end
+ it 'a version equal to end is not inside a given range' do
+ range = Version::Range.new('1.1.1', '2.2.2')
+ expect(range.include?('2.2.2')).to eq(false)
+ end
+ end
+ end
+
+ describe '#to_a' do
+ it 'the array has the start version from the range' do
+ version1 = Version.new('1.1')
+ version2 = Version.new('1.2')
+ range = Version::Range.new(version1, version2)
+ expect(range.to_a.first).to eq(version1)
+ end
+ it 'the array does not have the end version from the range' do
+ version1 = Version.new('1.1')
+ version2 = Version.new('1.2')
+ range = Version::Range.new(version1, version2)
+ expect(range.to_a.last).not_to eq(version2)
+ end
+ it 'there is a difference of 1 between the versions in the range' do
+ version1 = Version.new('1.1.0')
+ version2 = Version.new('1.2.0')
+ range = Version::Range.new(version1, version2)
+ expected_range =
+ [
+ '1.1', '1.1.1', '1.1.2', '1.1.3', '1.1.4',
+ '1.1.5', '1.1.6', '1.1.7', '1.1.8', '1.1.9'
+ ]
+ # result = range.to_a.each_cons(2).all? do |first, second|
+ # first.components(3).last + 1 == second.components.last
+ # end
+ # expect(result).to eq(true)
+ expect(range.to_a).to eq(expected_range)
+ end
+ it 'the next final number turns to 0 when the previous one is 9' do
+ version1 = Version.new('1.1.9')
+ version2 = Version.new('1.2.1')
+ range = Version::Range.new(version1, version2)
+ # expect(range.to_a.last.components(3).last).to eq(0)
+ expect(range.to_a.last).to eq('1.2.0')
+ end
+ it 'the first version after the start is with 3 components' do
+ version1 = Version.new('0')
+ version2 = Version.new('1')
+ range = Version::Range.new(version1, version2)
+ # expect(range.to_a[1].components.size).to eq(3)
+ expect(range.to_a[1]).to eq('0.0.1')
+ end
+ it 'returns an empty array in a range with the same start and end' do
+ version1 = Version.new('1.1')
+ version2 = Version.new('1.1')
+ range = Version::Range.new(version1, version2)
+ expected_range = []
+ expect(range.to_a).to eq(expected_range)
+ end
+ end
+ end
+end