
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
We love Capybara! We think it's a great interface for testing Ruby web applications. But there are some pain points with the developer experience of using Capybara. We created this gem to address some of those pain points and added a few niceties along the way.
Problems with/unsolved by vanilla Capybara:
Capybara::Experience has a few core concepts:
Add this line to your application's Gemfile:
gem 'capybara-experience'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capybara-experience
This scenario is for your standard user/admin.
# spec/support/experiences/user_experience.rb
class UserExperience < Capybara::Experience
include Rails.application.routes.url_helpers
def login(user)
@user = user
login_as user, scope: :user
visit '/'
assert_text "#{@user.name} Welcome!"
self
end
private
attr_reader :user
end
# spec/support/experiences/user_experience.rb
class AdminExperience < Capybara::Experience
def initialize(*args)
super
end
def login(user)
@user = user
login_as user, scope: :admin
visit '/admin/login'
assert_text "Home"
end
private
attr_reader :user
end
# spec/support/capabilities/sign_up.rb
module Capabilities::SignUp
def navigate_to_sign_up
click_link "Sign Up"
end
def sign_up(email: , password: "password")
fill_in "email", with: email
fill_in "password", with: password
fill_in "password_confirmation", with: password
click_button "Submit"
assert_text "Welcome #{email}"
end
end
# spec/features/sign_up_flow_spec.rb
RSpec.describe "sign up flow", feature: true do
let(:guest_experience) { GuestExperience.new.extend(Capabilities::SignUp) }
let(:admin_experience) { AdminExperience.new.extend(Capabilities::Admin::ManageUser) }
it "works" do
behavior "user can sign up" do # behaviors are an added DSL by capybara-experiences to group interactions & assertions
guest_ux = GuestExperience.new
guest_ux.navigate_to_sign_up
guest_ux.sign_up(
email: "user@example.com"
)
expect(guest_ux).to have_content "user@example.com"
expect(guest_ux).to_not have_content "Login"
end
behavior "admin can see user" do
admin_ux = AdminExperience.new
admin_ux.login
admin_ux.to have_content "user@example.com"
end
end
end
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/ryanong/capybara-experience.
FAQs
Unknown package
We found that capybara-experience demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.