Sha256: 189f138270e1fa155b67f4757b3ae66350ec12173a1083462295e4640fae6cb7

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe StatefulLink::Helper do
  before(:each) do
    ActionView::Base.send(:include, StatefulLink::ActionAnyOf)
    controller.controller_path = 'foos'
    controller.action_name = 'bar'
  end    

  it "should generate stateful links" do
    helper.stateful_link_to(
      "foos#bar",
      :active => "1",
      :inactive => "2",
      :chosen => "3"
    ).should == "1"

    helper.stateful_link_to(
      "bars#foo",
      ["foos#bar", "foobars#*"],
      :active => "1",
      :inactive => "2",
      :chosen => proc { root_path }
    ).should == root_path

    # Check for controller#*
    helper.stateful_link_to(
      "bars#foo",
      ["foos#trala", "foos#*"],
      :active => "1",
      :inactive => "2",
      :chosen => "3"
    ).should == "3"
    
    helper.stateful_link_to(
      :active => "1",
      :inactive => "2",
      :chosen => "3",
      :state => proc { :active }
    ).should == "1"

    helper.stateful_link_to(
      :active => "1",
      :inactive => "2",
      :chosen => "3",
      :state => proc { false }
    ).should == "2"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stateful_link-0.0.8 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.7 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.6 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.5 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.4 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.3 spec/helpers/stateful_link_spec.rb
stateful_link-0.0.2 spec/helpers/stateful_link_spec.rb