|
4 | 4 | describe '#links' do |
5 | 5 | let(:links) { subject.links } |
6 | 6 |
|
7 | | - it 'returns an array of OpenStructs' do |
| 7 | + it 'returns an array of Breadcrumb structs' do |
8 | 8 | expect(links).to be_an Array |
9 | 9 | expect(links.count).to eq 4 |
10 | | - expect(links.first).to be_an OpenStruct |
| 10 | + expect(links.first).to be_a described_class::Breadcrumb |
11 | 11 | end |
12 | 12 |
|
13 | 13 | it 'adds a home link' do |
14 | 14 | expect(links.first.label).to eq 'Home' |
15 | 15 | expect(links.first.href).to eq '/' |
16 | 16 | end |
17 | 17 |
|
18 | | - it 'adds a link to each element' do |
| 18 | + it 'adds a link to all elements except the last one' do |
19 | 19 | expect(links[1].label).to eq 'one' |
20 | 20 | expect(links[1].href).to eq '/one/' |
21 | 21 | expect(links[2].label).to eq 'two' |
22 | 22 | expect(links[2].href).to eq '/one/two/' |
23 | 23 | expect(links[3].label).to eq 'three' |
24 | | - expect(links[3].href).to eq '/one/two/three/' |
25 | | - end |
26 | | - |
27 | | - it 'adds a last attribute to last element' do |
28 | | - expect(links.last.last).to be true |
| 24 | + expect(links[3].href).to be_nil |
29 | 25 | end |
30 | 26 |
|
31 | 27 | context 'with sorted elements' do |
|
37 | 33 | expect(links[2].label).to eq 'two' |
38 | 34 | expect(links[2].href).to eq '/1. one/2. two/' |
39 | 35 | expect(links[3].label).to eq 'three' |
40 | | - expect(links[3].href).to eq '/1. one/2. two/3. three/' |
| 36 | + expect(links[3].href).to be_nil |
41 | 37 | end |
42 | 38 | end |
43 | 39 |
|
|
48 | 44 | it 'prepends the links with the base_uri' do |
49 | 45 | expect(links[1].href).to eq '/docs/one/' |
50 | 46 | expect(links[2].href).to eq '/docs/one/two/' |
51 | | - expect(links[3].href).to eq '/docs/one/two/three/' |
| 47 | + expect(links[3].href).to be_nil |
52 | 48 | end |
53 | 49 | end |
54 | 50 | end |
|
0 commit comments