Sha256: cefde76e52dcd8a303e6fcaee99fe5754d892537ad90e0d3d66f1ed0f29be5ce

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

# -*- encoding : utf-8 -*-

describe Card::Set::All::Json, "JSON mod" do
  context "status view" do
    it "should handle real and virtual cards" do
      jf = Card::Format::JsonFormat
      real_json = jf.new(Card["T"]).show :status, {}
      expect(JSON[real_json]).to eq(
        "key" => "t", "status" => "real", "id" => Card["T"].id, "url_key" => "T"
      )
      virtual_json = jf.new(Card.fetch("T+*self")).show :status, {}
      expect(JSON[virtual_json]).to eq(
        "key" => "t+*self", "status" => "virtual", "url_key" => "T+*self"
      )
    end

    it "should treat both unknown and unreadable cards as unknown" do
      Card::Auth.as Card::AnonymousID do
        jf = Card::Format::JsonFormat

        unknown = Card.new name: "sump"
        unreadable = Card.new name: "kumq", type: "Fruit"
        unknown_json = jf.new(unknown).show :status, {}
        expect(JSON[unknown_json]).to eq(
          "key" => "sump", "status" => "unknown", "url_key" => "sump"
        )
        unreadable_json = jf.new(unreadable).show :status, {}
        expect(JSON[unreadable_json]).to eq(
          "key" => "kumq", "status" => "unknown", "url_key" => "kumq"
        )
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
card-1.19.6 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.5 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.4 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.3 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.2 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.1 mod/basic_formats/spec/set/all/json_spec.rb
card-1.19.0 mod/basic_types/spec/set/all/json_spec.rb