Sha256: 018a146cb96c686608fb6f9696de6044ead422287ae675589f746271e31629cf

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

shared_examples_for "view helpers" do |subject|
  describe "#helpers" do
    it "returns the current view context" do
      allow(Draper::ViewContext).to receive_messages current: :current_view_context
      expect(subject.helpers).to be :current_view_context
    end

    it "is aliased to #h" do
      allow(Draper::ViewContext).to receive_messages current: :current_view_context
      expect(subject.h).to be :current_view_context
    end
  end

  describe "#localize" do
    it "delegates to #helpers" do
      allow(subject).to receive(:helpers).and_return(double)
      expect(subject.helpers).to receive(:localize).with(:an_object, some: "parameter")
      subject.localize(:an_object, some: "parameter")
    end

    it "is aliased to #l" do
      allow(subject).to receive_messages helpers: double
      expect(subject.helpers).to receive(:localize).with(:an_object, some: "parameter")
      subject.l(:an_object, some: "parameter")
    end
  end

  describe ".helpers" do
    it "returns the current view context" do
      allow(Draper::ViewContext).to receive_messages current: :current_view_context
      expect(subject.class.helpers).to be :current_view_context
    end

    it "is aliased to .h" do
      allow(Draper::ViewContext).to receive(:current).and_return(:current_view_context)
      expect(subject.class.h).to be :current_view_context
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
draper-4.0.4 spec/support/shared_examples/view_helpers.rb
draper-4.0.3 spec/support/shared_examples/view_helpers.rb
draper-4.0.2 spec/support/shared_examples/view_helpers.rb
draper-4.0.1 spec/support/shared_examples/view_helpers.rb
draper-4.0.0 spec/support/shared_examples/view_helpers.rb
draper-3.1.0 spec/support/shared_examples/view_helpers.rb
draper-3.0.1 spec/support/shared_examples/view_helpers.rb
draper-3.0.0 spec/support/shared_examples/view_helpers.rb