Sha256: 1c81627b7069f28ab03de3f94b9b1762c8e46b26512912e459e88ed7659dda72

Contents?: true

Size: 794 Bytes

Versions: 11

Compression:

Stored size: 794 Bytes

Contents

require_relative '../spec_helper'

describe RestfulResource::Associations do
  describe "#has_many" do
    it "should add a method to access nested resource" do
      make = Make.new({
        name: 'Volkswagen',
        models:
          [
            {name: 'Golf', rrp: 1000},
            {name: 'Passat', rrp: 3000}
          ]
      })

      expect(make.models.first.name).to eq 'Golf'
      expect(make.models.last.name).to eq 'Passat'
      expect(make.models.first.rrp).to eq 1000
      expect(make.models.last.rrp).to eq 3000
    end
  end

  describe "#has_one" do
    it "should add a method to access nested resource" do
      model = Model.new({
        name: 'Golf',
        make: {name: 'Volkswagen'}
      })

      expect(model.make.name).to eq 'Volkswagen'
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restful_resource-0.8.10 spec/restful_resource/associations_spec.rb
restful_resource-0.8.9 spec/restful_resource/associations_spec.rb
restful_resource-0.8.8 spec/restful_resource/associations_spec.rb
restful_resource-0.8.7 spec/restful_resource/associations_spec.rb
restful_resource-0.8.6 spec/restful_resource/associations_spec.rb
restful_resource-0.8.5 spec/restful_resource/associations_spec.rb
restful_resource-0.8.4 spec/restful_resource/associations_spec.rb
restful_resource-0.8.3 spec/restful_resource/associations_spec.rb
restful_resource-0.8.2 spec/restful_resource/associations_spec.rb
restful_resource-0.8.1 spec/restful_resource/associations_spec.rb
restful_resource-0.8.0 spec/restful_resource/associations_spec.rb