alexandria-book-collection-manager 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +6 -6
  3. data/.rubocop_todo.yml +13 -26
  4. data/.simplecov +2 -2
  5. data/CHANGELOG.md +8 -0
  6. data/Rakefile +3 -3
  7. data/alexandria-book-collection-manager.gemspec +18 -18
  8. data/lib/alexandria/book_providers/z3950_provider.rb +1 -1
  9. data/lib/alexandria/console.rb +2 -2
  10. data/lib/alexandria/export_library.rb +4 -4
  11. data/lib/alexandria/import_library.rb +1 -1
  12. data/lib/alexandria/library_store.rb +1 -1
  13. data/lib/alexandria/models/library.rb +2 -2
  14. data/lib/alexandria/{book_providers/pseudomarc.rb → pseudo_marc_parser.rb} +1 -1
  15. data/lib/alexandria/smart_library.rb +2 -2
  16. data/lib/alexandria/ui/alert_dialog.rb +2 -2
  17. data/lib/alexandria/ui/book_properties_dialog_base.rb +3 -3
  18. data/lib/alexandria/ui/icons.rb +2 -2
  19. data/lib/alexandria/ui/init.rb +10 -4
  20. data/lib/alexandria/ui/ui_manager.rb +4 -4
  21. data/lib/alexandria/version.rb +1 -1
  22. data/lib/alexandria/web_themes.rb +1 -1
  23. data/lib/alexandria.rb +6 -5
  24. data/spec/alexandria/book_providers/bl_provider_spec.rb +1 -1
  25. data/spec/alexandria/book_providers/loc_provider_spec.rb +2 -2
  26. data/spec/alexandria/book_providers/sbn_provider_spec.rb +1 -1
  27. data/spec/alexandria/book_providers/thalia_provider_spec.rb +1 -1
  28. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +22 -10
  29. data/spec/alexandria/book_spec.rb +5 -3
  30. data/spec/alexandria/export_library_spec.rb +8 -8
  31. data/spec/alexandria/library_spec.rb +67 -53
  32. data/spec/alexandria/library_store_spec.rb +1 -1
  33. data/spec/alexandria/preferences_spec.rb +7 -7
  34. data/spec/alexandria/pseudo_marc_parser_spec.rb +71 -0
  35. data/spec/alexandria/scanners/cue_cat_spec.rb +11 -4
  36. data/spec/alexandria/smart_library_spec.rb +7 -5
  37. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  38. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  39. data/spec/alexandria/ui/alert_dialog_spec.rb +5 -3
  40. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  41. data/spec/alexandria/ui/book_properties_dialog_spec.rb +4 -4
  42. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +18 -2
  43. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  44. data/spec/alexandria/ui/error_dialog_spec.rb +13 -2
  45. data/spec/alexandria/ui/export_dialog_spec.rb +3 -3
  46. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  47. data/spec/alexandria/ui/import_dialog_spec.rb +3 -3
  48. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  49. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +4 -4
  50. data/spec/alexandria/ui/new_book_dialog_spec.rb +2 -2
  51. data/spec/alexandria/ui/new_provider_dialog_spec.rb +3 -3
  52. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +9 -7
  53. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  54. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +2 -2
  55. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  56. data/spec/alexandria/ui/sidepane_manager_spec.rb +1 -1
  57. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +18 -2
  58. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +2 -2
  59. data/spec/alexandria/ui/ui_manager_spec.rb +5 -3
  60. data/spec/spec_helper.rb +23 -32
  61. data/util/rake/fileinstall.rb +8 -8
  62. data/util/rake/gettextgenerate.rb +1 -1
  63. metadata +15 -14
@@ -24,7 +24,7 @@ RSpec.describe Alexandria::ExportLibrary do
24
24
  end
25
25
 
26
26
  after do
27
- FileUtils.rm_rf(outfile) if File.exist? outfile
27
+ FileUtils.rm_rf(outfile)
28
28
  end
29
29
 
30
30
  describe "#export_as_csv_list" do
@@ -59,8 +59,8 @@ RSpec.describe Alexandria::ExportLibrary do
59
59
  index = File.join(outfile, "index.html")
60
60
 
61
61
  aggregate_failures do
62
- expect(File.exist?(outfile)).to be_truthy
63
- expect(File.exist?(index)).to be_truthy
62
+ expect(outfile).to be_an_existing_file
63
+ expect(index).to be_an_existing_file
64
64
  expect(File.size(index)).to be_nonzero
65
65
  end
66
66
  end
@@ -72,7 +72,7 @@ RSpec.describe Alexandria::ExportLibrary do
72
72
  it "can export unsorted" do
73
73
  format.invoke(my_library, unsorted, outfile)
74
74
  aggregate_failures do
75
- expect(File.exist?(outfile)).to be_truthy
75
+ expect(outfile).to be_an_existing_file
76
76
  expect(File.size(outfile)).to be_nonzero
77
77
  end
78
78
  end
@@ -84,7 +84,7 @@ RSpec.describe Alexandria::ExportLibrary do
84
84
  it "can export unsorted" do
85
85
  format.invoke(my_library, unsorted, outfile)
86
86
  aggregate_failures do
87
- expect(File.exist?(outfile)).to be_truthy
87
+ expect(outfile).to be_an_existing_file
88
88
  expect(File.size(outfile)).to be_nonzero
89
89
  end
90
90
  end
@@ -96,7 +96,7 @@ RSpec.describe Alexandria::ExportLibrary do
96
96
  it "can export unsorted" do
97
97
  format.invoke(my_library, unsorted, outfile)
98
98
  aggregate_failures do
99
- expect(File.exist?(outfile)).to be_truthy
99
+ expect(outfile).to be_an_existing_file
100
100
  expect(File.size(outfile)).to be_nonzero
101
101
  end
102
102
  end
@@ -108,7 +108,7 @@ RSpec.describe Alexandria::ExportLibrary do
108
108
  it "can export unsorted" do
109
109
  format.invoke(my_library, unsorted, outfile)
110
110
  aggregate_failures do
111
- expect(File.exist?(outfile)).to be_truthy
111
+ expect(outfile).to be_an_existing_file
112
112
  expect(File.size(outfile)).to be_nonzero
113
113
  end
114
114
  end
@@ -122,7 +122,7 @@ RSpec.describe Alexandria::ExportLibrary do
122
122
  index = File.join(outfile, "index.linx")
123
123
 
124
124
  aggregate_failures do
125
- expect(File.exist?(outfile)).to be_truthy
125
+ expect(outfile).to be_an_existing_file
126
126
  expect(File.size(index)).to be_nonzero
127
127
  end
128
128
  end
@@ -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")
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")
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
-
194
- latex_book = my_library_reloaded.find { |b| b.title.include? "Latex" }
195
- expect(latex_book.publisher).to eq("Addison Wesley")
196
211
 
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,10 +238,10 @@ 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
@@ -236,7 +250,7 @@ describe Alexandria::Library do
236
250
  let(:my_library) { loader.load_library("Empty") }
237
251
 
238
252
  before do
239
- FileUtils.mkdir(TESTDIR) unless File.exist? TESTDIR
253
+ FileUtils.mkdir_p(TESTDIR)
240
254
  end
241
255
 
242
256
  it "changes the library's name" do
@@ -246,7 +260,7 @@ describe Alexandria::Library do
246
260
 
247
261
  it "moves the library's directory" do
248
262
  my_library.name = "Really Empty"
249
- expect(File.exist?(File.join(TESTDIR, "Really Empty"))).to be_truthy
263
+ expect(File.join(TESTDIR, "Really Empty")).to be_an_existing_file
250
264
  end
251
265
  end
252
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 { nil }
35
+ expect { import_dialog.acquire { nil } }.not_to raise_error
36
36
  end
37
37
 
38
38
  it "works when response is OK" do