class Webspicy::Tester::Asserter
Constants
- NO_ARG
Public Class Methods
new(target)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 11 def initialize(target) @target = target @assertions = AssertionsClass.new end
Public Instance Methods
empty(path = '')
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 42 def empty(path = '') unless @assertions.empty(@target, path) _! "Expected #{_s(@target, path)} to be empty" end end
exists(path = '')
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 30 def exists(path = '') unless @assertions.exists(@target, path) _! "Expected #{_s(@target, path)} to exists" end end
idFD(path, id, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 76 def idFD(path, id, expected = NO_ARG) if expected == NO_ARG expected = id id, path = path, '' end element = @assertions.element_with_id(@target, path, id) unless element _! "Expected an element with id #{id} to contain the key(s) and value(s) #{expected}, but there is no element with that id" end unless @assertions.idFD(element, expected) _! "Expected #{_s(@target, path)} to contain the key(s) and value(s) #{expected}" end end
idIn(path, *expected)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 62 def idIn(path, *expected) path, expected = '', [path]+expected unless path.is_a?(String) unless @assertions.idIn(@target, path, expected) _! "Expected #{_s(@target, path)} to have ids #{expected.join(',')}" end end
idNotIn(path, *expected)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 69 def idNotIn(path, *expected) path, expected = '', [path]+expected unless path.is_a?(String) unless @assertions.idNotIn(@target, path, expected) _! "Expected #{_s(@target, path)} to not have ids #{expected.join(',')}" end end
includes(path, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 16 def includes(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.includes(@target, path, expected) _! "Expected #{_s(@target, path)} to include #{expected}" end end
match(path, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 97 def match(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.match(@target, path, expected) _! "Expected #{_s(@target, path)} to match #{expected.inspect}" end end
notEmpty(path = '')
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 48 def notEmpty(path = '') unless @assertions.notEmpty(@target, path) _! "Expected #{_s(@target, path)} to be non empty" end end
notExists(path = '')
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 36 def notExists(path = '') unless @assertions.notExists(@target, path) _! "Expected #{_s(@target, path)} not to exists" end end
notIncludes(path, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 23 def notIncludes(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.notIncludes(@target, path, expected) _! "Expected #{_s(@target, path)} not to include #{expected}" end end
notMatch(path, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 104 def notMatch(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.notMatch(@target, path, expected) _! "Expected #{_s(@target, path)} not to match #{expected.inspect}" end end
pathFD(path, expected)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 91 def pathFD(path, expected) unless @assertions.pathFD(@target, path, expected) _! "Expected #{_s(@target, path)} to contain the key(s) and value(s) #{expected}" end end
size(path, expected = NO_ARG)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 54 def size(path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG unless @assertions.size(@target, path, expected) actual = @assertions.actual_size(@target, path) _! "Expected #{_s(@target, path)} to have a size of #{expected}, actual size is: #{actual}" end end
Private Instance Methods
Date(str)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 117 def Date(str) Date.parse(str) end
DateTime(str)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 113 def DateTime(str) DateTime.parse(str) end
_!(msg)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 128 def _!(msg) raise Failure, msg end
_s(target, path)
click to toggle source
# File lib/webspicy/tester/asserter.rb, line 121 def _s(target, path) result = @assertions.extract_path(target, path) result = result.to_json result = result[0..25] + "..." if result.size>25 result end