Решение на Четвърта задача от Георги Буюклиев

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

Към профила на Георги Буюклиев

Резултати

  • 1 точка от тестове
  • 0 бонус точки
  • 1 точка общо
  • 1 успешни тест(а)
  • 10 неуспешни тест(а)

Код

module UI
class TextScreen
attr_accessor :text
def initialize
@text = []
end
def self.label(hash)
text << hash[:text]
end
def self.draw(&block)
TextScreen.new.tap do |n|
n.instance_eval(&block)
end
end
end
end

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

FFFFFFFFFF.

Failures:

  1) Command Line Toolkit arranges components horizontally by default
     Failure/Error: label text: '1'
     NoMethodError:
       undefined method `label' for #<UI::TextScreen:0xba44a5b0 @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:21:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:20:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) Command Line Toolkit adding horizontal group does not change the behavior
     Failure/Error: horizontal do
     NoMethodError:
       undefined method `horizontal' for #<UI::TextScreen:0xba449084 @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:31:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:30:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) Command Line Toolkit verical group orders elements vertically
     Failure/Error: vertical do
     NoMethodError:
       undefined method `vertical' for #<UI::TextScreen:0xba443abc @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:43:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:42:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) Command Line Toolkit handles complex group nestings
     Failure/Error: vertical do
     NoMethodError:
       undefined method `vertical' for #<UI::TextScreen:0xba4428ec @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:57:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:56:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) Command Line Toolkit wraps vertically-aligned components correctly in border
     Failure/Error: vertical border: '|' do
     NoMethodError:
       undefined method `vertical' for #<UI::TextScreen:0xba44171c @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:86:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:85:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) Command Line Toolkit handles borders correctly in complex group nestings
     Failure/Error: vertical border: '|' do
     NoMethodError:
       undefined method `vertical' for #<UI::TextScreen:0xba4404e8 @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:100:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:99:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) Command Line Toolkit applies upcase to simple components
     Failure/Error: label text: 'some', style: :upcase
     NoMethodError:
       undefined method `label' for #<UI::TextScreen:0xba43b04c @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:129:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:128:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) Command Line Toolkit propagates upcase to child components
     Failure/Error: horizontal do
     NoMethodError:
       undefined method `horizontal' for #<UI::TextScreen:0xba43992c @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:138:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:137:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) Command Line Toolkit applies downcase to simple components
     Failure/Error: label text: 'SOME'
     NoMethodError:
       undefined method `label' for #<UI::TextScreen:0xba4384a0 @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:164:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:163:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) Command Line Toolkit propagates downcase to child components
     Failure/Error: horizontal do
     NoMethodError:
       undefined method `horizontal' for #<UI::TextScreen:0xba4344a4 @text=[]>
     # /tmp/d20141126-26053-npft2t/spec.rb:173:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `instance_eval'
     # /tmp/d20141126-26053-npft2t/solution.rb:15:in `block in draw'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `tap'
     # /tmp/d20141126-26053-npft2t/solution.rb:14:in `draw'
     # /tmp/d20141126-26053-npft2t/spec.rb:8:in `block (3 levels) in <top (required)>'
     # /tmp/d20141126-26053-npft2t/spec.rb:172:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.01673 seconds
11 examples, 10 failures

Failed examples:

rspec /tmp/d20141126-26053-npft2t/spec.rb:19 # Command Line Toolkit arranges components horizontally by default
rspec /tmp/d20141126-26053-npft2t/spec.rb:29 # Command Line Toolkit adding horizontal group does not change the behavior
rspec /tmp/d20141126-26053-npft2t/spec.rb:41 # Command Line Toolkit verical group orders elements vertically
rspec /tmp/d20141126-26053-npft2t/spec.rb:55 # Command Line Toolkit handles complex group nestings
rspec /tmp/d20141126-26053-npft2t/spec.rb:84 # Command Line Toolkit wraps vertically-aligned components correctly in border
rspec /tmp/d20141126-26053-npft2t/spec.rb:98 # Command Line Toolkit handles borders correctly in complex group nestings
rspec /tmp/d20141126-26053-npft2t/spec.rb:127 # Command Line Toolkit applies upcase to simple components
rspec /tmp/d20141126-26053-npft2t/spec.rb:136 # Command Line Toolkit propagates upcase to child components
rspec /tmp/d20141126-26053-npft2t/spec.rb:162 # Command Line Toolkit applies downcase to simple components
rspec /tmp/d20141126-26053-npft2t/spec.rb:171 # Command Line Toolkit propagates downcase to child components

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

Георги обнови решението на 26.11.2014 16:56 (преди почти 10 години)

+module UI
+ class TextScreen
+ attr_accessor :text
+
+ def initialize
+ @text = []
+ end
+
+ def self.label(hash)
+ text << hash[:text]
+ end
+
+ def self.draw(&block)
+ TextScreen.new.tap do |n|
+ n.instance_eval(&block)
+ end
+ end
+ end
+end