alexandria-book-collection-manager 0.7.8 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +48 -53
  3. data/.rubocop.yml +18 -5
  4. data/.rubocop_todo.yml +31 -37
  5. data/.simplecov +2 -2
  6. data/CHANGELOG.md +37 -0
  7. data/ChangeLog.0 +19 -19
  8. data/INSTALL.md +3 -5
  9. data/README.md +0 -5
  10. data/Rakefile +14 -14
  11. data/alexandria-book-collection-manager.gemspec +35 -34
  12. data/doc/FAQ +2 -2
  13. data/lib/alexandria/about.rb +1 -1
  14. data/lib/alexandria/book_providers/bl_provider.rb +88 -0
  15. data/lib/alexandria/book_providers/loc_provider.rb +38 -0
  16. data/lib/alexandria/book_providers/sbn_provider.rb +108 -0
  17. data/lib/alexandria/book_providers/thalia_provider.rb +1 -1
  18. data/lib/alexandria/book_providers/web.rb +2 -2
  19. data/lib/alexandria/book_providers/worldcat.rb +9 -7
  20. data/lib/alexandria/book_providers/z3950_provider.rb +199 -0
  21. data/lib/alexandria/book_providers.rb +10 -25
  22. data/lib/alexandria/console.rb +2 -2
  23. data/lib/alexandria/default_preferences.rb +1 -1
  24. data/lib/alexandria/export_library.rb +14 -14
  25. data/lib/alexandria/image_fetcher.rb +25 -0
  26. data/lib/alexandria/import_library.rb +10 -10
  27. data/lib/alexandria/library_store.rb +4 -5
  28. data/lib/alexandria/models/book.rb +13 -0
  29. data/lib/alexandria/models/library.rb +15 -23
  30. data/lib/alexandria/preferences.rb +4 -6
  31. data/lib/alexandria/{book_providers/pseudomarc.rb → pseudo_marc_parser.rb} +2 -2
  32. data/lib/alexandria/scanners/cue_cat.rb +1 -1
  33. data/lib/alexandria/smart_library.rb +2 -2
  34. data/lib/alexandria/ui/about_dialog.rb +1 -1
  35. data/lib/alexandria/ui/acquire_dialog.rb +6 -9
  36. data/lib/alexandria/ui/alert_dialog.rb +2 -2
  37. data/lib/alexandria/ui/barcode_animation.rb +1 -1
  38. data/lib/alexandria/ui/book_properties_dialog_base.rb +5 -9
  39. data/lib/alexandria/ui/completion_models.rb +1 -5
  40. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
  41. data/lib/alexandria/ui/icons.rb +2 -2
  42. data/lib/alexandria/ui/init.rb +10 -4
  43. data/lib/alexandria/ui/listview.rb +1 -1
  44. data/lib/alexandria/ui/multi_drag_treeview.rb +1 -1
  45. data/lib/alexandria/ui/new_book_dialog.rb +11 -13
  46. data/lib/alexandria/ui/new_book_dialog_manual.rb +1 -1
  47. data/lib/alexandria/ui/preferences_dialog.rb +2 -2
  48. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +1 -1
  49. data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
  50. data/lib/alexandria/ui/ui_manager.rb +17 -25
  51. data/lib/alexandria/version.rb +1 -1
  52. data/lib/alexandria/web_themes.rb +1 -1
  53. data/lib/alexandria.rb +6 -5
  54. data/po/cs.po +90 -125
  55. data/po/cy.po +87 -125
  56. data/po/de.po +96 -125
  57. data/po/el.po +96 -125
  58. data/po/es.po +96 -125
  59. data/po/fr.po +90 -125
  60. data/po/ga.po +83 -124
  61. data/po/gl.po +90 -125
  62. data/po/it.po +90 -125
  63. data/po/ja.po +90 -125
  64. data/po/mk.po +96 -125
  65. data/po/nb.po +90 -125
  66. data/po/nl.po +107 -124
  67. data/po/pl.po +113 -124
  68. data/po/pt.po +90 -125
  69. data/po/pt_BR.po +90 -125
  70. data/po/ru.po +92 -124
  71. data/po/sk.po +90 -125
  72. data/po/sv.po +90 -125
  73. data/po/uk.po +90 -125
  74. data/po/zh_TW.po +90 -125
  75. data/schemas/alexandria.schemas +1 -1
  76. data/share/gnome/help/alexandria/C/adding-books.xml +3 -4
  77. data/share/gnome/help/alexandria/C/introduction.xml +0 -16
  78. data/share/gnome/help/alexandria/C/searching.xml +1 -4
  79. data/share/gnome/help/alexandria/C/settings.xml +0 -30
  80. data/share/gnome/help/alexandria/fr/alexandria.xml +4 -159
  81. data/share/gnome/help/alexandria/ja/adding-books.xml +1 -1
  82. data/share/gnome/help/alexandria/ja/introduction.xml +0 -15
  83. data/share/gnome/help/alexandria/ja/searching.xml +3 -7
  84. data/share/gnome/help/alexandria/ja/settings.xml +0 -27
  85. data/spec/alexandria/book_providers/bl_provider_spec.rb +13 -0
  86. data/spec/alexandria/book_providers/loc_provider_spec.rb +17 -0
  87. data/spec/alexandria/book_providers/sbn_provider_spec.rb +13 -0
  88. data/spec/alexandria/book_providers/thalia_provider_spec.rb +1 -1
  89. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +22 -10
  90. data/spec/alexandria/book_providers_spec.rb +0 -81
  91. data/spec/alexandria/book_spec.rb +5 -3
  92. data/spec/alexandria/export_library_spec.rb +8 -8
  93. data/spec/alexandria/library_spec.rb +83 -51
  94. data/spec/alexandria/library_store_spec.rb +1 -1
  95. data/spec/alexandria/preferences_spec.rb +7 -7
  96. data/spec/alexandria/pseudo_marc_parser_spec.rb +71 -0
  97. data/spec/alexandria/scanners/cue_cat_spec.rb +11 -4
  98. data/spec/alexandria/smart_library_spec.rb +7 -5
  99. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  100. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  101. data/spec/alexandria/ui/alert_dialog_spec.rb +5 -3
  102. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  103. data/spec/alexandria/ui/book_properties_dialog_spec.rb +4 -4
  104. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +18 -2
  105. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  106. data/spec/alexandria/ui/error_dialog_spec.rb +13 -2
  107. data/spec/alexandria/ui/export_dialog_spec.rb +3 -3
  108. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  109. data/spec/alexandria/ui/import_dialog_spec.rb +3 -3
  110. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  111. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +4 -4
  112. data/spec/alexandria/ui/new_book_dialog_spec.rb +2 -2
  113. data/spec/alexandria/ui/new_provider_dialog_spec.rb +3 -3
  114. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +9 -7
  115. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  116. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +2 -2
  117. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  118. data/spec/alexandria/ui/sidepane_manager_spec.rb +1 -1
  119. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +18 -2
  120. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +2 -2
  121. data/spec/alexandria/ui/ui_manager_spec.rb +83 -5
  122. data/spec/data/libraries/0.6.2/My Library/9780571147168.yaml +2 -0
  123. data/spec/spec_helper.rb +23 -32
  124. data/util/rake/fileinstall.rb +12 -12
  125. data/util/rake/gettextgenerate.rb +1 -1
  126. data/util/rake/omfgenerate.rb +1 -1
  127. metadata +73 -58
  128. data/lib/alexandria/book_providers/adlibris.rb +0 -191
  129. data/lib/alexandria/book_providers/amazon_aws.rb +0 -239
  130. data/lib/alexandria/book_providers/amazon_ecs_util.rb +0 -373
  131. data/lib/alexandria/book_providers/barnes_and_noble.rb +0 -209
  132. data/lib/alexandria/book_providers/proxis.rb +0 -176
  133. data/lib/alexandria/book_providers/siciliano.rb +0 -256
  134. data/lib/alexandria/book_providers/z3950.rb +0 -408
@@ -12,62 +12,71 @@ describe Alexandria::Library do
12
12
  describe "::EXT" do
13
13
  it "has symbolic references to file extensions" do
14
14
  extensions = Alexandria::Library::EXT
15
- expect(extensions[:book]).not_to be_nil
16
- expect(extensions[:cover]).not_to be_nil
15
+ aggregate_failures do
16
+ expect(extensions[:book]).not_to be_nil
17
+ expect(extensions[:cover]).not_to be_nil
18
+ end
17
19
  end
18
20
  end
19
21
 
20
22
  describe "#valid_isbn?" do
21
23
  it "returns a true value for valid isbns" do
22
24
  ["014143984X", "0-345-43192-8"].each do |x|
23
- expect(described_class.valid_isbn?(x)).to be_truthy
25
+ expect(described_class.valid_isbn?(x)).to be true
24
26
  end
25
27
  end
26
28
  end
27
29
 
28
30
  describe "#valid_ean?" do
29
31
  it "returns a true value for valid EANs" do
30
- expect(described_class.valid_ean?("9780345431929")).to be_truthy
31
- expect(described_class.valid_ean?("978034543192912345")).to be_truthy
32
+ aggregate_failures do
33
+ expect(described_class.valid_ean?("9780345431929")).to be true
34
+ expect(described_class.valid_ean?("978034543192912345")).to be true
32
35
 
33
- # Regression test: this EAN has a checksum of 10, which should be
34
- # treated like a checksum of 0.
35
- expect(described_class.valid_ean?("9784047041790")).to be_truthy
36
+ # Regression test: this EAN has a checksum of 10, which should be
37
+ # treated like a checksum of 0.
38
+ expect(described_class.valid_ean?("9784047041790")).to be true
39
+ end
36
40
  end
37
41
 
38
42
  it "returns a false value for invalid EANs" do
39
- expect(described_class.valid_ean?("780345431929")).to be_falsey
40
- expect(described_class.valid_ean?("97803454319290")).to be_falsey
41
- expect(described_class.valid_ean?("97803454319291234")).to be_falsey
42
- expect(described_class.valid_ean?("9780345431929123456")).to be_falsey
43
- expect(described_class.valid_ean?("9780345431928")).to be_falsey
44
- expect(described_class.valid_ean?("9780345431929A")).to be_falsey
43
+ invalid_eans = ["780345431929", "97803454319290", "97803454319291234",
44
+ "9780345431929123456", "9780345431928", "9780345431929A",
45
+ "9784047041791"]
45
46
 
46
- expect(described_class.valid_ean?("9784047041791")).to be_falsey
47
+ aggregate_failures do
48
+ invalid_eans.each do |ean|
49
+ expect(described_class.valid_ean?(ean)).to be false
50
+ end
51
+ end
47
52
  end
48
53
  end
49
54
 
50
55
  describe "#valid_upc?" do
51
56
  it "returns a true value for valid UPCs" do
52
- expect(described_class.valid_upc?("97803454319312356")).to be_truthy
57
+ expect(described_class.valid_upc?("97803454319312356")).to be true
53
58
  end
54
59
 
55
60
  it "returns a false value for invalid UPCs" do
56
- expect(described_class.valid_upc?("978034543193123567")).to be_falsey
57
- expect(described_class.valid_upc?("9780345431931235")).to be_falsey
61
+ aggregate_failures do
62
+ expect(described_class.valid_upc?("978034543193123567")).to be false
63
+ expect(described_class.valid_upc?("9780345431931235")).to be false
58
64
 
59
- expect(described_class.valid_upc?("97803454319412356")).to be_falsey
60
- expect(described_class.valid_upc?("97803454319212356")).to be_falsey
65
+ expect(described_class.valid_upc?("97803454319412356")).to be false
66
+ expect(described_class.valid_upc?("97803454319212356")).to be false
67
+ end
61
68
  end
62
69
  end
63
70
 
64
71
  describe "#canonicalise_isbn" do
65
72
  it "returns the correct value for several examples" do
66
- expect(described_class.canonicalise_isbn("014143984X")).to eq "014143984X"
67
- expect(described_class.canonicalise_isbn("0-345-43192-8")).to eq "0345431928"
68
- expect(described_class.canonicalise_isbn("3522105907")).to eq "3522105907"
69
- # EAN number
70
- expect(described_class.canonicalise_isbn("9780345431929")).to eq "0345431928"
73
+ aggregate_failures do
74
+ expect(described_class.canonicalise_isbn("014143984X")).to eq "014143984X"
75
+ expect(described_class.canonicalise_isbn("0-345-43192-8")).to eq "0345431928"
76
+ expect(described_class.canonicalise_isbn("3522105907")).to eq "3522105907"
77
+ # EAN number
78
+ expect(described_class.canonicalise_isbn("9780345431929")).to eq "0345431928"
79
+ end
71
80
  end
72
81
  end
73
82
 
@@ -75,7 +84,7 @@ describe Alexandria::Library do
75
84
  let(:my_library) { loader.load_library("Empty") }
76
85
 
77
86
  before do
78
- FileUtils.mkdir(TESTDIR) unless File.exist? TESTDIR
87
+ FileUtils.mkdir_p(TESTDIR)
79
88
  end
80
89
 
81
90
  it "disallows multiple deletion of the same copy of a book" do
@@ -136,21 +145,27 @@ describe Alexandria::Library do
136
145
  end
137
146
 
138
147
  it "can be loaded" do
139
- expect(libs.size).to eq(1)
140
- expect(my_library.size).to eq(3)
148
+ aggregate_failures do
149
+ expect(libs.size).to eq(1)
150
+ expect(my_library.size).to eq(3)
151
+ end
141
152
  end
142
153
 
143
- it "imports cleanly from version 0.6.1 data format" do
144
- # Malory
154
+ it "imports Malory book cleanly from version 0.6.1 data format" do
145
155
  malory_book = my_library.find { |b| b.isbn == "9780192812179" }
146
- expect(malory_book.publisher).to eq("Oxford University Press")
147
- expect(malory_book.authors.include?("Vinaver")).to be_truthy
148
- expect(malory_book.version).to eq(Alexandria::DATA_VERSION)
156
+ aggregate_failures do
157
+ expect(malory_book.publisher).to eq("Oxford University Press")
158
+ expect(malory_book.authors).to include "Vinaver"
159
+ expect(malory_book.version).to eq(Alexandria::DATA_VERSION)
160
+ end
161
+ end
149
162
 
150
- # Guide to LaTeX
163
+ it "imports Guide to LaTeX cleanly from version 0.6.1 data format" do
151
164
  latex_book = my_library.find { |b| b.title.include? "Latex" }
152
- expect(latex_book.isbn).to eq("9780201398250")
153
- expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
165
+ aggregate_failures do
166
+ expect(latex_book.isbn).to eq("9780201398250")
167
+ expect(latex_book.publisher).to eq("Addison Wesley")
168
+ end
154
169
  end
155
170
  end
156
171
 
@@ -168,16 +183,20 @@ describe Alexandria::Library do
168
183
  end
169
184
 
170
185
  it "can be loaded" do
171
- expect(libs.size).to eq(1)
172
- expect(my_library.size).to eq(2)
186
+ aggregate_failures do
187
+ expect(libs.size).to eq(1)
188
+ expect(my_library.size).to eq(2)
189
+ end
173
190
  end
174
191
 
175
192
  it "loads a book with ISBN" do
176
193
  # Guide to LaTeX
177
194
  latex_book = my_library.find { |b| b.title.include? "Latex" }
178
- expect(latex_book.isbn).to eq("9780201398250")
179
- expect(latex_book.publisher).to eq("Addison Wesley") # note, no Ruby-Amazon cruft
180
- expect(latex_book.version).to eq(Alexandria::DATA_VERSION)
195
+ aggregate_failures do
196
+ expect(latex_book.isbn).to eq("9780201398250")
197
+ expect(latex_book.publisher).to eq("Addison Wesley")
198
+ expect(latex_book.version).to eq(Alexandria::DATA_VERSION)
199
+ end
181
200
  end
182
201
 
183
202
  it "loads a book without ISBN" do
@@ -189,13 +208,8 @@ describe Alexandria::Library do
189
208
  it "saves loaded books properly" do
190
209
  my_library.each { |book| my_library.save(book, true) }
191
210
  my_library_reloaded = loader.load_all_libraries[0]
192
- expect(my_library_reloaded.size).to eq(2)
193
211
 
194
- latex_book = my_library_reloaded.find { |b| b.title.include? "Latex" }
195
- expect(latex_book.publisher).to eq("Addison Wesley")
196
-
197
- lex_and_yacc_book = my_library_reloaded.find { |b| b.title.include? "Lex" }
198
- expect(lex_and_yacc_book.publisher).to eq("O'Reilley")
212
+ expect(my_library_reloaded.map(&:publisher)).to eq ["O'Reilley", "Addison Wesley"]
199
213
  end
200
214
  end
201
215
 
@@ -224,11 +238,29 @@ describe Alexandria::Library do
224
238
  described_class.move(source, target, book)
225
239
 
226
240
  aggregate_failures do
227
- expect(File.exist?(source.yaml(book))).to be_falsey
228
- expect(File.exist?(source.cover(book))).to be_falsey
229
- expect(File.exist?(target.yaml(book))).to be_truthy
230
- expect(File.exist?(target.cover(book))).to be_truthy
241
+ expect(source.yaml(book)).not_to be_an_existing_file
242
+ expect(source.cover(book)).not_to be_an_existing_file
243
+ expect(target.yaml(book)).to be_an_existing_file
244
+ expect(target.cover(book)).to be_an_existing_file
231
245
  end
232
246
  end
233
247
  end
248
+
249
+ describe "#name=" do
250
+ let(:my_library) { loader.load_library("Empty") }
251
+
252
+ before do
253
+ FileUtils.mkdir_p(TESTDIR)
254
+ end
255
+
256
+ it "changes the library's name" do
257
+ my_library.name = "Really Empty"
258
+ expect(my_library.name).to eq "Really Empty"
259
+ end
260
+
261
+ it "moves the library's directory" do
262
+ my_library.name = "Really Empty"
263
+ expect(File.join(TESTDIR, "Really Empty")).to be_an_existing_file
264
+ end
265
+ end
234
266
  end
@@ -16,7 +16,7 @@ RSpec.describe Alexandria::LibraryStore do
16
16
  aggregate_failures do
17
17
  expect(smart_libs.size).to eq 5
18
18
  smart_libs.each do |lib|
19
- expect(File.exist?(lib.yaml)).to be_truthy
19
+ expect(lib.yaml).to be_an_existing_file
20
20
  end
21
21
  end
22
22
  end
@@ -11,17 +11,17 @@ describe Alexandria::Preferences do
11
11
 
12
12
  describe "#get_variable" do
13
13
  it "returns nil fetching unknown setting" do
14
- expect(instance.get_variable("does_not_exist")).to eq nil
14
+ expect(instance.get_variable("does_not_exist")).to be_nil
15
15
  end
16
16
 
17
17
  it "allows fetching by string" do
18
18
  instance.toolbar_visible = false
19
- expect(instance.get_variable("toolbar_visible")).to eq false
19
+ expect(instance.get_variable("toolbar_visible")).to be false
20
20
  end
21
21
 
22
22
  it "allows fetching by symbol" do
23
23
  instance.toolbar_visible = true
24
- expect(instance.get_variable(:toolbar_visible)).to eq true
24
+ expect(instance.get_variable(:toolbar_visible)).to be true
25
25
  end
26
26
  end
27
27
 
@@ -29,23 +29,23 @@ describe Alexandria::Preferences do
29
29
  it "allows setting by string" do
30
30
  instance.toolbar_visible = false
31
31
  instance.set_variable("toolbar_visible", true)
32
- expect(instance.toolbar_visible).to eq true
32
+ expect(instance.toolbar_visible).to be true
33
33
  end
34
34
 
35
35
  it "allows setting by symbol" do
36
36
  instance.toolbar_visible = false
37
37
  instance.set_variable(:toolbar_visible, true)
38
- expect(instance.toolbar_visible).to eq true
38
+ expect(instance.toolbar_visible).to be true
39
39
  end
40
40
  end
41
41
 
42
42
  it "allows setting known setting to false" do
43
43
  instance.toolbar_visible = false
44
- expect(instance.toolbar_visible).to eq false
44
+ expect(instance.toolbar_visible).to be false
45
45
  end
46
46
 
47
47
  it "resets known setting by setting to nil" do
48
48
  instance.toolbar_visible = nil
49
- expect(instance.toolbar_visible).to eq true
49
+ expect(instance.toolbar_visible).to be true
50
50
  end
51
51
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2022 Matijs van Zuijlen
4
+ #
5
+ # Alexandria is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU General Public License as
7
+ # published by the Free Software Foundation; either version 2 of the
8
+ # License, or (at your option) any later version.
9
+ #
10
+ # Alexandria is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public
16
+ # License along with Alexandria; see the file COPYING. If not,
17
+ # write to the Free Software Foundation, Inc., 51 Franklin Street,
18
+ # Fifth Floor, Boston, MA 02110-1301 USA.
19
+
20
+ require "spec_helper"
21
+
22
+ RSpec.describe Alexandria::PseudoMarcParser do
23
+ describe ".marc_text_to_book" do
24
+ let(:marc_text) do
25
+ <<~MARC
26
+ 00991pam 2200289 a 4500
27
+ 001 426456
28
+ 005 19820209000000.0
29
+ 008 811005s1981 maua b 001 0 eng#{' '}
30
+ 035 $9 (DLC) 81017108
31
+ 906 $a 7 $b cbc $c orignew $d 1 $e ocip $f 19 $g y-gencatlg
32
+ 010 $a 81017108#{' '}
33
+ 020 $a 0805335587
34
+ 020 $a 0805335579 (pbk.)
35
+ 040 $a DLC $c DLC $d DLC
36
+ 050 00 $a QA612 $b .G7
37
+ 082 00 $a 514/.2 $2 19
38
+ 100 1 $a Greenberg, Marvin J.
39
+ 245 10 $a Algebraic topology : $b a first course / $c Marvin J. Greenberg, John R. Harper.
40
+ 260 $a Reading, Mass. : $b Benjamin/Cummings Pub. Co., $c 1981.
41
+ 300 $a xi, 311 p. : $b ill. ; $c 24 cm.
42
+ 440 0 $a Mathematics lecture note series ; $v 58
43
+ 500 $a "A revision of the first author's Lectures on algebraic topology"--P.
44
+ 504 $a Bibliography: p. 303-307.
45
+ 500 $a Includes index.
46
+ 650 0 $a Algebraic topology.
47
+ 700 1 $a Harper, John R., $d 1941-
48
+ 991 $b c-GenColl $h QA612 $i .G7 $p 00035736761 $t Copy 1 $w BOOKS
49
+ MARC
50
+ end
51
+
52
+ it "returns a book with the correct attributes" do
53
+ result = described_class.marc_text_to_book(marc_text,
54
+ described_class::USMARC_MAPPINGS)
55
+ aggregate_failures do
56
+ expect(result.title).to eq "Algebraic topology: a first course"
57
+ expect(result.authors).to eq ["Greenberg, Marvin J."]
58
+ end
59
+ end
60
+
61
+ it "returns nil when passed a blank string" do
62
+ result = described_class.marc_text_to_book("", described_class::USMARC_MAPPINGS)
63
+ expect(result).to be_nil
64
+ end
65
+
66
+ it "returns nil when passed nil" do
67
+ result = described_class.marc_text_to_book(nil, described_class::USMARC_MAPPINGS)
68
+ expect(result).to be_nil
69
+ end
70
+ end
71
+ end
@@ -27,10 +27,17 @@ describe Alexandria::Scanners::CueCat do
27
27
  expect(cuecat.name).to match(/CueCat/i)
28
28
  end
29
29
 
30
- it "detects a complete scan only" do
31
- partials.each { |scan| expect(cuecat.match?(scan)).not_to be_truthy }
32
- expect(cuecat.match?(scans[:isbn])).to be_truthy
33
- expect(cuecat.match?(scans[:ib5])).to be_truthy
30
+ it "refuses to detect incomplete scans" do
31
+ aggregate_failures do
32
+ partials.each { |scan| expect(cuecat.match?(scan)).to be false }
33
+ end
34
+ end
35
+
36
+ it "detects complete scans" do
37
+ aggregate_failures do
38
+ expect(cuecat.match?(scans[:isbn])).to be true
39
+ expect(cuecat.match?(scans[:ib5])).to be true
40
+ end
34
41
  end
35
42
 
36
43
  it "decodes ISBN barcodes" do
@@ -16,8 +16,10 @@ RSpec.describe Alexandria::SmartLibrary do
16
16
  it "normalizes the encoding" do
17
17
  bad_name = (+"Prêts").force_encoding("ascii")
18
18
  lib = described_class.new(bad_name, [], :all)
19
- expect(lib.name.encoding.name).to eq "UTF-8"
20
- expect(bad_name.encoding.name).to eq "US-ASCII"
19
+ aggregate_failures do
20
+ expect(lib.name.encoding.name).to eq "UTF-8"
21
+ expect(bad_name.encoding.name).to eq "US-ASCII"
22
+ end
21
23
  end
22
24
  end
23
25
 
@@ -25,15 +27,15 @@ RSpec.describe Alexandria::SmartLibrary do
25
27
  let(:lib) { described_class.new("Hello", [], :all) }
26
28
 
27
29
  it "works when given no parameters" do
28
- lib.update
30
+ expect { lib.update }.not_to raise_error
29
31
  end
30
32
 
31
33
  it "works when given a LibraryCollection" do
32
- lib.update Alexandria::LibraryCollection.instance
34
+ expect { lib.update Alexandria::LibraryCollection.instance }.not_to raise_error
33
35
  end
34
36
 
35
37
  it "works when given a Library" do
36
- lib.update Alexandria::Library.new("Hi")
38
+ expect { lib.update Alexandria::Library.new("Hi") }.not_to raise_error
37
39
  end
38
40
  end
39
41
  end
@@ -9,6 +9,6 @@ require_relative "../../spec_helper"
9
9
  describe Alexandria::UI::AboutDialog do
10
10
  it "works" do
11
11
  parent = Gtk::Window.new :toplevel
12
- described_class.new parent
12
+ expect { described_class.new parent }.not_to raise_error
13
13
  end
14
14
  end
@@ -9,6 +9,6 @@ require_relative "../../spec_helper"
9
9
  describe Alexandria::UI::AcquireDialog do
10
10
  it "works" do
11
11
  parent = Gtk::Window.new :toplevel
12
- described_class.new parent
12
+ expect { described_class.new parent }.not_to raise_error
13
13
  end
14
14
  end
@@ -9,8 +9,10 @@ require_relative "../../spec_helper"
9
9
  describe Alexandria::UI::AlertDialog do
10
10
  it "works" do
11
11
  parent = Gtk::Window.new :toplevel
12
- described_class.new(parent, "Hello",
13
- Gtk::Stock::DIALOG_QUESTION,
14
- [[Gtk::Stock::CANCEL, :cancel]], "Hi there")
12
+ expect do
13
+ described_class.new(parent, "Hello",
14
+ Gtk::Stock::DIALOG_QUESTION,
15
+ [[Gtk::Stock::CANCEL, :cancel]], "Hi there")
16
+ end.not_to raise_error
15
17
  end
16
18
  end
@@ -9,6 +9,6 @@ require_relative "../../spec_helper"
9
9
  describe Alexandria::UI::BadIsbnsDialog do
10
10
  it "works" do
11
11
  parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "Careful", []
12
+ expect { described_class.new parent, "Careful", [] }.not_to raise_error
13
13
  end
14
14
  end
@@ -22,7 +22,7 @@ describe Alexandria::UI::BookPropertiesDialog do
22
22
  end
23
23
 
24
24
  it "works" do
25
- described_class.new parent, library, book
25
+ expect { described_class.new parent, library, book }.not_to raise_error
26
26
  end
27
27
 
28
28
  describe "#on_change_cover" do
@@ -39,21 +39,21 @@ describe Alexandria::UI::BookPropertiesDialog do
39
39
  allow(filechooser)
40
40
  .to receive(:run).and_return(Gtk::ResponseType::ACCEPT)
41
41
 
42
- dialog.on_change_cover
42
+ expect { dialog.on_change_cover }.not_to raise_error
43
43
  end
44
44
 
45
45
  it "works when response is reject" do
46
46
  allow(filechooser)
47
47
  .to receive(:run).and_return(Gtk::ResponseType::REJECT)
48
48
 
49
- dialog.on_change_cover
49
+ expect { dialog.on_change_cover }.not_to raise_error
50
50
  end
51
51
 
52
52
  it "works when response is cancel" do
53
53
  allow(filechooser)
54
54
  .to receive(:run).and_return(Gtk::ResponseType::CANCEL)
55
55
 
56
- dialog.on_change_cover
56
+ expect { dialog.on_change_cover }.not_to raise_error
57
57
  end
58
58
  end
59
59
  end
@@ -7,8 +7,24 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ConfirmEraseDialog do
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
10
12
  it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "foo-file"
13
+ expect { described_class.new parent, "foo-file" }.not_to raise_error
14
+ end
15
+
16
+ describe "erase?" do
17
+ let(:instance) { described_class.new parent, "foo-file" }
18
+ let(:dialog) { instance.dialog }
19
+
20
+ it "returns false when response is cancel" do
21
+ allow(dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
22
+ expect(instance.erase?).to be false
23
+ end
24
+
25
+ it "returns true when response is OK" do
26
+ allow(dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
27
+ expect(instance.erase?).to be true
28
+ end
13
29
  end
14
30
  end
@@ -11,6 +11,6 @@ describe Alexandria::UI::ConflictWhileCopyingDialog do
11
11
  parent = Gtk::Window.new :toplevel
12
12
  library = instance_double(Alexandria::Library, name: "Bar Library")
13
13
  book = instance_double(Alexandria::Book, title: "Foo Book")
14
- described_class.new parent, library, book
14
+ expect { described_class.new parent, library, book }.not_to raise_error
15
15
  end
16
16
  end
@@ -7,8 +7,19 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ErrorDialog do
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
10
12
  it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "Boom", "It went boom"
13
+ expect { described_class.new parent, "Boom", "It went boom" }.not_to raise_error
14
+ end
15
+
16
+ describe "display" do
17
+ let(:instance) { described_class.new parent, "Boom", "It went boom" }
18
+ let(:dialog) { instance.dialog }
19
+
20
+ it "works when response is OK" do
21
+ allow(dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
22
+ expect { instance.display }.not_to raise_error
23
+ end
13
24
  end
14
25
  end
@@ -12,7 +12,7 @@ describe Alexandria::UI::ExportDialog do
12
12
  let(:sort_order) { Alexandria::LibrarySortOrder::Unsorted.new }
13
13
 
14
14
  it "works" do
15
- described_class.new parent, library, sort_order
15
+ expect { described_class.new parent, library, sort_order }.not_to raise_error
16
16
  end
17
17
 
18
18
  describe "#perform" do
@@ -21,14 +21,14 @@ describe Alexandria::UI::ExportDialog do
21
21
 
22
22
  it "works when response is cancel" do
23
23
  allow(chooser).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
24
- export_dialog.perform
24
+ expect { export_dialog.perform }.not_to raise_error
25
25
  end
26
26
 
27
27
  it "works when response is OK" do
28
28
  dir = Dir.mktmpdir
29
29
  allow(chooser).to receive(:run).and_return(Gtk::ResponseType::OK)
30
30
  allow(chooser).to receive(:filename).and_return File.join(dir, "export")
31
- export_dialog.perform
31
+ expect { export_dialog.perform }.not_to raise_error
32
32
  ensure
33
33
  FileUtils.remove_entry dir
34
34
  end
@@ -10,6 +10,6 @@ describe Alexandria::UI::IconViewManager do
10
10
  it "works" do
11
11
  iconview = instance_double(Gtk::IconView).as_null_object
12
12
  parent = instance_double(Alexandria::UI::UIManager, iconview: iconview).as_null_object
13
- described_class.new iconview, parent
13
+ expect { described_class.new iconview, parent }.not_to raise_error
14
14
  end
15
15
  end
@@ -10,12 +10,12 @@ describe Alexandria::UI::ImportDialog do
10
10
  let(:parent) { Gtk::Window.new :toplevel }
11
11
 
12
12
  it "can be instantiated" do
13
- described_class.new parent
13
+ expect { described_class.new parent }.not_to raise_error
14
14
  end
15
15
 
16
16
  it "handles a selection change" do
17
17
  importdialog = described_class.new parent
18
- importdialog.dialog.signal_emit "selection_changed"
18
+ expect { importdialog.dialog.signal_emit "selection_changed" }.not_to raise_error
19
19
  end
20
20
 
21
21
  describe "#acquire" do
@@ -32,7 +32,7 @@ describe Alexandria::UI::ImportDialog do
32
32
 
33
33
  it "works when response is cancel" do
34
34
  allow(chooser).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
35
- import_dialog.acquire {}
35
+ expect { import_dialog.acquire { nil } }.not_to raise_error
36
36
  end
37
37
 
38
38
  it "works when response is OK" do
@@ -12,6 +12,6 @@ describe Alexandria::UI::KeepBadISBNDialog do
12
12
  book = instance_double(Alexandria::Book,
13
13
  title: "Foo Book",
14
14
  isbn: "98765432")
15
- described_class.new parent, book
15
+ expect { described_class.new parent, book }.not_to raise_error
16
16
  end
17
17
  end
@@ -14,7 +14,7 @@ describe Alexandria::UI::NewBookDialogManual do
14
14
  end
15
15
 
16
16
  it "works" do
17
- described_class.new parent, library
17
+ expect { described_class.new parent, library }.not_to raise_error
18
18
  end
19
19
 
20
20
  describe "#on_change_cover" do
@@ -31,21 +31,21 @@ describe Alexandria::UI::NewBookDialogManual do
31
31
  allow(filechooser)
32
32
  .to receive(:run).and_return(Gtk::ResponseType::ACCEPT)
33
33
 
34
- dialog.on_change_cover
34
+ expect { dialog.on_change_cover }.not_to raise_error
35
35
  end
36
36
 
37
37
  it "works when response is reject" do
38
38
  allow(filechooser)
39
39
  .to receive(:run).and_return(Gtk::ResponseType::REJECT)
40
40
 
41
- dialog.on_change_cover
41
+ expect { dialog.on_change_cover }.not_to raise_error
42
42
  end
43
43
 
44
44
  it "works when response is cancel" do
45
45
  allow(filechooser)
46
46
  .to receive(:run).and_return(Gtk::ResponseType::CANCEL)
47
47
 
48
- dialog.on_change_cover
48
+ expect { dialog.on_change_cover }.not_to raise_error
49
49
  end
50
50
  end
51
51
  end
@@ -11,12 +11,12 @@ describe Alexandria::UI::NewBookDialog do
11
11
  let(:model) { Gtk::ListStore.new(String, String, GdkPixbuf::Pixbuf) }
12
12
 
13
13
  it "works" do
14
- described_class.new parent
14
+ expect { described_class.new parent }.not_to raise_error
15
15
  end
16
16
 
17
17
  it "can copy search results into result treeview" do
18
18
  results = [[an_artist_of_the_floating_world, "cover-url"]]
19
19
  dialog = described_class.new parent
20
- dialog.copy_results_to_treeview_model results, model
20
+ expect { dialog.copy_results_to_treeview_model results, model }.not_to raise_error
21
21
  end
22
22
  end