Sha256: 4626fe846d013c7b04188ba76615d55a829a292da3df1a7fa9c3e8af99965737

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require "spec_helper"

describe JsonSpec::Configuration do
  it "excludes id and timestamps by default" do
    JsonSpec.excluded_keys.should == ["id", "created_at", "updated_at"]
  end

  it "excludes custom keys" do
    JsonSpec.exclude_keys("token")
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "excludes custom keys via setter" do
    JsonSpec.excluded_keys = ["token"]
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "excludes custom keys via block" do
    JsonSpec.configure{|c| c.exclude_keys("token") }
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "excludes custom keys via block setter" do
    JsonSpec.configure{|c| c.excluded_keys = ["token"] }
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "excludes custom keys via instance-evaluated block" do
    JsonSpec.configure{ exclude_keys("token") }
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "ensures its excluded keys are strings" do
    JsonSpec.exclude_keys(:token)
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "ensures its excluded keys are unique" do
    JsonSpec.exclude_keys("token", :token)
    JsonSpec.excluded_keys.should == ["token"]
  end

  it "resets its excluded keys" do
    original = JsonSpec.excluded_keys

    JsonSpec.exclude_keys("token")
    JsonSpec.excluded_keys.should_not == original

    JsonSpec.reset
    JsonSpec.excluded_keys.should == original
  end

  it "resets its directory" do
    JsonSpec.directory.should be_nil

    JsonSpec.directory = "/"
    JsonSpec.directory.should_not be_nil

    JsonSpec.reset
    JsonSpec.directory.should be_nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_spec-1.1.1 spec/json_spec/configuration_spec.rb
json_spec-1.1.0 spec/json_spec/configuration_spec.rb
json_spec-1.0.3 spec/json_spec/configuration_spec.rb
json_spec-1.0.2 spec/json_spec/configuration_spec.rb
json_spec-1.0.0 spec/json_spec/configuration_spec.rb