Sha256: 9b90159ea07d243182358df673de8536aefa99d146e4d50121de15a8343c7563

Contents?: true

Size: 563 Bytes

Versions: 10

Compression:

Stored size: 563 Bytes

Contents

require 'spec_helper'

describe DiscourseApi::API::Params do
  def params_for(h)
    DiscourseApi::API::Params.new(h).required(:r1).optional(:o1, :o2)
  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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
discourse_api-0.6.1 spec/discourse_api/api/params_spec.rb
discourse_api-0.6.0 spec/discourse_api/api/params_spec.rb
discourse_api-0.5.1 spec/discourse_api/api/params_spec.rb
discourse_api-0.5.0 spec/discourse_api/api/params_spec.rb
discourse_api-0.4.4 spec/discourse_api/api/params_spec.rb
discourse_api-0.4.3 spec/discourse_api/api/params_spec.rb
discourse_api-0.4.2 spec/discourse_api/api/params_spec.rb
discourse_api-0.4.1 spec/discourse_api/api/params_spec.rb
discourse_api-0.4.0 spec/discourse_api/api/params_spec.rb
discourse_api-0.3.6 spec/discourse_api/api/params_spec.rb