alexandria-book-collection-manager 0.7.9 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +5 -1
  3. data/.github/workflows/ruby.yml +36 -22
  4. data/.rubocop.yml +12 -3
  5. data/.rubocop_todo.yml +35 -47
  6. data/.simplecov +2 -2
  7. data/CHANGELOG.md +71 -24
  8. data/Gemfile +0 -6
  9. data/Rakefile +5 -5
  10. data/alexandria-book-collection-manager.gemspec +24 -21
  11. data/bin/rake +28 -0
  12. data/bin/rspec +28 -0
  13. data/doc/dependency_decisions.yml +32 -26
  14. data/{bin → exe}/alexandria +1 -3
  15. data/lib/alexandria/about.rb +1 -0
  16. data/lib/alexandria/book_providers/bl_provider.rb +4 -6
  17. data/lib/alexandria/book_providers/{douban.rb → douban_provider.rb} +1 -1
  18. data/lib/alexandria/book_providers/loc_provider.rb +2 -6
  19. data/lib/alexandria/book_providers/sbn_provider.rb +2 -12
  20. data/lib/alexandria/book_providers/thalia_provider.rb +5 -6
  21. data/lib/alexandria/book_providers/{web.rb → website_based_provider.rb} +20 -1
  22. data/lib/alexandria/book_providers/{worldcat.rb → world_cat_provider.rb} +3 -4
  23. data/lib/alexandria/book_providers/z3950_provider.rb +25 -27
  24. data/lib/alexandria/book_providers.rb +14 -10
  25. data/lib/alexandria/config.rb +2 -2
  26. data/lib/alexandria/console.rb +12 -10
  27. data/lib/alexandria/export_format.rb +3 -2
  28. data/lib/alexandria/export_library.rb +35 -40
  29. data/lib/alexandria/import_library.rb +3 -4
  30. data/lib/alexandria/import_library_csv.rb +2 -2
  31. data/lib/alexandria/library_collection.rb +1 -1
  32. data/lib/alexandria/library_store.rb +20 -15
  33. data/lib/alexandria/logging.rb +22 -21
  34. data/lib/alexandria/models/book.rb +1 -2
  35. data/lib/alexandria/models/library.rb +7 -8
  36. data/lib/alexandria/preferences.rb +7 -19
  37. data/lib/alexandria/{book_providers/pseudomarc.rb → pseudo_marc_parser.rb} +2 -2
  38. data/lib/alexandria/scanners/cue_cat.rb +5 -9
  39. data/lib/alexandria/scanners/{keyboard.rb → keyboard_wedge.rb} +3 -3
  40. data/lib/alexandria/scanners.rb +2 -2
  41. data/lib/alexandria/smart_library.rb +9 -5
  42. data/lib/alexandria/ui/acquire_dialog.rb +42 -45
  43. data/lib/alexandria/ui/alert_dialog.rb +3 -3
  44. data/lib/alexandria/ui/barcode_animation.rb +3 -3
  45. data/lib/alexandria/ui/book_properties_dialog.rb +9 -9
  46. data/lib/alexandria/ui/book_properties_dialog_base.rb +13 -14
  47. data/lib/alexandria/ui/builder_base.rb +1 -1
  48. data/lib/alexandria/ui/callbacks.rb +8 -7
  49. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -0
  50. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -0
  51. data/lib/alexandria/ui/export_dialog.rb +1 -0
  52. data/lib/alexandria/ui/{iconview.rb → icon_view_manager.rb} +1 -0
  53. data/lib/alexandria/ui/icons.rb +2 -2
  54. data/lib/alexandria/ui/iconview_tooltips.rb +1 -1
  55. data/lib/alexandria/ui/init.rb +10 -4
  56. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +1 -0
  57. data/lib/alexandria/ui/libraries_combo.rb +1 -0
  58. data/lib/alexandria/ui/listview.rb +2 -0
  59. data/lib/alexandria/ui/main_app.rb +3 -1
  60. data/lib/alexandria/ui/multi_drag_treeview.rb +0 -2
  61. data/lib/alexandria/ui/new_book_dialog.rb +15 -20
  62. data/lib/alexandria/ui/new_book_dialog_manual.rb +7 -7
  63. data/lib/alexandria/ui/new_provider_dialog.rb +1 -0
  64. data/lib/alexandria/ui/new_smart_library_dialog.rb +2 -1
  65. data/lib/alexandria/ui/preferences_dialog.rb +4 -4
  66. data/lib/alexandria/ui/provider_preferences_dialog.rb +1 -0
  67. data/lib/alexandria/ui/really_delete_dialog.rb +1 -0
  68. data/lib/alexandria/ui/sidepane_manager.rb +49 -48
  69. data/lib/alexandria/ui/skip_entry_dialog.rb +1 -0
  70. data/lib/alexandria/ui/smart_library_properties_dialog.rb +1 -0
  71. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +2 -1
  72. data/lib/alexandria/ui/{sound.rb → sound_effects_player.rb} +3 -0
  73. data/lib/alexandria/ui/ui_manager.rb +194 -143
  74. data/lib/alexandria/ui.rb +1 -0
  75. data/lib/alexandria/version.rb +1 -1
  76. data/lib/alexandria/web_themes.rb +1 -1
  77. data/lib/alexandria.rb +6 -5
  78. data/po/Makefile +1 -1
  79. data/po/it.po +64 -82
  80. data/spec/alexandria/book_providers/bl_provider_spec.rb +11 -2
  81. data/spec/alexandria/book_providers/douban_provider_spec.rb +17 -0
  82. data/spec/alexandria/book_providers/loc_provider_spec.rb +10 -2
  83. data/spec/alexandria/book_providers/sbn_provider_spec.rb +10 -2
  84. data/spec/alexandria/book_providers/thalia_provider_spec.rb +9 -1
  85. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +30 -10
  86. data/spec/alexandria/book_providers/z3950_provider_spec.rb +22 -0
  87. data/spec/alexandria/book_spec.rb +5 -3
  88. data/spec/alexandria/console_spec.rb +1 -1
  89. data/spec/alexandria/export_library_spec.rb +65 -19
  90. data/spec/alexandria/library_collection_spec.rb +24 -0
  91. data/spec/alexandria/library_spec.rb +68 -53
  92. data/spec/alexandria/library_store_spec.rb +33 -1
  93. data/spec/alexandria/preferences_spec.rb +7 -7
  94. data/spec/alexandria/pseudo_marc_parser_spec.rb +71 -0
  95. data/spec/alexandria/scanners/cue_cat_spec.rb +11 -4
  96. data/spec/alexandria/scanners/keyboard_wedge_spec.rb +47 -0
  97. data/spec/alexandria/smart_library_spec.rb +7 -5
  98. data/spec/alexandria/ui/about_dialog_spec.rb +2 -2
  99. data/spec/alexandria/ui/acquire_dialog_spec.rb +8 -3
  100. data/spec/alexandria/ui/alert_dialog_spec.rb +6 -4
  101. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +2 -2
  102. data/spec/alexandria/ui/book_properties_dialog_spec.rb +5 -5
  103. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +19 -3
  104. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +2 -2
  105. data/spec/alexandria/ui/error_dialog_spec.rb +14 -3
  106. data/spec/alexandria/ui/export_dialog_spec.rb +6 -6
  107. data/spec/alexandria/ui/{iconview_spec.rb → icon_view_manager_spec.rb} +2 -2
  108. data/spec/alexandria/ui/import_dialog_spec.rb +3 -3
  109. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +2 -2
  110. data/spec/alexandria/ui/main_app_spec.rb +0 -2
  111. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +5 -5
  112. data/spec/alexandria/ui/new_book_dialog_spec.rb +7 -4
  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 +2 -2
  116. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +22 -7
  117. data/spec/alexandria/ui/really_delete_dialog_spec.rb +2 -2
  118. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  119. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +19 -3
  120. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +2 -2
  121. data/spec/alexandria/ui/ui_manager_spec.rb +7 -5
  122. data/spec/end_to_end/basic_run_spec.rb +2 -1
  123. data/spec/spec_helper.rb +26 -33
  124. data/tasks/setup.rb +1 -1
  125. data/util/rake/fileinstall.rb +12 -13
  126. data/util/rake/gettextgenerate.rb +1 -1
  127. data/util/rake/omfgenerate.rb +1 -1
  128. metadata +97 -64
  129. /data/spec/alexandria/ui/{sound_spec.rb → sound_effects_player_spec.rb} +0 -0
@@ -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
@@ -7,8 +7,8 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::AboutDialog do
10
- it "works" do
10
+ it "can be instantiated" 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
@@ -7,8 +7,13 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::AcquireDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+ let(:library) { Alexandria::Library.new("Hi") }
12
+ let(:ui_manager) { instance_double(Alexandria::UI::UIManager) }
13
+
14
+ it "can be instantiated" do
15
+ allow(ui_manager).to receive :set_status_label
16
+ dialog = described_class.new parent, ui_manager, library
17
+ expect(dialog).to be_a described_class
13
18
  end
14
19
  end
@@ -7,10 +7,12 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::AlertDialog do
10
- it "works" do
10
+ it "can be instantiated" 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
@@ -7,8 +7,8 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::BadIsbnsDialog do
10
- it "works" do
10
+ it "can be instantiated" 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
@@ -21,8 +21,8 @@ describe Alexandria::UI::BookPropertiesDialog do
21
21
  library << book
22
22
  end
23
23
 
24
- it "works" do
25
- described_class.new parent, library, book
24
+ it "can be instantiated" do
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
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "foo-file"
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
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
@@ -7,10 +7,10 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ConflictWhileCopyingDialog do
10
- it "works" do
10
+ it "can be instantiated" 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
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "Boom", "It went boom"
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
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
@@ -11,8 +11,8 @@ describe Alexandria::UI::ExportDialog do
11
11
  let(:library) { Alexandria::Library.new "Bar Library" }
12
12
  let(:sort_order) { Alexandria::LibrarySortOrder::Unsorted.new }
13
13
 
14
- it "works" do
15
- described_class.new parent, library, sort_order
14
+ it "can be instantiated" do
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
- allow(chooser).to receive(:run).and_return(Gtk::ResponseType::OK)
30
- allow(chooser).to receive(:filename).and_return File.join(dir, "export")
31
- export_dialog.perform
29
+ allow(chooser).to receive_messages(run: Gtk::ResponseType::OK,
30
+ filename: File.join(dir, "export"))
31
+ expect { export_dialog.perform }.not_to raise_error
32
32
  ensure
33
33
  FileUtils.remove_entry dir
34
34
  end
@@ -7,9 +7,9 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::IconViewManager do
10
- it "works" do
10
+ it "can be instantiated" 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
@@ -7,11 +7,11 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::KeepBadISBNDialog do
10
- it "works" do
10
+ it "can be instantiated" do
11
11
  parent = Gtk::Window.new :toplevel
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
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # frozen_string_literal: true
4
-
5
3
  # This file is part of Alexandria.
6
4
  #
7
5
  # See the file README.md for authorship and licensing information.
@@ -13,8 +13,8 @@ describe Alexandria::UI::NewBookDialogManual do
13
13
  store.load_library("Bar Library")
14
14
  end
15
15
 
16
- it "works" do
17
- described_class.new parent, library
16
+ it "can be instantiated" do
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
@@ -9,14 +9,17 @@ require "spec_helper"
9
9
  describe Alexandria::UI::NewBookDialog do
10
10
  let(:parent) { Gtk::Window.new :toplevel }
11
11
  let(:model) { Gtk::ListStore.new(String, String, GdkPixbuf::Pixbuf) }
12
+ let(:library) { Alexandria::Library.new("Hi") }
13
+ let(:ui_manager) { instance_double(Alexandria::UI::UIManager) }
12
14
 
13
- it "works" do
14
- described_class.new parent
15
+ it "can be instantiated" do
16
+ dialog = described_class.new parent, ui_manager, library
17
+ expect(dialog).to be_a described_class
15
18
  end
16
19
 
17
20
  it "can copy search results into result treeview" do
18
21
  results = [[an_artist_of_the_floating_world, "cover-url"]]
19
- dialog = described_class.new parent
20
- dialog.copy_results_to_treeview_model results, model
22
+ dialog = described_class.new parent, ui_manager, library
23
+ expect { dialog.copy_results_to_treeview_model results, model }.not_to raise_error
21
24
  end
22
25
  end
@@ -10,7 +10,7 @@ describe Alexandria::UI::NewProviderDialog 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
  describe "#acquire" do
@@ -19,12 +19,12 @@ describe Alexandria::UI::NewProviderDialog do
19
19
 
20
20
  it "works when response is cancel" do
21
21
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
22
- provider_dialog.acquire
22
+ expect { provider_dialog.acquire }.not_to raise_error
23
23
  end
24
24
 
25
25
  it "works when response is accept" do
26
26
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::ACCEPT)
27
- provider_dialog.acquire
27
+ expect { provider_dialog.acquire }.not_to raise_error
28
28
  end
29
29
  end
30
30
  end
@@ -10,30 +10,32 @@ describe Alexandria::UI::NewSmartLibraryDialog 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
  describe "#acquire" do
17
17
  let(:properties_dialog) { described_class.new parent }
18
18
  let(:gtk_dialog) { properties_dialog.dialog }
19
+ let(:rules_box) { properties_dialog.instance_variable_get(:@rules_box) }
20
+ let(:rule_entry) { rules_box.children.first.children[2] }
19
21
 
20
22
  it "works when response is cancel" do
21
23
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
22
- properties_dialog.acquire
24
+ expect { properties_dialog.acquire }.not_to raise_error
23
25
  end
24
26
 
25
27
  it "returns a smart library that can be saved when response is ok" do
26
28
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
27
29
 
28
30
  # Make sure entered rule is valid
29
- rules_box = properties_dialog.instance_variable_get(:@rules_box)
30
- entry = rules_box.children.first.children[2]
31
- entry.text = "foo"
31
+ rule_entry.text = "foo"
32
32
 
33
33
  result = properties_dialog.acquire
34
34
 
35
- expect(result).to be_a Alexandria::SmartLibrary
36
- expect { result.save }.not_to raise_error
35
+ aggregate_failures do
36
+ expect(result).to be_a Alexandria::SmartLibrary
37
+ expect { result.save }.not_to raise_error
38
+ end
37
39
  end
38
40
  end
39
41
  end
@@ -7,8 +7,8 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::PreferencesDialog do
10
- it "works" do
10
+ it "can be instantiated" do
11
11
  parent = Gtk::Window.new :toplevel
12
- described_class.new(parent) { nil }
12
+ expect { described_class.new(parent) { nil } }.not_to raise_error
13
13
  end
14
14
  end
@@ -8,9 +8,13 @@ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ProviderPreferencesDialog do
10
10
  let(:parent) { Gtk::Window.new :toplevel }
11
+ let(:variable) do
12
+ instance_double(Alexandria::BookProviders::Preferences::Variable,
13
+ name: "foo-bar", description: "Foo Bar", possible_values: nil,
14
+ value: "baz", mandatory?: false)
15
+ end
11
16
  let(:preferences) do
12
- instance_double(Alexandria::BookProviders::Preferences,
13
- length: 0, read: [])
17
+ instance_double(Alexandria::BookProviders::Preferences, length: 0, read: [variable])
14
18
  end
15
19
  let(:provider) do
16
20
  instance_double(Alexandria::BookProviders::GenericProvider,
@@ -19,16 +23,27 @@ describe Alexandria::UI::ProviderPreferencesDialog do
19
23
  end
20
24
 
21
25
  it "can be instantiated" do
22
- described_class.new parent, provider
26
+ expect { described_class.new parent, provider }.not_to raise_error
23
27
  end
24
28
 
25
29
  describe "#acquire" do
26
- it "works" do
27
- preferences_dialog = described_class.new parent, provider
28
- gtk_dialog = preferences_dialog.dialog
29
- allow(gtk_dialog).to receive(:run)
30
+ let(:preferences_dialog) { described_class.new parent, provider }
31
+
32
+ before do
33
+ allow(preferences_dialog.dialog).to receive(:run)
34
+ allow(variable).to receive(:new_value=)
35
+ end
36
+
37
+ it "runs the underlying Gtk+ dialog" do
38
+ preferences_dialog.acquire
39
+
40
+ expect(preferences_dialog.dialog).to have_received(:run)
41
+ end
30
42
 
43
+ it "updates variables" do
31
44
  preferences_dialog.acquire
45
+
46
+ expect(variable).to have_received(:new_value=).with "baz"
32
47
  end
33
48
  end
34
49
  end
@@ -7,10 +7,10 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ReallyDeleteDialog do
10
- it "works" do
10
+ it "can be instantiated" do
11
11
  library = instance_double(Alexandria::Library,
12
12
  name: "Bar Library", empty?: false, size: 12)
13
13
  parent = Gtk::Window.new :toplevel
14
- described_class.new parent, library
14
+ expect { described_class.new parent, library }.not_to raise_error
15
15
  end
16
16
  end
@@ -7,9 +7,9 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::SidepaneManager do
10
- it "works" do
10
+ it "can be instantiated" do
11
11
  library_listview = instance_double(Gtk::TreeView).as_null_object
12
12
  parent = instance_double(Alexandria::UI::UIManager, main_app: nil, append_library: nil)
13
- described_class.new library_listview, parent
13
+ expect { described_class.new library_listview, parent }.not_to raise_error
14
14
  end
15
15
  end
@@ -7,8 +7,24 @@
7
7
  require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::SkipEntryDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- described_class.new parent, "Foo"
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
13
+ expect { described_class.new parent, "Foo" }.not_to raise_error
14
+ end
15
+
16
+ describe "continue?" do
17
+ let(:instance) { described_class.new parent, "Foo" }
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.continue?).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.continue?).to be true
28
+ end
13
29
  end
14
30
  end
@@ -18,12 +18,12 @@ describe Alexandria::UI::SmartLibraryPropertiesDialog do
18
18
  describe "#acquire" do
19
19
  it "works when response is cancel" do
20
20
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
21
- properties_dialog.acquire
21
+ expect { properties_dialog.acquire }.not_to raise_error
22
22
  end
23
23
 
24
24
  it "works when response is ok" do
25
25
  allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
26
- properties_dialog.acquire
26
+ expect { properties_dialog.acquire }.not_to raise_error
27
27
  end
28
28
  end
29
29
 
@@ -9,12 +9,12 @@ require_relative "../../spec_helper"
9
9
  describe Alexandria::UI::UIManager do
10
10
  let(:main_app) { instance_double(Alexandria::UI::MainApp) }
11
11
 
12
- it "works" do
13
- described_class.new main_app
12
+ it "can be instantiated" do
13
+ expect { described_class.new main_app }.not_to raise_error
14
14
  end
15
15
 
16
16
  describe "#on_new" do
17
- it "works" do
17
+ it "adds one library" do
18
18
  ui = described_class.new main_app
19
19
  libraries = ui.instance_variable_get(:@libraries)
20
20
  libraries_count = libraries.all_libraries.count
@@ -41,12 +41,14 @@ describe Alexandria::UI::UIManager do
41
41
  regular_library.each { |book| ui.append_book book }
42
42
  # This makes the iconview model re-appear
43
43
  ui.iconview.unfreeze
44
- expect(ui.model.iter_n_children).to eq regular_library.count
45
44
 
46
45
  # This triggers the #on_books_selection_changed callback
47
46
  ui.select_a_book regular_library.first
48
47
 
49
- expect(ui.iconview.selected_items).not_to be_empty
48
+ aggregate_failures do
49
+ expect(ui.model.iter_n_children).to eq regular_library.count
50
+ expect(ui.iconview.selected_items).not_to be_empty
51
+ end
50
52
  end
51
53
  end
52
54
 
@@ -8,7 +8,8 @@ require "gnome_app_driver"
8
8
  require "tmpdir"
9
9
 
10
10
  describe "The Alexandria application" do
11
- let(:driver) { GnomeAppDriver.new "alexandria" }
11
+ # TODO: Remove app_file argument once GnomeAppDriver is smart about executable location
12
+ let(:driver) { GnomeAppDriver.new "alexandria", app_file: "exe/alexandria" }
12
13
 
13
14
  before do
14
15
  ENV["HOME"] = Dir.mktmpdir