alexandria-book-collection-manager 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.gitignore +4 -1
  4. data/.rubocop.yml +51 -29
  5. data/.rubocop_todo.yml +33 -155
  6. data/.simplecov +5 -2
  7. data/.travis.yml +10 -4
  8. data/CHANGELOG.md +19 -0
  9. data/INSTALL.md +23 -11
  10. data/README.md +36 -35
  11. data/Rakefile +7 -5
  12. data/alexandria-book-collection-manager.gemspec +8 -3
  13. data/doc/dependency_decisions.yml +22 -3
  14. data/lib/alexandria.rb +2 -2
  15. data/lib/alexandria/book_providers.rb +47 -49
  16. data/lib/alexandria/book_providers/adlibris.rb +8 -13
  17. data/lib/alexandria/book_providers/amazon_aws.rb +47 -60
  18. data/lib/alexandria/book_providers/amazon_ecs_util.rb +283 -298
  19. data/lib/alexandria/book_providers/barnes_and_noble.rb +8 -8
  20. data/lib/alexandria/book_providers/douban.rb +2 -2
  21. data/lib/alexandria/book_providers/proxis.rb +12 -11
  22. data/lib/alexandria/book_providers/pseudomarc.rb +60 -70
  23. data/lib/alexandria/book_providers/siciliano.rb +5 -6
  24. data/lib/alexandria/book_providers/thalia.rb +8 -9
  25. data/lib/alexandria/book_providers/worldcat.rb +25 -31
  26. data/lib/alexandria/book_providers/z3950.rb +62 -69
  27. data/lib/alexandria/default_preferences.rb +37 -0
  28. data/lib/alexandria/execution_queue.rb +13 -12
  29. data/lib/alexandria/export_library.rb +4 -8
  30. data/lib/alexandria/import_library.rb +38 -62
  31. data/lib/alexandria/import_library_csv.rb +16 -16
  32. data/lib/alexandria/library_sort_order.rb +3 -1
  33. data/lib/alexandria/library_store.rb +16 -16
  34. data/lib/alexandria/logging.rb +4 -8
  35. data/lib/alexandria/models/book.rb +2 -2
  36. data/lib/alexandria/models/library.rb +18 -14
  37. data/lib/alexandria/net.rb +1 -2
  38. data/lib/alexandria/preferences.rb +27 -31
  39. data/lib/alexandria/scanners.rb +2 -2
  40. data/lib/alexandria/scanners/cue_cat.rb +5 -5
  41. data/lib/alexandria/scanners/keyboard.rb +1 -1
  42. data/lib/alexandria/smart_library.rb +22 -26
  43. data/lib/alexandria/ui.rb +7 -7
  44. data/lib/alexandria/ui/about_dialog.rb +1 -1
  45. data/lib/alexandria/ui/acquire_dialog.rb +9 -10
  46. data/lib/alexandria/ui/alert_dialog.rb +34 -19
  47. data/lib/alexandria/ui/bad_isbns_dialog.rb +13 -9
  48. data/lib/alexandria/ui/barcode_animation.rb +5 -5
  49. data/lib/alexandria/ui/book_properties_dialog.rb +2 -2
  50. data/lib/alexandria/ui/book_properties_dialog_base.rb +23 -17
  51. data/lib/alexandria/ui/callbacks.rb +141 -120
  52. data/lib/alexandria/ui/completion_models.rb +1 -1
  53. data/lib/alexandria/ui/confirm_erase_dialog.rb +1 -1
  54. data/lib/alexandria/ui/conflict_while_copying_dialog.rb +1 -1
  55. data/lib/alexandria/ui/error_dialog.rb +1 -1
  56. data/lib/alexandria/ui/export_dialog.rb +13 -15
  57. data/lib/alexandria/ui/icons.rb +34 -40
  58. data/lib/alexandria/ui/iconview_tooltips.rb +40 -53
  59. data/lib/alexandria/ui/import_dialog.rb +48 -47
  60. data/lib/alexandria/ui/init.rb +3 -2
  61. data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +2 -2
  62. data/lib/alexandria/ui/libraries_combo.rb +10 -9
  63. data/lib/alexandria/ui/listview.rb +5 -6
  64. data/lib/alexandria/ui/main_app.rb +2 -2
  65. data/lib/alexandria/ui/multi_drag_treeview.rb +4 -6
  66. data/lib/alexandria/ui/new_book_dialog.rb +52 -52
  67. data/lib/alexandria/ui/new_provider_dialog.rb +12 -11
  68. data/lib/alexandria/ui/new_smart_library_dialog.rb +39 -27
  69. data/lib/alexandria/ui/preferences_dialog.rb +23 -82
  70. data/lib/alexandria/ui/provider_preferences_base_dialog.rb +9 -5
  71. data/lib/alexandria/ui/provider_preferences_dialog.rb +5 -5
  72. data/lib/alexandria/ui/really_delete_dialog.rb +1 -1
  73. data/lib/alexandria/ui/sidepane_manager.rb +35 -37
  74. data/lib/alexandria/ui/skip_entry_dialog.rb +3 -2
  75. data/lib/alexandria/ui/smart_library_properties_dialog.rb +35 -36
  76. data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +59 -138
  77. data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
  78. data/lib/alexandria/ui/sound.rb +4 -6
  79. data/lib/alexandria/ui/ui_manager.rb +62 -64
  80. data/lib/alexandria/version.rb +2 -2
  81. data/lib/alexandria/web_themes.rb +15 -15
  82. data/po/cs.po +991 -874
  83. data/po/cy.po +957 -870
  84. data/po/de.po +991 -866
  85. data/po/el.po +987 -863
  86. data/po/es.po +986 -862
  87. data/po/fr.po +988 -868
  88. data/po/ga.po +910 -822
  89. data/po/gl.po +983 -863
  90. data/po/it.po +984 -862
  91. data/po/ja.po +969 -849
  92. data/po/mk.po +983 -859
  93. data/po/nb.po +982 -862
  94. data/po/nl.po +992 -869
  95. data/po/pl.po +1018 -963
  96. data/po/pt.po +983 -852
  97. data/po/pt_BR.po +983 -863
  98. data/po/ru.po +992 -869
  99. data/po/sk.po +986 -864
  100. data/po/sv.po +980 -860
  101. data/po/uk.po +975 -861
  102. data/po/zh_TW.po +974 -854
  103. data/share/alexandria/glade/main_app__builder.glade +6 -21
  104. data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
  105. data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
  106. data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
  107. data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
  108. data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
  109. data/spec/alexandria/book_providers_spec.rb +73 -129
  110. data/spec/alexandria/console_spec.rb +0 -5
  111. data/spec/alexandria/export_library_spec.rb +27 -38
  112. data/spec/alexandria/library_spec.rb +56 -44
  113. data/spec/alexandria/preferences_spec.rb +29 -3
  114. data/spec/alexandria/scanners/cue_cat_spec.rb +1 -1
  115. data/spec/alexandria/ui/about_dialog_spec.rb +1 -1
  116. data/spec/alexandria/ui/acquire_dialog_spec.rb +1 -1
  117. data/spec/alexandria/ui/alert_dialog_spec.rb +1 -1
  118. data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +1 -1
  119. data/spec/alexandria/ui/book_properties_dialog_spec.rb +1 -1
  120. data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +1 -1
  121. data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +1 -1
  122. data/spec/alexandria/ui/error_dialog_spec.rb +1 -1
  123. data/spec/alexandria/ui/export_dialog_spec.rb +1 -1
  124. data/spec/alexandria/ui/icons_spec.rb +26 -0
  125. data/spec/alexandria/ui/iconview_spec.rb +1 -1
  126. data/spec/alexandria/ui/import_dialog_spec.rb +30 -3
  127. data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +1 -1
  128. data/spec/alexandria/ui/main_app_spec.rb +1 -1
  129. data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +1 -1
  130. data/spec/alexandria/ui/new_provider_dialog_spec.rb +19 -3
  131. data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +28 -3
  132. data/spec/alexandria/ui/preferences_dialog_spec.rb +1 -1
  133. data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +23 -8
  134. data/spec/alexandria/ui/really_delete_dialog_spec.rb +1 -1
  135. data/spec/alexandria/ui/sidepane_manager_spec.rb +2 -2
  136. data/spec/alexandria/ui/skip_entry_dialog_spec.rb +1 -1
  137. data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +21 -7
  138. data/spec/alexandria/ui/ui_manager_spec.rb +39 -2
  139. data/spec/spec_helper.rb +46 -3
  140. data/tasks/spec.rake +3 -5
  141. data/util/rake/fileinstall.rb +12 -11
  142. metadata +82 -10
  143. data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
  144. data/spec/alexandria/utilities_spec.rb +0 -52
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ErrorDialog do
10
10
  it "works" do
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ExportDialog do
10
10
  it "works" do
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Alexandria.
4
+ #
5
+ # See the file README.md for authorship and licensing information.
6
+
7
+ require "spec_helper"
8
+
9
+ RSpec.describe Alexandria::UI::Icons do
10
+ describe ".tag_icon" do
11
+ let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
12
+ let(:lib_version) { File.join(LIBDIR, "0.6.2") }
13
+
14
+ before do
15
+ FileUtils.cp_r(lib_version, TESTDIR)
16
+ end
17
+
18
+ it "returns a pixbuf" do
19
+ library = loader.load_all_libraries.first
20
+ icon = described_class.cover(library, library.first)
21
+
22
+ tagged_icon = described_class.tag_icon(icon, described_class::FAVORITE_TAG)
23
+ expect(tagged_icon).to be_a GdkPixbuf::Pixbuf
24
+ end
25
+ end
26
+ end
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::IconViewManager do
10
10
  it "works" do
@@ -4,11 +4,38 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ImportDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
12
13
  described_class.new parent
13
14
  end
15
+
16
+ describe "#acquire" do
17
+ let(:import_dialog) { described_class.new parent }
18
+ let(:chooser) { import_dialog.dialog }
19
+
20
+ before do
21
+ allow(chooser).to receive(:filename).and_return("spec/data/isbns.txt")
22
+ allow(Alexandria::BookProviders).to receive(:isbn_search)
23
+ .and_raise Alexandria::BookProviders::SearchEmptyError
24
+ allow(Alexandria::BookProviders).to receive(:isbn_search).with("0595371086")
25
+ .and_return(an_artist_of_the_floating_world)
26
+ end
27
+
28
+ it "works when response is cancel" do
29
+ allow(chooser).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
30
+ import_dialog.acquire {}
31
+ end
32
+
33
+ it "works when response is OK" do
34
+ allow(chooser).to receive(:run).and_return(Gtk::ResponseType::OK)
35
+
36
+ result = nil
37
+ import_dialog.acquire { |*args| result = args }
38
+ expect(result.first.to_a).to eq [an_artist_of_the_floating_world]
39
+ end
40
+ end
14
41
  end
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::KeepBadISBNDialog do
10
10
  it "works" do
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # See the file README.md for authorship and licensing information.
8
8
 
9
- require File.dirname(__FILE__) + "/../../spec_helper"
9
+ require_relative "../../spec_helper"
10
10
 
11
11
  describe Alexandria::UI::MainApp do
12
12
  it "is a singleton" do
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::NewBookDialogManual do
10
10
  it "works" do
@@ -4,11 +4,27 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::NewProviderDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
12
13
  described_class.new parent
13
14
  end
15
+
16
+ describe "#acquire" do
17
+ let(:provider_dialog) { described_class.new parent }
18
+ let(:gtk_dialog) { provider_dialog.dialog }
19
+
20
+ it "works when response is cancel" do
21
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
22
+ provider_dialog.acquire
23
+ end
24
+
25
+ it "works when response is accept" do
26
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::ACCEPT)
27
+ provider_dialog.acquire
28
+ end
29
+ end
14
30
  end
@@ -4,11 +4,36 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::NewSmartLibraryDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+
12
+ it "can be instantiated" do
12
13
  described_class.new parent
13
14
  end
15
+
16
+ describe "#acquire" do
17
+ let(:properties_dialog) { described_class.new parent }
18
+ let(:gtk_dialog) { properties_dialog.dialog }
19
+
20
+ it "works when response is cancel" do
21
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
22
+ properties_dialog.acquire
23
+ end
24
+
25
+ it "returns a smart library that can be saved when response is ok" do
26
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
27
+
28
+ # 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"
32
+
33
+ result = properties_dialog.acquire
34
+
35
+ expect(result).to be_a Alexandria::SmartLibrary
36
+ expect { result.save }.not_to raise_error
37
+ end
38
+ end
14
39
  end
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::PreferencesDialog do
10
10
  it "works" do
@@ -4,16 +4,31 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ProviderPreferencesDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- preferences = instance_double(Alexandria::BookProviders::Preferences,
13
- length: 0, read: [])
14
- provider = instance_double(Alexandria::BookProviders::GenericProvider,
15
- fullname: "FooProvider",
16
- prefs: preferences)
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+ let(:preferences) do
12
+ instance_double(Alexandria::BookProviders::Preferences,
13
+ length: 0, read: [])
14
+ end
15
+ let(:provider) do
16
+ instance_double(Alexandria::BookProviders::GenericProvider,
17
+ fullname: "FooProvider",
18
+ prefs: preferences)
19
+ end
20
+
21
+ it "can be instantiated" do
17
22
  described_class.new parent, provider
18
23
  end
24
+
25
+ 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
+
31
+ preferences_dialog.acquire
32
+ end
33
+ end
19
34
  end
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::ReallyDeleteDialog do
10
10
  it "works" do
@@ -4,9 +4,9 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
- describe Alexandria::UI::SidePaneManager do
9
+ describe Alexandria::UI::SidepaneManager do
10
10
  it "works" 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)
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::SkipEntryDialog do
10
10
  it "works" do
@@ -4,15 +4,29 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::SmartLibraryPropertiesDialog do
10
- it "works" do
11
- parent = Gtk::Window.new :toplevel
12
- smart_library = instance_double(Alexandria::SmartLibrary,
13
- name: "Foo",
14
- rules: [],
15
- predicate_operator_rule: :any)
10
+ let(:parent) { Gtk::Window.new :toplevel }
11
+ let(:loader) { Alexandria::LibraryStore.new(TESTDIR) }
12
+ let(:smart_library) { Alexandria::SmartLibrary.new("Foo", [], :all, loader) }
13
+
14
+ it "can be instantiated" do
16
15
  described_class.new parent, smart_library
17
16
  end
17
+
18
+ describe "#acquire" do
19
+ let(:properties_dialog) { described_class.new parent, smart_library }
20
+ let(:gtk_dialog) { properties_dialog.dialog }
21
+
22
+ it "works when response is cancel" do
23
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
24
+ properties_dialog.acquire
25
+ end
26
+
27
+ it "works when response is ok" do
28
+ allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)
29
+ properties_dialog.acquire
30
+ end
31
+ end
18
32
  end
@@ -4,11 +4,48 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- require File.dirname(__FILE__) + "/../../spec_helper"
7
+ require_relative "../../spec_helper"
8
8
 
9
9
  describe Alexandria::UI::UIManager do
10
+ let(:main_app) { instance_double(Alexandria::UI::MainApp) }
11
+
10
12
  it "works" do
11
- main_app = instance_double(Alexandria::UI::MainApp)
12
13
  described_class.new main_app
13
14
  end
15
+
16
+ describe "#on_new" do
17
+ it "works" do
18
+ ui = described_class.new main_app
19
+ libraries = ui.instance_variable_get("@libraries")
20
+ libraries_count = libraries.all_libraries.count
21
+ ui.on_new
22
+ expect(libraries.all_libraries.count).to eq libraries_count + 1
23
+ end
24
+ end
25
+
26
+ describe "#on_books_selection_changed" do
27
+ let(:lib_version) { File.join(LIBDIR, "0.6.2") }
28
+ let(:ui) { described_class.new main_app }
29
+ let(:libraries) { ui.instance_variable_get("@libraries") }
30
+ let(:regular_library) { libraries.all_regular_libraries.last }
31
+
32
+ before do
33
+ FileUtils.cp_r(lib_version, TESTDIR)
34
+ end
35
+
36
+ it "works when single book is selected" do
37
+ ui.select_a_library regular_library
38
+
39
+ # FIXME: This is needed because right now UIManager#refresh_books doesn't
40
+ # work without Gtk loop.
41
+ regular_library.each { |book| ui.append_book book }
42
+ ui.iconview.unfreeze
43
+ expect(ui.model.iter_n_children).to eq regular_library.count
44
+
45
+ # This triggers the #on_books_selection_changed callback
46
+ ui.select_a_book regular_library.first
47
+
48
+ expect(ui.iconview.selected_items).not_to be_empty
49
+ end
50
+ end
14
51
  end
@@ -4,11 +4,11 @@
4
4
  #
5
5
  # See the file README.md for authorship and licensing information.
6
6
 
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../lib"))
8
-
7
+ require "rspec"
9
8
  require "alexandria"
9
+ require "webmock/rspec"
10
10
 
11
- LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), "/data/libraries"))
11
+ LIBDIR = File.expand_path("data/libraries", __dir__)
12
12
  TESTDIR = File.join(LIBDIR, "test")
13
13
 
14
14
  def an_artist_of_the_floating_world
@@ -19,12 +19,55 @@ def an_artist_of_the_floating_world
19
19
  "Paperback")
20
20
  end
21
21
 
22
+ def assert_correct_search_result(provider, query,
23
+ search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
24
+ begin
25
+ results = provider.instance.search(query, search_type)
26
+ rescue SocketError
27
+ skip "Service is offline"
28
+ end
29
+
30
+ expect(results).to be_instance_of(Array), "Results are not an array for #{provider}"
31
+ expect(results).not_to be_empty, "Results are empty for #{provider}"
32
+
33
+ if search_type == Alexandria::BookProviders::SEARCH_BY_ISBN
34
+ expect(results.length).to be <= 2, "Results are greater than 2 for #{provider}"
35
+
36
+ book = results.first
37
+
38
+ expect(book).to be_instance_of(Alexandria::Book),
39
+ "Result is not a Book for #{provider}"
40
+
41
+ canonical_query = Alexandria::Library.canonicalise_ean(query)
42
+ canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
43
+ expect(canonical_query)
44
+ .to eq(canonical_result),
45
+ "Result's isbn #{book.isbn} is not equivalent" \
46
+ " to the requested isbn #{query} for #{provider}"
47
+
48
+ if results.length == 2
49
+ cover_url = results.last
50
+ if cover_url
51
+ expect(cover_url)
52
+ .to be_instance_of(String),
53
+ "Unexpected cover_url #{cover_url.inspect} for #{provider}"
54
+ end
55
+ end
56
+ else
57
+ expect(results.first.first)
58
+ .to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
59
+ end
60
+ results
61
+ end
62
+
22
63
  Alexandria::UI::Icons.init
23
64
 
24
65
  test_store = Alexandria::LibraryStore.new(TESTDIR)
25
66
  Alexandria::LibraryCollection.instance.library_store = test_store
26
67
 
27
68
  RSpec.configure do |config|
69
+ config.example_status_persistence_file_path = "spec/examples.txt"
70
+
28
71
  config.before do
29
72
  FileUtils.rm_rf(TESTDIR)
30
73
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -*- ruby -*-
4
4
  #--
5
- # Copyright (C) 2011-2019 Matijs van Zuijlen
5
+ # Copyright (C) 2011 Matijs van Zuijlen
6
6
  #
7
7
  # This file is part of the Alexandria build system.
8
8
  #
@@ -39,10 +39,8 @@ namespace "spec" do
39
39
  t.ruby_opts = ["-rbundler/setup -rsimplecov -Ilib -w"]
40
40
  end
41
41
 
42
- RSpec::Core::RakeTask.new("all") do |t|
43
- t.pattern = "spec/**/*_spec.rb"
44
- t.ruby_opts = ["-rbundler/setup -rsimplecov -Ilib -w"]
45
- end
42
+ desc "Runs all unit and end-to-end specs"
43
+ task "all" => ["spec:unit", "spec:end_to_end"]
46
44
  end
47
45
 
48
46
  task spec: "spec:all"