Sha256: 47b7554513fa7fb84a3f02e8efbe0cd9ec8ca70ce6f86941efffc032c8fad70e
Contents?: true
Size: 1.07 KB
Versions: 39
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' describe DiscourseApi::API::Params do def params_for(h) DiscourseApi::API::Params.new(h).required(:r1).optional(:o1, :o2).default(d1: "default") end it "should raise on missing required params" do expect { params_for({o1: "test"}).to_h }.to raise_error(ArgumentError) end it "should not include optional params when not provided" do expect(params_for({r1: "test"}).to_h).not_to include(:o1) end it "should include optional params if provided but blank" do expect(params_for({r1: "test", o2: nil}).to_h).to include(:o2) end it "should include default params when defined but not provided" do expect(params_for({r1: "test"}).to_h).to include(d1: "default") end it "should include default params when defined and provided" do expect(params_for({r1: "test", d1: "override"}).to_h).to include(d1: "override") end it "should include optional and default params when defined and provided" do expect(params_for({r1: "test", o1: "optional", d1: "override"}).to_h).to include(o1: "optional", d1: "override") end end
Version data entries
39 entries across 39 versions & 1 rubygems