Sha256: afcad33e95a225348f7258b87ea57b955db96f71f0184efe8cd866aae8bca62f

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

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

    it "is aliased to #h" do
      StrongPresenter::ViewContext.stub current: :current_view_context
      expect(subject.h).to be :current_view_context
    end
  end

  describe "#localize" do
    it "delegates to #helpers" do
      subject.stub helpers: double
      subject.helpers.should_receive(:localize).with(:an_object, some: "parameter")
      subject.localize(:an_object, some: "parameter")
    end

    it "is aliased to #l" do
      subject.stub helpers: double
      subject.helpers.should_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
      StrongPresenter::ViewContext.stub current: :current_view_context
      expect(subject.class.helpers).to be :current_view_context
    end

    it "is aliased to .h" do
      StrongPresenter::ViewContext.stub current: :current_view_context
      expect(subject.class.h).to be :current_view_context
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strong_presenter-0.2.2 spec/support/shared_examples/view_helpers.rb
strong_presenter-0.2.1 spec/support/shared_examples/view_helpers.rb
strong_presenter-0.2.0 spec/support/shared_examples/view_helpers.rb