Sha256: 3ec494ce5343cce2c4bf826438289e4d11a09b8ffce6b9b93aec3f2d332bdc67

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 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::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::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

14 entries across 14 versions & 1 rubygems

Version Path
card-1.17.4 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.17.3 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.17.2 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.17.1 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.17.0 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.15 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.14 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.13 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.12 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.11 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.10 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.9 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.8 mod/02_basic_types/spec/set/all/json_spec.rb
card-1.16.7 mod/02_basic_types/spec/set/all/json_spec.rb