spec/alexandria/ui/export_dialog_spec.rb in alexandria-book-collection-manager-0.7.6 vs spec/alexandria/ui/export_dialog_spec.rb in alexandria-book-collection-manager-0.7.7

- old
+ new

@@ -5,11 +5,32 @@ # See the file README.md for authorship and licensing information. require_relative "../../spec_helper" describe Alexandria::UI::ExportDialog do + let(:parent) { Gtk::Window.new :toplevel } + let(:library) { Alexandria::Library.new "Bar Library" } + let(:sort_order) { Alexandria::LibrarySortOrder::Unsorted.new } + it "works" do - parent = Gtk::Window.new :toplevel - library = instance_double(Alexandria::Library, name: "Bar Library") - described_class.new parent, library, :ascending + described_class.new parent, library, sort_order + end + + describe "#perform" do + let(:export_dialog) { described_class.new parent, library, sort_order } + let(:chooser) { export_dialog.dialog } + + it "works when response is cancel" do + allow(chooser).to receive(:run).and_return(Gtk::ResponseType::CANCEL) + export_dialog.perform + end + + it "works when response is OK" do + dir = Dir.mktmpdir + allow(chooser).to receive(:run).and_return(Gtk::ResponseType::OK) + allow(chooser).to receive(:filename).and_return File.join(dir, "export") + export_dialog.perform + ensure + FileUtils.remove_entry dir + end end end