# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Config::Strconv do subject(:strconv) { Wayfarer::Config::Strconv } describe "::parse" do describe Hash do it "parses" do input = "alpha:1,beta:two,gamma:true" output = strconv.parse(input, Hash) expect(output).to eq(alpha: 1, beta: "two", gamma: true) end end describe Array do it "parses" do input = "alpha, beta , gamma" output = strconv.parse(input, Array) expect(output).to eq(%w[alpha beta gamma]) end end describe Symbol do it "parses" do expect(strconv.parse("foobar", Symbol)).to be(:foobar) end end describe Integer do it "parses" do expect(strconv.parse("42", Integer)).to be(42) end end describe "Primitives" do context "Booleans" do it "parses" do expect(strconv.parse("true")).to be(true) expect(strconv.parse("false")).to be(false) end end context "Numbers" do it "parses" do expect(strconv.parse("42")).to be(42) end end context "Strings" do it "parses" do expect(strconv.parse("foobar")).to be("foobar") end end end end end