Решение на Втора задача от Тихомир Янев
Обратно към всички решения
Към профила на Тихомир Янев
Резултати
- 2 точки от тестове
- 0 бонус точки
- 2 точки общо
- 3 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
▸ Покажи лога.F.FFF.FFFF
Failures:
1) Collection can find all the names of all songs in the collection
Failure/Error: ]
expected collection contained: ["Acknowledgment", "Autumn Leaves", "Brain of J.F.K", "Come Away With Me", "Fields of Gold", "Jeremy", "Mad About You", "Ruby, My Dear"]
actual collection contained: [#<Song:0x87d79c4 @name="Fields of Gold", @artist="Sting", @album="Ten Summoner's Tales">, #<Song:0x87d780c @name="Mad About You", @artist="Sting", @album="The Soul Cages">, #<Song:0x87d76e0 @name="Fields of Gold", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0x87d7460 @name="Autumn Leaves", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0x87d726c @name="Autumn Leaves", @artist="Bill Evans", @album="Portrait in Jazz">, #<Song:0x87d6f9c @name="Brain of J.F.K", @artist="Pearl Jam", @album="Yield">, #<Song:0x87d6d30 @name="Jeremy", @artist="Pearl Jam", @album="Ten">, #<Song:0x87d63f8 @name="Come Away With Me", @artist="Norah Johnes", @album="One">, #<Song:0x87d613c @name="Acknowledgment", @artist="John Coltrane", @album="A Love Supreme">, #<Song:0x87d5ac0 @name="Ruby, My Dear", @artist="Thelonious Monk", @album="Mysterioso">]
the missing elements were: ["Acknowledgment", "Autumn Leaves", "Brain of J.F.K", "Come Away With Me", "Fields of Gold", "Jeremy", "Mad About You", "Ruby, My Dear"]
the extra elements were: [#<Song:0x87d79c4 @name="Fields of Gold", @artist="Sting", @album="Ten Summoner's Tales">, #<Song:0x87d780c @name="Mad About You", @artist="Sting", @album="The Soul Cages">, #<Song:0x87d76e0 @name="Fields of Gold", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0x87d7460 @name="Autumn Leaves", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0x87d726c @name="Autumn Leaves", @artist="Bill Evans", @album="Portrait in Jazz">, #<Song:0x87d6f9c @name="Brain of J.F.K", @artist="Pearl Jam", @album="Yield">, #<Song:0x87d6d30 @name="Jeremy", @artist="Pearl Jam", @album="Ten">, #<Song:0x87d63f8 @name="Come Away With Me", @artist="Norah Johnes", @album="One">, #<Song:0x87d613c @name="Acknowledgment", @artist="John Coltrane", @album="A Love Supreme">, #<Song:0x87d5ac0 @name="Ruby, My Dear", @artist="Thelonious Monk", @album="Mysterioso">]
# /tmp/d20130203-23049-9dt4m0/spec.rb:26:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
2) Collection can be filtered by song name
Failure/Error: filtered.map(&:artist).should =~ ['Eva Cassidy', 'Sting']
NoMethodError:
undefined method `artist' for [0, [["Fields of Gold", 0], ["Fields of Gold", 3]]]:Array
# /tmp/d20130203-23049-9dt4m0/spec.rb:45:in `each'
# /tmp/d20130203-23049-9dt4m0/spec.rb:45:in `map'
# /tmp/d20130203-23049-9dt4m0/spec.rb:45:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
3) Collection can be filtered by song name
Failure/Error: filtered.map(&:album).should =~ ['The Soul Cages', "Ten Summoner's Tales"]
NoMethodError:
undefined method `album' for [0, [["Sting", 0], ["Sting", 3]]]:Array
# /tmp/d20130203-23049-9dt4m0/spec.rb:50:in `each'
# /tmp/d20130203-23049-9dt4m0/spec.rb:50:in `map'
# /tmp/d20130203-23049-9dt4m0/spec.rb:50:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
4) Collection can be filtered by album
Failure/Error: filtered.map(&:name).should =~ ['Fields of Gold', 'Autumn Leaves']
NoMethodError:
undefined method `name' for [0, [["Live at Blues Alley", 0], ["Live at Blues Alley", 3]]]:Array
# /tmp/d20130203-23049-9dt4m0/spec.rb:55:in `each'
# /tmp/d20130203-23049-9dt4m0/spec.rb:55:in `map'
# /tmp/d20130203-23049-9dt4m0/spec.rb:55:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
5) Collection supports a conjuction of filters
Failure/Error: filtered = collection.filter Criteria.artist('Sting') & Criteria.name('Fields of Gold')
NoMethodError:
undefined method `&' for {1=>"Sting"}:Hash
# /tmp/d20130203-23049-9dt4m0/spec.rb:64:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
6) Collection supports a disjunction of filters
Failure/Error: filtered = collection.filter Criteria.artist('Sting') | Criteria.name('Fields of Gold')
NoMethodError:
undefined method `|' for {1=>"Sting"}:Hash
# /tmp/d20130203-23049-9dt4m0/spec.rb:69:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
7) Collection supports negation of filters
Failure/Error: filtered = collection.filter Criteria.artist('Sting') & !Criteria.name('Fields of Gold')
NoMethodError:
undefined method `&' for {1=>"Sting"}:Hash
# /tmp/d20130203-23049-9dt4m0/spec.rb:78:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
8) Collection can be adjoined with another collection
Failure/Error: adjoined = sting.adjoin(eva)
NoMethodError:
undefined method `adjoin' for #<Hash:0x9051c30>
# /tmp/d20130203-23049-9dt4m0/spec.rb:85:in `block (2 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
# ./lib/homework/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'
Finished in 0.01155 seconds
11 examples, 8 failures
Failed examples:
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:16 # Collection can find all the names of all songs in the collection
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:43 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:48 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:53 # Collection can be filtered by album
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:63 # Collection supports a conjuction of filters
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:68 # Collection supports a disjunction of filters
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:77 # Collection supports negation of filters
rspec /tmp/d20130203-23049-9dt4m0/spec.rb:82 # Collection can be adjoined with another collection
История (1 версия и 0 коментара)
Тихомир обнови решението на 31.10.2012 16:20 (преди около 12 години)
▸ Покажи разликите