Решение на Пета задача - DataModel от Петко Митков
Обратно към всички решения
Към профила на Петко Митков
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 19 успешни тест(а)
- 6 неуспешни тест(а)
Код
Лог от изпълнението
.......FF...F....F....FF.
Failures:
1) DataModel equality comparison compares by id if both records are saved
Failure/Error: modified_ivan.first_name = 'Gosho'
NoMethodError:
undefined method `first_name=' for nil:NilClass
# /tmp/d20161202-15620-ftsv2s/spec.rb:103: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) DataModel equality comparison uses #equal? if there are no ids
Failure/Error: expect(first_user).to_not eq second_user
expected: value != #<#<Class:0x007fb746eda530>:0x007fb746ed8b18 @first_name="Ivan">
got: #<#<Class:0x007fb746eda530>:0x007fb746ed8cf8 @first_name="Ivan">
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-#<#<Class:0x007fb746eda530>:0x007fb746ed8b18 @first_name="Ivan">
+#<#<Class:0x007fb746eda530>:0x007fb746ed8cf8 @first_name="Ivan">
# /tmp/d20161202-15620-ftsv2s/spec.rb:112: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)>'
3) DataModel.where raises an error if the query is by an unknown key
Failure/Error: DataModel::UnknownAttributeError,
NameError:
uninitialized constant DataModel::UnknownAttributeError
# /tmp/d20161202-15620-ftsv2s/spec.rb:144: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)>'
4) HashStore behaves like a data store #update updates the attributes of a record with a given ID
Failure/Error: expect(store.find(id: 2)).to eq [{id: 2, name: 'Georgi'}]
expected: [{:id=>2, :name=>"Georgi"}]
got: [{:id=>2, :name=>"Pesho"}, {:id=>2, :name=>"Georgi"}]
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[{:id=>2, :name=>"Georgi"}]
+[{:id=>2, :name=>"Pesho"}, {:id=>2, :name=>"Georgi"}]
Shared Example Group: "a data store" called from /tmp/d20161202-15620-ftsv2s/spec.rb:235
# /tmp/d20161202-15620-ftsv2s/spec.rb:201: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)>'
5) ArrayStore behaves like a data store #update updates the attributes of a record with a given ID
Failure/Error: expect(store.find(id: 2)).to eq [{id: 2, name: 'Georgi'}]
expected: [{:id=>2, :name=>"Georgi"}]
got: [{:id=>2, :name=>"Pesho"}]
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[{:id=>2, :name=>"Georgi"}]
+[{:id=>2, :name=>"Pesho"}]
Shared Example Group: "a data store" called from /tmp/d20161202-15620-ftsv2s/spec.rb:239
# /tmp/d20161202-15620-ftsv2s/spec.rb:201: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)>'
6) ArrayStore behaves like a data store #update only updates records with the correct IDs
Failure/Error: expect(store.find(id: 2)).to eq [{id: 2, name: 'Sasho'}]
expected: [{:id=>2, :name=>"Sasho"}]
got: [{:id=>2, :name=>"Pesho"}]
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-[{:id=>2, :name=>"Sasho"}]
+[{:id=>2, :name=>"Pesho"}]
Shared Example Group: "a data store" called from /tmp/d20161202-15620-ftsv2s/spec.rb:239
# /tmp/d20161202-15620-ftsv2s/spec.rb:213: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 0.02895 seconds
25 examples, 6 failures
Failed examples:
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:92 # DataModel equality comparison compares by id if both records are saved
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:108 # DataModel equality comparison uses #equal? if there are no ids
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:142 # DataModel.where raises an error if the query is by an unknown key
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:196 # HashStore behaves like a data store #update updates the attributes of a record with a given ID
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:196 # ArrayStore behaves like a data store #update updates the attributes of a record with a given ID
rspec /tmp/d20161202-15620-ftsv2s/spec.rb:204 # ArrayStore behaves like a data store #update only updates records with the correct IDs
История (6 версии и 0 коментара)
Петко обнови решението на 01.12.2016 22:30 (преди около 8 години)
Петко обнови решението на 01.12.2016 22:38 (преди около 8 години)
Петко обнови решението на 01.12.2016 23:18 (преди около 8 години)
Петко обнови решението на 01.12.2016 23:33 (преди около 8 години)
Петко обнови решението на 01.12.2016 23:47 (преди около 8 години)
Петко обнови решението на 01.12.2016 23:54 (преди около 8 години)