Sha256: b22dff18dcd7025665b5b26285442a54999a7ad78b687cf011c8a13dc0e298a3

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

# This file is part of Alexandria.
#
# See the file README.md for authorship and licensing information.

require_relative "../../spec_helper"

describe Alexandria::UI::NewBookDialogManual do
  let(:parent) { Gtk::Window.new :toplevel }
  let(:library) do
    store = Alexandria::LibraryCollection.instance.library_store
    store.load_library("Bar Library")
  end

  it "works" do
    described_class.new parent, library
  end

  describe "#on_change_cover" do
    let(:dialog) { described_class.new parent, library }
    let(:filechooser) { instance_double(Gtk::FileChooserDialog).as_null_object }

    before do
      allow(Gtk::FileChooserDialog).to receive(:new).and_return(filechooser)
      allow(filechooser).to receive(:filename)
        .and_return File.join(__dir__, "../../fixtures/cover.jpg")
    end

    it "works when response is accept" do
      allow(filechooser)
        .to receive(:run).and_return(Gtk::ResponseType::ACCEPT)

      dialog.on_change_cover
    end

    it "works when response is reject" do
      allow(filechooser)
        .to receive(:run).and_return(Gtk::ResponseType::REJECT)

      dialog.on_change_cover
    end

    it "works when response is cancel" do
      allow(filechooser)
        .to receive(:run).and_return(Gtk::ResponseType::CANCEL)

      dialog.on_change_cover
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alexandria-book-collection-manager-0.7.9 spec/alexandria/ui/new_book_dialog_manual_spec.rb
alexandria-book-collection-manager-0.7.8 spec/alexandria/ui/new_book_dialog_manual_spec.rb