Sha256: d0efdff39befbabfd3ed6573d084ad6bf45df3fceac6a800473063d99d4983c5

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'roar_extensions'

module RoarExtensions
  describe LinkPresenter do
    subject { LinkPresenter.new('search_engine', 'http://google.com') }

    describe "#==" do
      it "returns true if href, rel, and title match" do
        subject.should == LinkPresenter.new('search_engine', 'http://google.com')
      end

      it "returns false if href, rel, or title differ" do
        subject.should_not == LinkPresenter.new('search_engine', 'http://bing.com')
        subject.should_not == LinkPresenter.new('weee', 'http://google.com')
        subject.should_not == LinkPresenter.new('search_engine', 'http://google.com', 'cows')
      end
    end

    context "no title" do
      its(:as_json) do
        should == { 'search_engine' => {'href' => 'http://google.com'} }
      end

      it "aliases to_hash to as_json" do
        subject.to_hash.should == subject.as_json
      end
    end

    context "title given" do
      subject { LinkPresenter.new('search_engine',
                                  'http://google.com',
                                  'Cool Search') }
      its(:as_json) do
        should == {
          'search_engine' => {
            'href'  => 'http://google.com',
            'title' => 'Cool Search'
          }
        }
      end

      it "aliases to_hash to as_json" do
        subject.to_hash.should == subject.as_json
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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