Sha256: a3527c28cf5b93a88196bcd9fc89043e0db60e7dc5a9e1c012929930bf8654b3

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Draper::ViewHelpers do
  subject(:view_helpers_class) { Class.new { include Draper::ViewHelpers } }

  let(:view_helpers) { view_helpers_class.new }
  let(:helper_proxy) { Draper::HelperProxy.new }
  let(:view_context) { Object.new }

  before { view_helpers.helpers.stub(:view_context).and_return(view_context) }

  describe "#helpers" do
    it "returns a HelperProxy" do
      view_helpers.helpers.should be_a Draper::HelperProxy
    end

    it "is aliased to #h" do
      view_helpers.h.should be view_helpers_class.helpers
    end
  end

  it "delegates #localize to #helpers" do
    view_context.should_receive(:localize).with(Date.new)
    view_helpers.localize(Date.new)
  end

  it "aliases #l to #localize" do
    view_context.should_receive(:localize).with(Date.new)
    view_helpers.l(Date.new)
  end

  describe ".helpers" do
    it "returns a HelperProxy" do
      view_helpers_class.helpers.should be_a Draper::HelperProxy
    end

    it "is aliased to #h" do
      view_helpers_class.h.should be view_helpers_class.helpers
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
draper-1.0.0 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta6 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta5 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta4 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta3 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta2 spec/draper/view_helpers_spec.rb
draper-1.0.0.beta1 spec/draper/view_helpers_spec.rb