Решение на Втора задача от Даяна Беркова
Обратно към всички решения
Към профила на Даяна Беркова
Резултати
- 2 точки от тестове
- 0 бонус точки
- 2 точки общо
- 3 успешни тест(а)
- 8 неуспешни тест(а)
Код
Лог от изпълнението
...["Fields of Gold, Sting, Ten Summoner's Tales", "Fields of Gold, Eva Cassidy, Live at Blues Alley"]
F["Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages"]
F["Fields of Gold, Eva Cassidy, Live at Blues Alley", "Autumn Leaves, Eva Cassidy, Live at Blues Alley"]
F[]
F["Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages"]
F["Fields of Gold, Sting, Ten Summoner's Tales", "Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages", "Fields of Gold, Eva Cassidy, Live at Blues Alley"]
F["Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages"]
F["Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages"]
["Fields of Gold, Sting, Ten Summoner's Tales", "Mad About You, Sting, The Soul Cages", "Fields of Gold, Eva Cassidy, Live at Blues Alley", "Autumn Leaves, Eva Cassidy, Live at Blues Alley"]
F
Failures:
1) Collection can be filtered by song name
Failure/Error: filtered.map(&:artist).should =~ ['Eva Cassidy', 'Sting']
expected collection contained: ["Eva Cassidy", "Sting"]
actual collection contained: ["Bill Evans", "Eva Cassidy", "Eva Cassidy", "John Coltrane", "Norah Johnes", "Pearl Jam", "Pearl Jam", "Sting", "Sting", "Thelonious Monk"]
the extra elements were: ["Bill Evans", "Eva Cassidy", "John Coltrane", "Norah Johnes", "Pearl Jam", "Pearl Jam", "Sting", "Thelonious Monk"]
# /tmp/d20130203-23049-1kz7j3n/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)>'
2) Collection can be filtered by song name
Failure/Error: filtered.map(&:album).should =~ ['The Soul Cages', "Ten Summoner's Tales"]
expected collection contained: ["Ten Summoner's Tales", "The Soul Cages"]
actual collection contained: ["A Love Supreme", "Live at Blues Alley", "Live at Blues Alley", "Mysterioso", "One", "Portrait in Jazz", "Ten", "Ten Summoner's Tales", "The Soul Cages", "Yield"]
the extra elements were: ["A Love Supreme", "Live at Blues Alley", "Live at Blues Alley", "Mysterioso", "One", "Portrait in Jazz", "Ten", "Yield"]
# /tmp/d20130203-23049-1kz7j3n/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)>'
3) Collection can be filtered by album
Failure/Error: filtered.map(&:name).should =~ ['Fields of Gold', 'Autumn Leaves']
expected collection contained: ["Autumn Leaves", "Fields of Gold"]
actual collection contained: ["Acknowledgment", "Autumn Leaves", "Autumn Leaves", "Brain of J.F.K", "Come Away With Me", "Fields of Gold", "Fields of Gold", "Jeremy", "Mad About You", "Ruby, My Dear"]
the extra elements were: ["Acknowledgment", "Autumn Leaves", "Brain of J.F.K", "Come Away With Me", "Fields of Gold", "Jeremy", "Mad About You", "Ruby, My Dear"]
# /tmp/d20130203-23049-1kz7j3n/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)>'
4) Collection can return an empty result
Failure/Error: filtered.to_a.should eq []
expected: []
got: [#<Song:0xa0c1aac @name="Fields of Gold", @artist="Sting", @album="Ten Summoner's Tales">, #<Song:0xa0c1a5c @name="Mad About You", @artist="Sting", @album="The Soul Cages">, #<Song:0xa0c1a0c @name="Fields of Gold", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0xa0c19a8 @name="Autumn Leaves", @artist="Eva Cassidy", @album="Live at Blues Alley">, #<Song:0xa0c1958 @name="Autumn Leaves", @artist="Bill Evans", @album="Portrait in Jazz">, #<Song:0xa0c1930 @name="Brain of J.F.K", @artist="Pearl Jam", @album="Yield">, #<Song:0xa0c1804 @name="Jeremy", @artist="Pearl Jam", @album="Ten">, #<Song:0xa0c17b4 @name="Come Away With Me", @artist="Norah Johnes", @album="One">, #<Song:0xa0c1778 @name="Acknowledgment", @artist="John Coltrane", @album="A Love Supreme">, #<Song:0xa0c164c @name="Ruby, My Dear", @artist="Thelonious Monk", @album="Mysterioso">]
(compared using ==)
Diff:
@@ -1,2 +1,35 @@
-[]
+[#<Song:0xa0c1aac
+ @album="Ten Summoner's Tales",
+ @artist="Sting",
+ @name="Fields of Gold">,
+ #<Song:0xa0c1a5c
+ @album="The Soul Cages",
+ @artist="Sting",
+ @name="Mad About You">,
+ #<Song:0xa0c1a0c
+ @album="Live at Blues Alley",
+ @artist="Eva Cassidy",
+ @name="Fields of Gold">,
+ #<Song:0xa0c19a8
+ @album="Live at Blues Alley",
+ @artist="Eva Cassidy",
+ @name="Autumn Leaves">,
+ #<Song:0xa0c1958
+ @album="Portrait in Jazz",
+ @artist="Bill Evans",
+ @name="Autumn Leaves">,
+ #<Song:0xa0c1930 @album="Yield", @artist="Pearl Jam", @name="Brain of J.F.K">,
+ #<Song:0xa0c1804 @album="Ten", @artist="Pearl Jam", @name="Jeremy">,
+ #<Song:0xa0c17b4
+ @album="One",
+ @artist="Norah Johnes",
+ @name="Come Away With Me">,
+ #<Song:0xa0c1778
+ @album="A Love Supreme",
+ @artist="John Coltrane",
+ @name="Acknowledgment">,
+ #<Song:0xa0c164c
+ @album="Mysterioso",
+ @artist="Thelonious Monk",
+ @name="Ruby, My Dear">]
# /tmp/d20130203-23049-1kz7j3n/spec.rb:60: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.map(&:album).should eq ["Ten Summoner's Tales"]
expected: ["Ten Summoner's Tales"]
got: ["Ten Summoner's Tales", "The Soul Cages", "Live at Blues Alley", "Live at Blues Alley", "Portrait in Jazz", "Yield", "Ten", "One", "A Love Supreme", "Mysterioso"]
(compared using ==)
# /tmp/d20130203-23049-1kz7j3n/spec.rb:65: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: ]
expected collection contained: ["Live at Blues Alley", "Ten Summoner's Tales", "The Soul Cages"]
actual collection contained: ["A Love Supreme", "Live at Blues Alley", "Live at Blues Alley", "Mysterioso", "One", "Portrait in Jazz", "Ten", "Ten Summoner's Tales", "The Soul Cages", "Yield"]
the extra elements were: ["A Love Supreme", "Live at Blues Alley", "Mysterioso", "One", "Portrait in Jazz", "Ten", "Yield"]
# /tmp/d20130203-23049-1kz7j3n/spec.rb:74: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.map(&:name).should eq ['Mad About You']
expected: ["Mad About You"]
got: ["Fields of Gold", "Mad About You", "Fields of Gold", "Autumn Leaves", "Autumn Leaves", "Brain of J.F.K", "Jeremy", "Come Away With Me", "Acknowledgment", "Ruby, My Dear"]
(compared using ==)
# /tmp/d20130203-23049-1kz7j3n/spec.rb:79: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.names.should =~ [
NoMethodError:
undefined method `names' for #<Array:0xa479564>
# /tmp/d20130203-23049-1kz7j3n/spec.rb:88: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.02383 seconds
11 examples, 8 failures
Failed examples:
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:43 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:48 # Collection can be filtered by song name
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:53 # Collection can be filtered by album
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:58 # Collection can return an empty result
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:63 # Collection supports a conjuction of filters
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:68 # Collection supports a disjunction of filters
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:77 # Collection supports negation of filters
rspec /tmp/d20130203-23049-1kz7j3n/spec.rb:82 # Collection can be adjoined with another collection
История (1 версия и 0 коментара)
Даяна обнови решението на 31.10.2012 16:56 (преди около 12 години)