Sha256: a544a540638ff3409ad5f21c043a9353e7919cb9e3fb1d78f25be31a9fd4fc5e

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe NavLinks::ViewHelpers do
  describe '#nav_links' do
    let(:link_generator) do
      lg = double("LinkGenerator")
      lg.stub(:to_html => true)
      lg
    end

    before { helper.stub(:request => :request) }

    it 'does nothing when called without options' do
      NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
        .and_return(link_generator)

      helper.nav_links do |nav|
        nav.link_to("My Title", "/path")
      end
    end

    it 'supports the deprecated method name with nav_ prefix' do
      NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
        .and_return(link_generator)

      helper.nav_links do |nav|
        nav.nav_link_to("My Title", "/path")
      end
    end

    it 'applies the options to links created inside' do
      NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :bar})
        .and_return(link_generator)

      helper.nav_links foo: :bar do |nav|
        nav.link_to("My Title", "/path")
      end
    end

    it 'lets the options be overridden by individual calls' do
      NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :baz})
        .and_return(link_generator)

      helper.nav_links foo: :bar do |nav|
        nav.link_to("My Title", "/path", {}, {foo: :baz})
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nav_links-1.1.1 spec/helpers/nav_links_spec.rb
nav_links-1.1.0 spec/helpers/nav_links_spec.rb