Module: Webspicy::Tester::Assertions
- Included in:
- Webspicy::Tester::Asserter::AssertionsClass
- Defined in:
- lib/webspicy/tester/assertions.rb
Defined Under Namespace
Classes: InvalidArgError
Constant Summary collapse
- NO_ARG =
Object.new
Instance Method Summary collapse
- #empty(target, path = NO_ARG) ⇒ Object
- #exists(target, path = NO_ARG) ⇒ Object
- #idFD(target, path, id, expected = NO_ARG) ⇒ Object
- #idIn(target, path, expected = NO_ARG) ⇒ Object
- #idNotIn(target, path, expected = NO_ARG) ⇒ Object
- #notEmpty(target, path = NO_ARG) ⇒ Object
- #notExists(target, path = NO_ARG) ⇒ Object
- #pathFD(target, path, expected) ⇒ Object
- #size(target, path, expected = NO_ARG) ⇒ Object
Instance Method Details
#empty(target, path = NO_ARG) ⇒ Object
19 20 21 22 |
# File 'lib/webspicy/tester/assertions.rb', line 19 def empty(target, path = NO_ARG) target = extract_path(target, path) respond_to!(target, :empty?).empty? end |
#exists(target, path = NO_ARG) ⇒ Object
9 10 11 12 |
# File 'lib/webspicy/tester/assertions.rb', line 9 def exists(target, path = NO_ARG) target = extract_path(target, path) not target.nil? end |
#idFD(target, path, id, expected = NO_ARG) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/webspicy/tester/assertions.rb', line 52 def idFD(target, path, id, expected = NO_ARG) if expected == NO_ARG expected = id id, path = path, '' end target = extract_path(target, path) found = an_array(target).find{|t| t[:id] == id } expected.keys.all?{|k| value_equal(expected[k], found[k]) } end |
#idIn(target, path, expected = NO_ARG) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/webspicy/tester/assertions.rb', line 34 def idIn(target, path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG target = extract_path(target, path) ids = an_array(target).map do |tuple| respond_to!(tuple, :[])[:id] end ids.to_set == expected.to_set end |
#idNotIn(target, path, expected = NO_ARG) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/webspicy/tester/assertions.rb', line 43 def idNotIn(target, path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG target = extract_path(target, path) ids = an_array(target).map do |tuple| respond_to!(tuple, :[])[:id] end (ids.to_set & expected.to_set).empty? end |
#notEmpty(target, path = NO_ARG) ⇒ Object
24 25 26 |
# File 'lib/webspicy/tester/assertions.rb', line 24 def notEmpty(target, path = NO_ARG) not empty(target, path) end |
#notExists(target, path = NO_ARG) ⇒ Object
14 15 16 17 |
# File 'lib/webspicy/tester/assertions.rb', line 14 def notExists(target, path = NO_ARG) target = extract_path(target, path) target.nil? end |
#pathFD(target, path, expected) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/webspicy/tester/assertions.rb', line 64 def pathFD(target, path, expected) target = extract_path(target, path) expected.keys.all?{|k| value_equal(expected[k], target[k]) } end |
#size(target, path, expected = NO_ARG) ⇒ Object
28 29 30 31 32 |
# File 'lib/webspicy/tester/assertions.rb', line 28 def size(target, path, expected = NO_ARG) path, expected = '', path if expected == NO_ARG target = extract_path(target, path) respond_to!(target, :size).size == expected end |