Class: Webspicy::Tester::Asserter
- Inherits:
-
Object
- Object
- Webspicy::Tester::Asserter
- Defined in:
- lib/webspicy/tester/asserter.rb
Defined Under Namespace
Classes: AssertionsClass
Constant Summary collapse
- NO_ARG =
Object.new
Instance Method Summary collapse
- #empty(path = '') ⇒ Object
- #exists(path = '') ⇒ Object
- #idFD(path, id, expected = NO_ARG) ⇒ Object
- #idIn(path, *expected) ⇒ Object
- #idNotIn(path, *expected) ⇒ Object
-
#initialize(target) ⇒ Asserter
constructor
A new instance of Asserter.
- #notEmpty(path = '') ⇒ Object
- #notExists(path = '') ⇒ Object
- #pathFD(path, expected) ⇒ Object
- #size(path, expected = NO_ARG) ⇒ Object
Constructor Details
#initialize(target) ⇒ Asserter
Returns a new instance of Asserter.
11 12 13 14 |
# File 'lib/webspicy/tester/asserter.rb', line 11 def initialize(target) @target = target @assertions = AssertionsClass.new end |
Instance Method Details
#empty(path = '') ⇒ Object
28 29 30 31 32 |
# File 'lib/webspicy/tester/asserter.rb', line 28 def empty(path = '') unless @assertions.empty(@target, path) _! "Expected #{_s(@target)} to be empty" end end |
#exists(path = '') ⇒ Object
16 17 18 19 20 |
# File 'lib/webspicy/tester/asserter.rb', line 16 def exists(path = '') unless @assertions.exists(@target, path) _! "Expected #{_s(@target)} to exists" end end |
#idFD(path, id, expected = NO_ARG) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/webspicy/tester/asserter.rb', line 61 def idFD(path, id, expected = NO_ARG) if expected == NO_ARG expected = id id, path = path, '' end unless @assertions.idFD(@target, path, id, expected) _! "Expected #{_s(@target)} to meet FD #{expected.inspect}" end end |
#idIn(path, *expected) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/webspicy/tester/asserter.rb', line 47 def idIn(path, *expected) path, expected = '', [path]+expected unless path.is_a?(String) unless @assertions.idIn(@target, path, expected) _! "Expected #{_s(@target)} to have ids #{expected.join(',')}" end end |
#idNotIn(path, *expected) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/webspicy/tester/asserter.rb', line 54 def idNotIn(path, *expected) path, expected = '', [path]+expected unless path.is_a?(String) unless @assertions.idNotIn(@target, path, expected) _! "Expected #{_s(@target)} to not have ids #{expected.join(',')}" end end |
#notEmpty(path = '') ⇒ Object
34 35 36 37 38 |
# File 'lib/webspicy/tester/asserter.rb', line 34 def notEmpty(path = '') unless @assertions.notEmpty(@target, path) _! "Expected #{_s(@target)} to be non empty" end end |
#notExists(path = '') ⇒ Object
22 23 24 25 26 |
# File 'lib/webspicy/tester/asserter.rb', line 22 def notExists(path = '') unless @assertions.notExists(@target, path) _! "Expected #{_s(@target)} not to exists" end end |
#pathFD(path, expected) ⇒ Object
71 72 73 74 75 |
# File 'lib/webspicy/tester/asserter.rb', line 71 def pathFD(path, expected) unless @assertions.pathFD(@target, path, expected) _! "Expected #{_s(@target)} to meet FD #{expected.inspect}" end end |
#size(path, expected = NO_ARG) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/webspicy/tester/asserter.rb', line 40 def size(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.size(@target, path, expected) _! "Expected #{_s(@target)} to have a size of #{expected}" end end |