| @@ -3,7 +3,7 @@ require 'docs' · 2 unmodified lines |
| 3 | 3 | |
| 4 | 4 | class DocsEntryIndexTest < MiniTest::Spec |
| 5 | 5 | let :entry do |
| 6 | | − Docs::Entry.new 'name', 'type', 'path' |
| 6 | + Docs::Entry.new 'name', 'path', 'type' |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | let :index do |
| @@ -29,7 +29,11 @@ class DocsEntryIndexTest < MiniTest::Spec · 19 unmodified lines |
| 29 | 29 | end |
| 30 | 30 | |
| 31 | 31 | it "stores an array of entries" do |
| 32 | | − entries = [entry, entry] |
| 32 | + entries = [ |
| 33 | + Docs::Entry.new('one', 'path', 'type'), |
| 34 | + Docs::Entry.new('two', 'path', 'type') |
| 35 | + ] |
| 36 | + |
| 33 | 37 | index.add(entries) |
| 34 | 38 | assert_equal entries, index.entries |
| 35 | 39 | end |
| @@ -46,11 +50,17 @@ class DocsEntryIndexTest < MiniTest::Spec · 10 unmodified lines |
| 46 | 50 | assert_empty index.types |
| 47 | 51 | end |
| 48 | 52 | |
| 53 | + it "doesn't store the same entry twice" do |
| 54 | + 2.times { index.add(entry.dup) } |
| 55 | + assert_equal [entry], index.entries |
| 56 | + end |
| 57 | + |
| 49 | 58 | it "creates and indexes the type" do |
| 50 | | − entry.type = 'one'; index.add(entry) |
| 51 | | − entry.type = 'two'; 2.times { index.add(entry) } |
| 52 | | − assert_equal ['one', 'two'], index.types.keys |
| 53 | | − assert_instance_of Docs::Type, index.types['one'] |
| 59 | + index.add Docs::Entry.new('one', 'path', 'a') |
| 60 | + index.add Docs::Entry.new('two', 'path', 'b') |
| 61 | + index.add Docs::Entry.new('three', 'path', 'b') |
| 62 | + assert_equal ['a', 'b'], index.types.keys |
| 63 | + assert_instance_of Docs::Type, index.types['a'] |
| 54 | 64 | end |
| 55 | 65 | |
| 56 | 66 | it "doesn't index the nil type" do |
| @@ -59,8 +69,9 @@ class DocsEntryIndexTest < MiniTest::Spec · 2 unmodified lines |
| 59 | 69 | end |
| 60 | 70 | |
| 61 | 71 | it "increments the type's count" do |
| 62 | | − 2.times { index.add(entry) } |
| 63 | | − assert_equal 2, index.types[entry.type].count |
| 72 | + index.add Docs::Entry.new('one', 'path', 'type') |
| 73 | + index.add Docs::Entry.new('two', 'path', 'type') |
| 74 | + assert_equal 2, index.types['type'].count |
| 64 | 75 | end |
| 65 | 76 | end |
| 66 | 77 | |
| @@ -90,8 +101,9 @@ class DocsEntryIndexTest < MiniTest::Spec · 23 unmodified lines |
| 90 | 101 | end |
| 91 | 102 | |
| 92 | 103 | it "includes the json representation of the #entries" do |
| 93 | | − index.add [entry, entry] |
| 94 | | − assert_equal [entry.as_json, entry.as_json], index.as_json[:entries] |
| 104 | + index.add one = Docs::Entry.new('one', 'path', 'type') |
| 105 | + index.add two = Docs::Entry.new('two', 'path', 'type') |
| 106 | + assert_equal [one.as_json, two.as_json], index.as_json[:entries] |
| 95 | 107 | end |
| 96 | 108 | |
| 97 | 109 | it "is sorted by name, case-insensitive" do |