Решение на Четвърта задача от Георги Георгиев
Обратно към всички решения
Към профила на Георги Георгиев
Резултати
- 5 точки от тестове
- 0 бонус точки
- 5 точки общо
- 34 успешни тест(а)
- 7 неуспешни тест(а)
Код
Лог от изпълнението
...F..FF.F.........F...FF................
Failures:
1) PrivacyFilter does not filter invalid emails
Failure/Error: filter(text_with_invalid_emails).should eq text_with_invalid_emails
expected: "Contact me here: _invalid@email.com"
got: "Contact me here: _[EMAIL]"
(compared using ==)
# /tmp/d20130203-23049-1u38ew5/spec.rb:52:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-1u38ew5/spec.rb:46:in `each'
# /tmp/d20130203-23049-1u38ew5/spec.rb:46: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) PrivacyFilter filters whole email usernames if too short
Failure/Error: filter.filtered
NoMethodError:
undefined method `+' for nil:NilClass
# /tmp/d20130203-23049-1u38ew5/solution.rb:38:in `filter_email'
# /tmp/d20130203-23049-1u38ew5/solution.rb:29:in `block in filter_emails'
# /tmp/d20130203-23049-1u38ew5/solution.rb:25:in `gsub'
# /tmp/d20130203-23049-1u38ew5/solution.rb:25:in `filter_emails'
# /tmp/d20130203-23049-1u38ew5/solution.rb:12:in `filtered'
# /tmp/d20130203-23049-1u38ew5/spec.rb:17:in `partially_filter_email_usernames'
# /tmp/d20130203-23049-1u38ew5/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)>'
3) PrivacyFilter does not brake with unicode
Failure/Error: filter.filtered
NoMethodError:
undefined method `+' for nil:NilClass
# /tmp/d20130203-23049-1u38ew5/solution.rb:38:in `filter_email'
# /tmp/d20130203-23049-1u38ew5/solution.rb:29:in `block in filter_emails'
# /tmp/d20130203-23049-1u38ew5/solution.rb:25:in `gsub'
# /tmp/d20130203-23049-1u38ew5/solution.rb:25:in `filter_emails'
# /tmp/d20130203-23049-1u38ew5/solution.rb:12:in `filtered'
# /tmp/d20130203-23049-1u38ew5/spec.rb:17:in `partially_filter_email_usernames'
# /tmp/d20130203-23049-1u38ew5/spec.rb:73: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) PrivacyFilter does not filter invalid phone numbers
Failure/Error: filter(text).should eq filtered
expected: "Reach me at: 0885123"
got: "Reach me at: [PHONE]"
(compared using ==)
# /tmp/d20130203-23049-1u38ew5/spec.rb:96:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-1u38ew5/spec.rb:95:in `each'
# /tmp/d20130203-23049-1u38ew5/spec.rb:95: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) Validations can validate more complex phone numbers
Failure/Error: Validations.phone?(phone).should be(valid)
expected #<FalseClass:0> => false
got #<TrueClass:2> => true
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
'actual.should eq(expected)' if you don't care about
object identity in this example.
# /tmp/d20130203-23049-1u38ew5/spec.rb:210:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-1u38ew5/spec.rb:209:in `each'
# /tmp/d20130203-23049-1u38ew5/spec.rb:209: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) Validations validates IP addresses
Failure/Error: Validations.ip_address?('300.2.3.4').should be_false
expected: false value
got: true
# /tmp/d20130203-23049-1u38ew5/spec.rb:239: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) Validations handles multiline strings in IP validation properly
Failure/Error: Validations.ip_address?("8.8.8.8\n").should be_false
expected: false value
got: true
# /tmp/d20130203-23049-1u38ew5/spec.rb:245: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.04727 seconds
41 examples, 7 failures
Failed examples:
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:44 # PrivacyFilter does not filter invalid emails
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:68 # PrivacyFilter filters whole email usernames if too short
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:72 # PrivacyFilter does not brake with unicode
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:89 # PrivacyFilter does not filter invalid phone numbers
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:184 # Validations can validate more complex phone numbers
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:237 # Validations validates IP addresses
rspec /tmp/d20130203-23049-1u38ew5/spec.rb:244 # Validations handles multiline strings in IP validation properly
История (3 версии и 0 коментара)
Георги обнови решението на 28.11.2012 16:37 (преди почти 12 години)
Георги обнови решението на 28.11.2012 16:41 (преди почти 12 години)
Георги обнови решението на 28.11.2012 16:42 (преди почти 12 години)