Sha256: 06fcd408ad9f8215d0549077231b234959c09c2e8c68ce1fb540c9b8dbd8265b

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 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
    expect { described_class.new parent }.not_to raise_error
  end

  describe "#acquire" do
    let(:properties_dialog) { described_class.new parent }
    let(:gtk_dialog) { properties_dialog.dialog }
    let(:rules_box) { properties_dialog.instance_variable_get(:@rules_box) }
    let(:rule_entry) { rules_box.children.first.children[2] }

    it "works when response is cancel" do
      allow(gtk_dialog).to receive(:run).and_return(Gtk::ResponseType::CANCEL)
      expect { properties_dialog.acquire }.not_to raise_error
    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
      rule_entry.text = "foo"

      result = properties_dialog.acquire

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

Version data entries

1 entries across 1 versions & 1 rubygems

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