Skip to content

Need a testing example. #21

@andrewculver

Description

@andrewculver

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions