Решение на Четвърта задача от Даяна Беркова
Обратно към всички решения
Към профила на Даяна Беркова
Резултати
- 4 точки от тестове
- 0 бонус точки
- 4 точки общо
- 30 успешни тест(а)
- 11 неуспешни тест(а)
Код
Лог от изпълнението
..FF.....F...F..FF.F.FF...F.............F
Failures:
1) PrivacyFilter obfuscates more complicated emails
Failure/Error: filter(text).should eq filtered
expected: "Contact: [EMAIL],[EMAIL]"
got: "Contact: [EMAIL],[EMAIL]mple123.co.uk"
(compared using ==)
# /tmp/d20130203-23049-o1s1t7/spec.rb:40:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:39:in `each'
# /tmp/d20130203-23049-o1s1t7/spec.rb:39: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 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-o1s1t7/spec.rb:52:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:46:in `each'
# /tmp/d20130203-23049-o1s1t7/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)>'
3) 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-o1s1t7/spec.rb:96:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:95:in `each'
# /tmp/d20130203-23049-o1s1t7/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)>'
4) PrivacyFilter separates preserved country code from filtered phone with a space
Failure/Error: filter.filtered.should eq filtered
expected: "Phone: 0025 [FILTERED]"
got: "Phone: 0025( [FILTEERD]"
(compared using ==)
# /tmp/d20130203-23049-o1s1t7/spec.rb:144:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:141:in `each'
# /tmp/d20130203-23049-o1s1t7/spec.rb:141: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 emails
Failure/Error: Validations.email?(email).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-o1s1t7/spec.rb:171:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:170:in `each'
# /tmp/d20130203-23049-o1s1t7/spec.rb:170: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 does not break on emails in multiline strings
Failure/Error: Validations.email?("foo@bar.com\nwat?").should be_false
expected: false value
got: true
# /tmp/d20130203-23049-o1s1t7/spec.rb:176: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 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-o1s1t7/spec.rb:210:in `block (3 levels) in <top (required)>'
# /tmp/d20130203-23049-o1s1t7/spec.rb:209:in `each'
# /tmp/d20130203-23049-o1s1t7/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)>'
8) Validations validates hostnames
Failure/Error: Validations.hostname?('1.2.3.4.xip.io').should be_true
expected: true value
got: false
# /tmp/d20130203-23049-o1s1t7/spec.rb:222: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)>'
9) Validations handles multiline strings in hostname validation properly
Failure/Error: Validations.hostname?("foo.com\n").should be_false
expected: false value
got: true
# /tmp/d20130203-23049-o1s1t7/spec.rb:233: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)>'
10) Validations validates more complex numbers
Failure/Error: Validations.number?('0.0').should be_true
expected: true value
got: false
# /tmp/d20130203-23049-o1s1t7/spec.rb:265: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)>'
11) Validations handles newlines in time and datetime validation
Failure/Error: Validations.date_time?("2012-11-19 12:01:01\n").should be_false
expected: false value
got: true
# /tmp/d20130203-23049-o1s1t7/spec.rb:362: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.04937 seconds
41 examples, 11 failures
Failed examples:
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:30 # PrivacyFilter obfuscates more complicated emails
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:44 # PrivacyFilter does not filter invalid emails
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:89 # PrivacyFilter does not filter invalid phone numbers
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:136 # PrivacyFilter separates preserved country code from filtered phone with a space
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:160 # Validations can validate more complex emails
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:175 # Validations does not break on emails in multiline strings
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:184 # Validations can validate more complex phone numbers
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:218 # Validations validates hostnames
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:232 # Validations handles multiline strings in hostname validation properly
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:257 # Validations validates more complex numbers
rspec /tmp/d20130203-23049-o1s1t7/spec.rb:359 # Validations handles newlines in time and datetime validation
История (1 версия и 0 коментара)
Даяна обнови решението на 28.11.2012 14:05 (преди почти 12 години)