Sha256: 45b5ebaf2783fcc22b829e4be62e9a4d499d90600b53f6ff3398240df6ee70ea

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

require 'spec_helper'

describe Vienna::Model do
  describe "#as_json" do
    let(:model) { User.new }

    it "returns a hash" do
      expect(model.as_json).to be_kind_of(Hash)
    end

    it "contains all attributes on model" do
      expect(model.as_json).to eq({ "foo" => nil, "bar" => nil, "baz" => nil })

      model.foo = "Adam"
      expect(model.as_json).to eq({ "foo" => "Adam", "bar" => nil, "baz" => nil })

      model.bar = "Beynon"

      expect(model.as_json).to eq({ "foo" => "Adam", "bar" => "Beynon", "baz" => nil })
    end

    it "includes the id, if set" do
      model.id = 42

      expect(model.as_json).to eq({ "id" => 42, "foo" => nil, "bar" => nil, "baz" => nil })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-vienna-0.7.0 spec/model/as_json_spec.rb