Sha256: 924758f71c58011d5a0a44193fdb184ca8f3ff803a8483f216f81763e8996896

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

require 'test_helper'

class MountainView::ComponentHelperTest < ActionView::TestCase
  test "renders the proper component" do
    rendered = render_component("header", id: 1, title: "Pepe")

    expected = /Pepe/

    assert_match expected, rendered
    assert_match %r(href=\"\/products\/1\"), rendered
  end

  test "renders when passed a block" do
    rendered = render_component("yielder") do
      "I appear to be in a block"
    end

    expected = /<div class=\"yield-here\">\n    I appear to be in a block\n  <\/div>/
    assert_match expected, rendered
    assert_match /Tell me about the Proc/, rendered
  end

  test "Does not override passed yield property with block" do
    rendered = render_component("yielder", yield: "It is me in the block") do
      "I appear to be in a block"
    end

    expected = /<div class=\"yield-here\">\n    It is me in the block\n  <\/div>/
    assert_match expected, rendered
    assert_match /Tell me about the Proc/, rendered
  end

  test "renders when has a yield, but no block passed" do
    rendered = render_component("yielder")

    assert_match /Tell me about the Proc/, rendered
  end

  test "renders a component within a compontent" do
    rendered = render_component("yielder") do
      render_component("header", id: 1, title: "Pepe")
    end

    assert_match /Pepe/, rendered
    assert_match %r(href=\"\/products\/1\"), rendered
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mountain_view-0.12.3 test/helpers/mountain_view/component_helper_test.rb
mountain_view-0.12.2 test/helpers/mountain_view/component_helper_test.rb
mountain_view-0.12.1 test/helpers/mountain_view/component_helper_test.rb
mountain_view-0.12.0 test/helpers/mountain_view/component_helper_test.rb
mountain_view-0.11.0 test/helpers/mountain_view/component_helper_test.rb