Sha256: 373b1128c6ee002c1e52cd3deca1a7b718d9eeab819ba2cc5c15a14531734467

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe "has_many" do
  describe_example "has_many/simple" do
    it 'parses properly' do
      @root.id.should == 123
      @root.login.should == 'jackiechan2010'
    end

    describe "#resource" do
      subject {@root.resource}

      it 'has a link' do
        subject[:link].should be_an(Array)
      end

      [:services, :billing, :devops].each do |rel|
        it "has a #{rel} relation" do
          subject[:link].any? {|l| l[:rel] == rel}.should be_true
        end

        it "has a href for #{rel} relation" do
          link = subject[:link].find {|l| l[:rel] == rel}
          link[:href].should =~ %r{/customers/123/#{rel}}
        end
      end
    end
  end

  describe_example "has_many/href_options" do
    it 'parses properly' do
      @root.id.should == 123
      @root.login.should == 'jackiechan2010'
    end

    describe "#resource" do
      subject {@root.resource}

      it 'has a link' do
        subject[:link].should be_an(Array)
      end

      it "has a services relation" do
        subject[:link].any? {|l| l[:rel] == :services}.should be_true
      end

      it "has a href for services relation" do
        link = subject[:link].find {|l| l[:rel] == :services}
        link[:href].should =~ %r{http://external.service.com/customers/123/services}
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rest_model-0.3.1 spec/integration/has_many_spec.rb
rest_model-0.3.0 spec/integration/has_many_spec.rb
rest_model-0.2.3 spec/integration/has_many_spec.rb
rest_model-0.2.1 spec/integration/has_many_spec.rb
rest_model-0.2.0 spec/integration/has_many_spec.rb
rest_model-0.1.24 spec/integration/has_many_spec.rb
rest_model-0.1.23 spec/integration/has_many_spec.rb
rest_model-0.1.22 spec/integration/has_many_spec.rb
rest_model-0.1.21 spec/integration/has_many_spec.rb
rest_model-0.1.20 spec/integration/has_many_spec.rb
rest_model-0.1.19 spec/integration/has_many_spec.rb
rest_model-0.1.18 spec/integration/has_many_spec.rb
rest_model-0.1.17 spec/integration/has_many_spec.rb
rest_model-0.1.16 spec/integration/has_many_spec.rb
rest_model-0.1.15 spec/integration/has_many_spec.rb
rest_model-0.1.14 spec/integration/has_many_spec.rb