Sha256: b8cb201c4c9464503b0e4dd5caad6b118fd90ea0f75ae4b5b96bd27438633128

Contents?: true

Size: 987 Bytes

Versions: 2

Compression:

Stored size: 987 Bytes

Contents

# encoding: utf-8
require File.join(File.dirname(__FILE__), "../spec_helper.rb")

describe Her::Model::Introspection do
  context "introspecting a resource" do
    before do # {{{
      Her::API.setup :base_uri => "https://api.example.com"
      FakeWeb.register_uri(:get, "https://api.example.com/users/1", :body => { :data => { :id => 1, :name => "Tobias Fünke" } }.to_json)
      Object.instance_eval { remove_const :User } if Object.const_defined?(:User)
      class User
        include Her::Model
      end
    end # }}}

    describe "#inspect" do
      it "outputs resource attributs for an existing resource" do # {{{
        @user = User.find(1)
        @user.inspect.should == "#<User(users/1) id=1 name=\"Tobias Fünke\">"
      end # }}}

      it "outputs resource attributs for an not-saved-yet resource" do # {{{
        @user = User.new(:name => "Tobias Fünke")
        @user.inspect.should == "#<User(users) name=\"Tobias Fünke\">"
      end # }}}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
her-0.1.8.1 spec/model/introspection_spec.rb
her-0.1.8 spec/model/introspection_spec.rb