Sha256: ce4bf4c757a2757ba953444e634d35df0c9c220f277471769c704f47e9c43d27

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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::NewSmartLibraryDialog do
  let(:parent) { Gtk::Window.new :toplevel }

  it "can be instantiated" do
    described_class.new parent
  end

  describe "#acquire" do
    let(:properties_dialog) { described_class.new parent }
    let(:gtk_dialog) { properties_dialog.dialog }

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

    it "returns a smart library that can be saved when response is ok" do
      allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::OK)

      # Make sure entered rule is valid
      rules_box = properties_dialog.instance_variable_get(:@rules_box)
      entry = rules_box.children.first.children[2]
      entry.text = "foo"

      result = properties_dialog.acquire

      expect(result).to be_a Alexandria::SmartLibrary
      expect { result.save }.not_to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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