Sha256: dd4a5e773b5ae4222e14524642f3ee6b1b150a98a069566f0d5da3b3abb1f4f5

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'fast_spec_helper'

require 'active_model/naming'
require_relative '../app/presenters/post_presenter'

StrongPresenter::ViewContext.test_strategy :fast

Post = Struct.new(:id) { extend ActiveModel::Naming }

describe PostPresenter do
  let(:presenter) { PostPresenter.new(object) }
  let(:object) { Post.new(42) }

  it "can use built-in helpers" do
    expect(presenter.truncated).to eq "Once upon a..."
  end

  it "can use built-in private helpers" do
    expect(presenter.html_escaped).to eq "<script>danger</script>"
  end

  it "can't use user-defined helpers from app/helpers" do
    expect{presenter.hello_world}.to raise_error NoMethodError, /hello_world/
  end

  it "can't use path helpers" do
    expect{presenter.path_with_model}.to raise_error NoMethodError, /post_path/
  end

  it "can't use url helpers" do
    expect{presenter.url_with_model}.to raise_error NoMethodError, /post_url/
  end

  it "can't be passed implicitly to url_for" do
    expect{presenter.link}.to raise_error
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
strong_presenter-0.2.2 spec/dummy/fast_spec/post_presenter_spec.rb
strong_presenter-0.2.1 spec/dummy/fast_spec/post_presenter_spec.rb
strong_presenter-0.2.0 spec/dummy/fast_spec/post_presenter_spec.rb
strong_presenter-0.1.0 spec/dummy/fast_spec/post_presenter_spec.rb