Sha256: d79a97662c563dcbe7970f47d169b4bf56df9ef45cd9b9d98af184d219a7d00a

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 KB

Contents

require "spec_helper"

describe Rack::API::Runner, "Settings" do
  it "uses global namespace when no version is defined" do
    subject.set :foo, :bar
    subject.settings[:global][:foo].should == :bar
  end

  it "uses local namespace when version is defined" do
    subject.settings[:version] = "v1"
    subject.set :foo, :bar

    subject.settings[:foo].should == :bar
  end

  it "appends item when mode is :append" do
    subject.settings[:global][:list] = []
    subject.set :list, :item, :append

    subject.settings[:global][:list].should == [:item]
  end

  it "overrides item when mode is :override" do
    subject.settings[:global][:list] = []
    subject.set :list, [:item], :override

    subject.settings[:global][:list].should == [:item]
  end

  it "returns global value" do
    subject.set :name, "John Doe"
    subject.option(:name).should == "John Doe"
  end

  it "returns local value" do
    subject.settings[:version] = "v1"
    subject.set :name, "John Doe"

    subject.option(:name).should == "John Doe"
  end

  it "prefers local setting over global one" do
    subject.set :name, "Mary Doe"

    subject.settings[:version] = "v1"
    subject.set :name, "John Doe"

    subject.option(:name).should == "John Doe"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rack-api-1.1.0 spec/rack-api/settings_spec.rb
rack-api-1.0.2 spec/rack-api/settings_spec.rb
rack-api-1.0.1 spec/rack-api/settings_spec.rb
rack-api-1.0.0 spec/rack-api/settings_spec.rb
rack-api-0.3.1 spec/rack-api/settings_spec.rb
rack-api-0.3.0 spec/rack-api/settings_spec.rb
rack-api-0.2.2 spec/rack-api/settings_spec.rb
rack-api-0.2.1 spec/rack-api/settings_spec.rb
rack-api-0.2.0 spec/rack-api/settings_spec.rb
rack-api-0.1.2 spec/rack-api/settings_spec.rb
rack-api-0.1.1 spec/rack-api/settings_spec.rb