bullet-train-co/nice_partials

Need a testing example.

andrewculver opened this issue · 0 comments

I thought we had one, but we need to provide an example of how you can use Minitest + Nokogiri to test partials. While we're at it, we should just provide some library support for it so you can do the following:

class BoxPartialTest < NicePartials::TestCase
  test "title renders like you'd expect it to" do
    # Returns a Nokogiri::HTML() result.
    body = render <<-ERB
      <%= render 'account/shared/page', here: test, current_user: @user do |p| %>
        <% p.content_for :title, "Titles are great" %>
      <% end %>
    ERB

    assert_equal body.css('h3').text, "Titles are great"
  end
end