Testing
(Other frameworks TBD.)
Testing in Rails
- In
Gemfile
, add thecapybara
gem:
group :test do
gem "capybara"
end
- In
test_helper.rb
, add the following line somewhere abovemodule ActiveSupport
:
require "phlex/rails/testing"
- Create test cases like
tests/components/my_component_test.rb
:
class Components::MyComponentTest < ActiveSupport::TestCase
include Phlex::Testing::Capybara
test "it should render a submit button" do
render Components::MyComponent.new
assert_selector "submit[name='hello_world']"
end
end