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

New testing module #774

Merged
merged 1 commit into from
Sep 7, 2024
Merged

New testing module #774

merged 1 commit into from
Sep 7, 2024

Conversation

joeldrapper
Copy link
Collaborator

Introducing a new testing module to replace the external gems phlex-testing-capybara and phlex-testing-nokogiri.

Comment on lines +9 to +17
if defined?(Minitest::Test) && Minitest::Test > mod
require "capybara/minitest"
include Capybara::Minitest::Assertions
end

if defined?(RSpec::Core::ExampleGroup) && RSpec::Core::ExampleGroup > mod
require "capybara/rspec"
include Capybara::RSpecMatchers
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically detect which testing framework you’re using an include relevant matchers / assertions.

Comment on lines +20 to +21
attr_reader :page
alias_method :component, :page
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have page for the built in capybara matchers, but you may want to refer to it as component.

Comment on lines +8 to +18
def render_fragment(...)
::Nokogiri::HTML5.fragment(
render_to_string(...),
)
end

def render_document(...)
::Nokogiri::HTML5(
render_to_string(...),
)
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Nokogiri and Nokolexbor, you need to specify if you’re rendering a document or a fragment.

@joeldrapper joeldrapper merged commit ceffded into main Sep 7, 2024
5 of 8 checks passed
@joeldrapper joeldrapper deleted the new-testing-module branch September 7, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant