Sha256: a5dd15e333052ede3b7c8ad994fa88c6da8dde576a8e03eb93d5a9cf5ff259c1

Contents?: true

Size: 999 Bytes

Versions: 3

Compression:

Stored size: 999 Bytes

Contents

require 'spec_helper'
require 'roar_extensions'

module RoarExtensions
  describe ResourceLinks do
    class TestResourceLinks
      include ResourceLinks

      def test_merge_links(styles)
        merge_links(styles) { |style|
          {style => 'foo'}
        }
      end

      def test_resource_link_json(h)
        resource_link_json(h)
      end
    end

    subject { TestResourceLinks.new }

    describe "#merge_links" do
      it "merges all hashes for the list using the block as a builder" do
        subject.test_merge_links(['a', 'b']).
          should == {
            'a' => 'foo',
            'b' => 'foo'
          }
      end
    end

    describe "#resource_link_json" do
      it "turns a hash with keys as rels into proper link representations" do
        subject.test_resource_link_json('self' => '/foo', 'next' => '/bar').
          should == {
            'self' => { 'href' => '/foo' },
            'next' => { 'href' => '/bar' }
          }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roar-extensions-0.1.0 spec/resource_links_spec.rb
roar-extensions-0.0.4 spec/resource_links_spec.rb
roar-extensions-0.0.3 spec/resource_links_spec.rb