Class: Webspicy::Tester::Asserter

Inherits:
Object
  • Object
show all
Defined in:
lib/webspicy/tester/asserter.rb

Defined Under Namespace

Classes: AssertionsClass

Constant Summary collapse

NO_ARG =
Object.new

Instance Method Summary collapse

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



42
43
44
45
46
# 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 = '') ⇒ Object



30
31
32
33
34
# 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) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/webspicy/tester/asserter.rb', line 75

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, path)} to meet FD #{expected.inspect}"
  end
end

#idIn(path, *expected) ⇒ Object



61
62
63
64
65
66
# File 'lib/webspicy/tester/asserter.rb', line 61

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) ⇒ Object



68
69
70
71
72
73
# File 'lib/webspicy/tester/asserter.rb', line 68

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) ⇒ Object



16
17
18
19
20
21
# 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) ⇒ Object



91
92
93
94
95
96
# File 'lib/webspicy/tester/asserter.rb', line 91

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 = '') ⇒ Object



48
49
50
51
52
# 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 = '') ⇒ Object



36
37
38
39
40
# 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) ⇒ Object



23
24
25
26
27
28
# 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) ⇒ Object



98
99
100
101
102
103
# File 'lib/webspicy/tester/asserter.rb', line 98

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) ⇒ Object



85
86
87
88
89
# File 'lib/webspicy/tester/asserter.rb', line 85

def pathFD(path, expected)
  unless @assertions.pathFD(@target, path, expected)
    _! "Expected #{_s(@target, path)} to meet FD #{expected.inspect}"
  end
end

#size(path, expected = NO_ARG) ⇒ Object



54
55
56
57
58
59
# 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)
    _! "Expected #{_s(@target, path)} to have a size of #{expected}"
  end
end