Sha256: fae6e6781e264341a9bb395d4c7c646a4137d4d462ee02fadc2fadc6ce754af1

Contents?: true

Size: 1.03 KB

Versions: 44

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Her::Model do
  before do
    Her::API.setup :url => "https://api.example.com" do |connection|
      connection.use Her::Middleware::FirstLevelParseJSON
      connection.adapter :test do |stub|
        stub.get("/users/1") { |env| [200, {}, { :id => 1, :name => "Tobias Fünke" }.to_json] }
        stub.get("/users/1/comments") { |env| [200, {}, [{ :id => 4, :body => "They're having a FIRESALE?" }].to_json] }
      end
    end

    spawn_model("Foo::User") { has_many :comments }
    spawn_model("Foo::Comment")
  end
  subject { Foo::User.find(1) }

  describe :has_key? do
    it { should_not have_key(:unknown_method_for_a_user) }
    it { should_not have_key(:unknown_method_for_a_user) }
    it { should have_key(:name) }
    it { should have_key(:comments) }
  end

  describe :[] do
    it { should_not have_key(:unknown_method_for_a_user) }
    specify { subject[:name].should == "Tobias Fünke" }
    specify { subject[:comments].first.body.should == "They're having a FIRESALE?" }
  end
end

Version data entries

44 entries across 44 versions & 4 rubygems

Version Path
her-0.7.5 spec/model_spec.rb
her-0.7.4 spec/model_spec.rb
herr-0.7.3 spec/model_spec.rb
her-0.7.3 spec/model_spec.rb
her-0.7.2 spec/model_spec.rb
her-0.7.1 spec/model_spec.rb
her-0.7 spec/model_spec.rb
her-0.6.8 spec/model_spec.rb
her-0.6.7 spec/model_spec.rb
her-0.6.6 spec/model_spec.rb
her-0.6.5 spec/model_spec.rb
her-0.6.4 spec/model_spec.rb
her-0.6.3 spec/model_spec.rb
her-0.6.2 spec/model_spec.rb
her-0.6.1 spec/model_spec.rb
her-0.6 spec/model_spec.rb
her-0.5.5 spec/model_spec.rb
her-0.5.4 spec/model_spec.rb
her-0.5.3 spec/model_spec.rb
her-0.5.2 spec/model_spec.rb