1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
# frozen_string_literal: true
require "guard/ui/config"
RSpec.describe Guard::UI::Config do
describe "#device" do
context "when not set" do
context "when accessed as a method" do
it "returns $stderr" do
expect(subject.device).to be($stderr)
end
end
context "when accessed as a string" do
it "returns $stderr" do
expect(subject["device"]).to be($stderr)
end
end
context "when accessed as a symbol" do
it "returns $stderr" do
expect(subject[:device]).to be($stderr)
end
end
end
end
describe "#logger_config" do
let(:options) { {} }
subject { described_class.new(options) }
let(:logger_config) { instance_double("Guard::UI::Logger::Config") }
before do
allow(Guard::UI::Logger::Config).to receive(:new)
.and_return(logger_config)
end
context "with defaults" do
it "provides a logger config" do
expect(subject.logger_config).to be(logger_config)
end
end
context "with deprecated options set" do
context "when set using a string" do
subject { described_class.new('time_format': "foo") }
it "passes deprecated options to logger" do
expect(Guard::UI::Logger::Config).to receive(:new)
.with({ time_format: "foo" })
subject
end
it "provides a logger config" do
expect(subject.logger_config).to be(logger_config)
end
end
context "when set using a symbol" do
let(:options) { { time_format: "foo" } }
it "passes deprecated options to logger" do
expect(Guard::UI::Logger::Config).to receive(:new)
.with({ time_format: "foo" })
subject
end
it "provides a logger config" do
expect(subject.logger_config).to be(logger_config)
end
end
end
end
end
|