Capybara DSL for fast and easy testing Active Admin applications.
Check out our docs at activeadmin-plugins.github.io/capybara_active_admin
Add this line to your application's Gemfile:
group:testdogem'capybara_active_admin'endAnd then execute:
$ bundle install
Or install it yourself as:
$ gem install capybara_active_admin
Note: capybara_active_admin should be required after capybara.
rails_helper.rb
require'capybara/active_admin/rspec'spec/system/users_spec.rb
RSpec.describe'Users',js: truedosubjectdovisitadmin_users_pathendlet!(:john){User.create!(full_name: 'John Doe')}let!(:jane){User.create!(full_name: 'Jane Air')}it'have john and jane in users table'dosubjectexpect(page).tohave_action_item('New User')expect(page).to_nothave_action_item('Edit User')within_table_for('users')doexpect(page).tohave_table_row(count: 2)expect(page).tohave_table_cell('John Doe')within_table_row(id: john.id)doexpect(page).tohave_table_cell('John Doe',row_id: john.id)expect(page).tohave_table_cell('John Doe',row_id: john.id,col_name: 'Full Name')expect(page).to_nothave_table_cell('John Doe',row_id: john.id,col_name: 'Id')endwithin_table_row(id: jane.id)doexpect(page).to_nothave_table_cell('John Doe')expect(page).to_nothave_table_cell('John Doe',col_name: 'Full Name')endendendit'creates user'dosubjectclick_action_item('New User')expect(page).tohave_current_path(new_admin_user_path)within_form_for(User)dofill_in'Full name',with: 'Johny Cage'click_submit'Create User'endexpect(page).tohave_flash_message('User was successfully created.',type: :notice)user=User.last!expect(page).tohave_current_pathadmin_user_path(user.id)expect(User.count).toeq(1)expect(user).tohave_attributes(full_name: 'Johny Cage')endendSee spec/support for more user examples.
See capybara/active_admin/test_helpers.rb for available DSL methods.
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/activeadmin-plugins/capybara_active_admin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Capybara::ActiveAdmin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Project uses Keep a Changelog convention. Project adheres to Semantic Versioning.