Sha256: 74f79abf4222e8a2f3b3ac6dac0a9baf0b17437e906ab7c59ba6f66841a6e00c

Contents?: true

Size: 1.07 KB

Versions: 46

Compression:

Stored size: 1.07 KB

Contents

require "rails_helper"

module Dorsale
  describe SmallData::Filter do
    let(:jar)    { {} }
    let(:filter) { {"name" => "bidule"} }
    let(:f)      { Dorsale::SmallData::Filter.new(jar) }

    describe "store" do
      it "should store the provided hash as json in the jar" do
        f.store(filter)
        expect(jar["filters"]).to eq filter.to_json
      end
    end

    describe "read" do
      it "should read stored filters" do
        f.store(filter)
        expect(f.read).to eq(filter)
      end
      it "should return empty hash by default" do
        expect(f.read).to eq({})
      end
      it "should return empty hash on invalid json" do
        jar["filters"] = "ce json est invalide"
        expect(f.read).to eq({})
      end
    end

    describe "get" do
      it "should return the value" do
        f.store(filter)
        expect(f.get("name")).to eq("bidule")
      end
    end

    describe "set" do
      it "should set the value" do
        f.store(filter)
        f.set("new", "truc")
        expect(f.get("new")).to eq("truc")
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
dorsale-2.3.5 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.3.4 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.3.3 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.3.2 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.3.1 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.3.0 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.16 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.15 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.14 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.13 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.12 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.11 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.10 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.9 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.8 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.6 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.5 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.4 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.3 spec/models/dorsale/small_data/filter_spec.rb
dorsale-2.2.2 spec/models/dorsale/small_data/filter_spec.rb