Class: PayloadTest

Inherits:
Minitest::Test
  • Object
show all
Includes:
TestUtils::Payload
Defined in:
lib/shaf/spec/payload_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/shaf/spec/payload_test.rb', line 8

def setup
  @payload = {
    attr1: 1,
    attr2: 2,
    _links: {
      link1: {
        href: '/link1'
      },
      link2: {
        href: '/link2'
      }
    },
    _embedded: {
      embed1: {
        attr_e1: 'e1',
        _links: {
          link_e1: {
            href: '/links/e1'
          }
        },
        _embedded: {
          embed1a: {
            attr_e1a: 'e1a'
          }
        }
      },
      embed2: [
        {
          attr_embed2a: 'e2a',
          _links: {
            link_e2a: {
              href: 'links/e2a'
            }
          }
        },
        {
          attr_embed2b: 'e2b',
          _links: {
            link_e2b: {
              href: 'links/e2b'
            }
          }
        }
      ]
    }
  }
end

#test_embedded_with_blockObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/shaf/spec/payload_test.rb', line 68

def test_embedded_with_block
  embedded :embed1 do
    assert_attribute :attr_e1, 'e1'
    assert_link :link_e1, '/links/e1'

    embedded :embed1a do
      assert_attribute :attr_e1a, 'e1a'
    end
  end
end

#test_embedded_without_blockObject



63
64
65
66
# File 'lib/shaf/spec/payload_test.rb', line 63

def test_embedded_without_block
  assert_equal @payload[:_embedded], embedded
  assert_equal @payload[:_embedded][:embed1], embedded(:embed1)
end

TODO How to verify that we do get assertions



58
59
60
61
# File 'lib/shaf/spec/payload_test.rb', line 58

def test_links
  assert_link :link1, '/link1'
  assert_link :link2, '/link2'
end