Sha256: 8a0a8894065d261aae5b64634ae5c023d3e395475ab696b70625932c8624ca63
Contents?: true
Size: 1.77 KB
Versions: 4
Compression:
Stored size: 1.77 KB
Contents
require "spec_helper" describe XRayMachine::Config do before { XRayMachine.instance_eval{ @options = nil } } describe ".config" do it "allows to config things" do XRayMachine.config do |config| config.thing = {title: "Thingy"} end expect(XRayMachine.options.instance_variable_get("@streams")).to eq({ thing: {title: "Thingy", color: :red, show_in_summary: true} }) end it "allows to override colors and the summary settings" do XRayMachine.config do |config| config.thing = {title: "Thingy", color: :yellow, show_in_summary: false} end expect(XRayMachine.options.instance_variable_get("@streams")).to eq({ thing: {title: "Thingy", color: :yellow, show_in_summary: false} }) end end describe ".for" do subject { XRayMachine::Config.for("some_thing").to_h } it "generates a new config if the settings are missing" do is_expected.to eq({title: "SomeThing", color: "\e[31m", show_in_summary: true}) end it "uses the user settings when it configured" do XRayMachine.config { |c| c.some_thing = {title: "ST", color: :yellow} } is_expected.to eq({title: "ST", color: "\e[33m", show_in_summary: true}) end it "returns the same object every time" do is_expected.to eq(XRayMachine::Config.for("some_thing").to_h) end it "picks different colors for different things" do colors = (1..3).to_a.map{|i| XRayMachine::Config.for("thing_#{i}").color } expect(colors).to eq ["\e[31m", "\e[32m", "\e[33m"] end it "works great when only a color was configured" do XRayMachine.config { |c| c.some_thing = {color: :yellow} } is_expected.to eq({title: "SomeThing", color: "\e[33m", show_in_summary: true}) end end end
Version data entries
4 entries across 4 versions & 1 rubygems