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
test_track_rails_client-2.0.0 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-1.3.0 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-1.2.0 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-1.1.0 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-1.0.0 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.20 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.19 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.18 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.17 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.16 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.15 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.14 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.13 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.12 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.11 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.10 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.9 vendor/gems/her/spec/model_spec.rb
test_track_rails_client-0.9.8 vendor/gems/her/spec/model_spec.rb
her-0.8.1 spec/model_spec.rb
her-0.7.6 spec/model_spec.rb