Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a testing example. #21

Open
andrewculver opened this issue Oct 11, 2021 · 0 comments
Open

Need a testing example. #21

andrewculver opened this issue Oct 11, 2021 · 0 comments

Comments

@andrewculver
Copy link
Contributor

andrewculver commented Oct 11, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant