Решение на Седма задача - ретроспекция от Никола Жишев
Обратно към всички решения
Към профила на Никола Жишев
Резултати
- 0 точки от тестове
- 2 бонус точки
- 2 точки общо
- 0 успешни тест(а)
- 1 неуспешни тест(а)
Код
Лог от изпълнението
From https://github.com/fmi/ruby-retrospective-2016
* branch master -> FETCH_HEAD
HEAD is now at a22cf37 Set rubocop version to 0.46.0 to fix obsolete cop errors
Cloning into 'submission'...
HEAD is now at 40673a8 Add solution to third problem.
From /tmp/ruby-retrospective-2016/checker
* branch master -> FETCH_HEAD
* [new branch] master -> upstream/master
Changes URL:
https://github.com/njichev/ruby-retrospective-2016/compare/1f710b00c26...40673a8a6a1
'tasks/1/solution.rb' -> '/tmp/ruby-retrospective-2016/checker/tasks/1/solution.rb'
'tasks/2/solution.rb' -> '/tmp/ruby-retrospective-2016/checker/tasks/2/solution.rb'
'tasks/3/solution.rb' -> '/tmp/ruby-retrospective-2016/checker/tasks/3/solution.rb'
'tasks/4/solution.rb' -> '/tmp/ruby-retrospective-2016/checker/tasks/4/solution.rb'
'tasks/5/solution.rb' -> '/tmp/ruby-retrospective-2016/checker/tasks/5/solution.rb'
Inspecting 1 file
.
1 file inspected, no offenses detected
.................
Finished in 0.0053 seconds
17 examples, 0 failures
Inspecting 1 file
.
1 file inspected, no offenses detected
...............
Finished in 0.00519 seconds
15 examples, 0 failures
Inspecting 1 file
.
1 file inspected, no offenses detected
...............
Finished in 0.00748 seconds
15 examples, 0 failures
Inspecting 1 file
.
1 file inspected, no offenses detected
F
Failures:
1) spec passes for the correct solution
Failure/Error: expect(SOLUTION).to pass_tests
expected this solution to 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)
(@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
RSpec log:
F....F............
Failures:
1) Version doesn't create invalid versions
Failure/Error: expect { Version.new('123213212..') }.to raise_error(
expected ArgumentError with "Invalid version string '123213213..'", got #<ArgumentError: Invalid version string '123213212..'> with backtrace:
# ./solution.rb:8:in `initialize'
# ./solution_spec.rb:11:in `new'
# ./solution_spec.rb:11:in `block (3 levels) in <top (required)>'
# ./solution_spec.rb:11:in `block (2 levels) in <top (required)>'
# ./solution_spec.rb:11:in `block (2 levels) in <top (required)>'
2) Version is returns copy of the components
Failure/Error: expect(version).to eq v('1.2.3')
NoMethodError:
undefined method `v' for #<RSpec::Core::ExampleGroup::Nested_1:0x005562da4a5cd0>
# ./solution_spec.rb:45:in `block (2 levels) in <top (required)>'
Finished in 0.0128 seconds
18 examples, 2 failures
Failed examples:
rspec ./solution_spec.rb:2 # Version doesn't create invalid versions
rspec ./solution_spec.rb:41 # Version is returns copy of the components
# ./spec.rb:180:in `block (2 levels) in <top (required)>'
Finished in 0.77607 seconds
1 example, 1 failure
Failed examples:
rspec ./spec.rb:179 # spec passes for the correct solution
F
Failures:
1) ruby-retrospective-2016 covers the minimum requirements
Failure/Error: system(command) or raise "Command failed for #{@solutions_repo}: #{command}"
RuntimeError:
Command failed for https://github.com/njichev/ruby-retrospective-2016: bundle exec rake check_all
# /tmp/d20170211-11010-1y6xoxo/spec.rb:82:in `execute'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:75:in `block (3 levels) in solutions_pass_all_checks'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:74:in `chdir'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:74:in `block (2 levels) in solutions_pass_all_checks'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:40:in `chdir'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:40:in `block in solutions_pass_all_checks'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:39:in `solutions_pass_all_checks'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:19:in `ok?'
# /tmp/d20170211-11010-1y6xoxo/spec.rb:101:in `<top (required)>'
Finished in 0.00093 seconds
1 example, 1 failure
Failed examples:
rspec /tmp/d20170211-11010-1y6xoxo/spec.rb:107 # ruby-retrospective-2016 covers the minimum requirements
История (1 версия и 0 коментара)
Никола обнови решението на 16.01.2017 16:56 (преди почти 8 години)