Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

test_selector

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test_selector

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TestSelector

Based on TestSelector for Elixir, a gem that adds a test-selector to the HTML so it can be found in the tests.

Usage

After installing this gem the views have a helper method test_selector that can be used as:

<!--- app/views/some/view.erb --->
<p <%= test_selector "description", 1 %>the description of entity 1</p>

<p <%= test_selector "description", 2 %>the description of entity 2</p>

That will result in:

<p test-selector="_app_views_some_view_erb__description" test-value="1">the description of entity 1</p>

<p test-selector="_app_views_some_view_erb__description" test-value="2">the description of entity 2</p>

In the test this can be found with:

it "assert the second description" do
  ... # some setup

  test_part = test_selector(path, "description", 1)
  expect(find_test_selector page.body, test_part).to have_content "the description of entity 2"
end

Installation

Add this line to your application's Gemfile:

  • Dependencie: Rails

Add to the Gemfile

gem 'test_selector'

Execute:

$ bundle

include in the test framework you're using, for RSpec:

require 'test_selector'

RSpec.configure do |config|
  ...

  config.include TestSelector::TestHelpers
end

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc