capybara_active_admin 0.3.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -0
- data/README.md +74 -7
- data/lib/capybara/active_admin/actions/form.rb +1 -1
- data/lib/capybara/active_admin/actions/layout.rb +3 -3
- data/lib/capybara/active_admin/actions/table.rb +12 -0
- data/lib/capybara/active_admin/finders/form.rb +7 -0
- data/lib/capybara/active_admin/finders/layout.rb +18 -7
- data/lib/capybara/active_admin/finders/table.rb +17 -0
- data/lib/capybara/active_admin/matchers/attributes_table.rb +2 -2
- data/lib/capybara/active_admin/matchers/form.rb +42 -7
- data/lib/capybara/active_admin/matchers/layout.rb +33 -7
- data/lib/capybara/active_admin/matchers/table.rb +39 -3
- data/lib/capybara/active_admin/selectors/attributes_table.rb +3 -1
- data/lib/capybara/active_admin/selectors/form.rb +7 -1
- data/lib/capybara/active_admin/selectors/table.rb +30 -5
- data/lib/capybara/active_admin/util.rb +41 -4
- data/lib/capybara/active_admin/version.rb +1 -1
- metadata +12 -26
- data/.gitignore +0 -20
- data/.rspec +0 -3
- data/.rubocop.yml +0 -82
- data/.travis.yml +0 -45
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -23
- data/Rakefile +0 -18
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/capybara_active_admin.gemspec +0 -33
- data/docs/.vuepress/config.js +0 -12
- data/docs/.vuepress/public/.keep +0 -0
- data/docs/.vuepress/styles/index.styl +0 -3
- data/docs/README.md +0 -41
- data/docs/guide/README.md +0 -113
- data/package.json +0 -9
- data/yarn.lock +0 -7947
data/docs/guide/README.md
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# Introduction
|
|
2
|
-
|
|
3
|
-
<Bit/>
|
|
4
|
-
|
|
5
|
-
`Capybara::ActiveAdmin` created to write tests as fast as `ActiveAdmin` resource which they are test.
|
|
6
|
-
|
|
7
|
-
## Getting Started
|
|
8
|
-
|
|
9
|
-
### Installation
|
|
10
|
-
|
|
11
|
-
```ruby
|
|
12
|
-
# Gemfile
|
|
13
|
-
|
|
14
|
-
gem 'capybara_active_admin', group: :test, require: false
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
```ruby
|
|
18
|
-
# spec/rails_helper.rb
|
|
19
|
-
|
|
20
|
-
# after require 'rspec' or 'rspec/rails'
|
|
21
|
-
require 'capybara/active_admin/rspec'
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Usage
|
|
25
|
-
|
|
26
|
-
For example we have such database table
|
|
27
|
-
```ruby
|
|
28
|
-
create_table :users do |t|
|
|
29
|
-
t.string :full_name
|
|
30
|
-
t.timestamps
|
|
31
|
-
end
|
|
32
|
-
```
|
|
33
|
-
And such `ActiveRecord` model
|
|
34
|
-
```ruby
|
|
35
|
-
class User < ActiveRecord::Base
|
|
36
|
-
validates :full_name, presence: true
|
|
37
|
-
end
|
|
38
|
-
```
|
|
39
|
-
And there is our `ActiveAdmin` resource
|
|
40
|
-
```ruby
|
|
41
|
-
ActiveAdmin.register User do
|
|
42
|
-
permit_params :full_name
|
|
43
|
-
end
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Our test can look like below
|
|
47
|
-
```ruby
|
|
48
|
-
# spec/system/users_spec.rb
|
|
49
|
-
|
|
50
|
-
RSpec.describe 'Users' do
|
|
51
|
-
|
|
52
|
-
describe 'index page' do
|
|
53
|
-
subject do
|
|
54
|
-
visit admin_users_path
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'have no table' do
|
|
58
|
-
subject
|
|
59
|
-
|
|
60
|
-
expect(page).to have_text('There are no Users yet.')
|
|
61
|
-
expect(page).to have_action_item('New User')
|
|
62
|
-
expect(page).to_not have_action_item('Edit User')
|
|
63
|
-
expect(page).to_not have_table
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context 'with users' do
|
|
67
|
-
let!(:users) do
|
|
68
|
-
[
|
|
69
|
-
User.create!(full_name: 'John Doe'),
|
|
70
|
-
User.create!(full_name: 'Jane Air')
|
|
71
|
-
]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'have correct table rows' do
|
|
75
|
-
subject
|
|
76
|
-
|
|
77
|
-
# you can check that table is visible on page
|
|
78
|
-
expect(page).to have_table
|
|
79
|
-
|
|
80
|
-
# checkout data within table,
|
|
81
|
-
# same as `within(table_selector) do`
|
|
82
|
-
within_table_for do
|
|
83
|
-
# check how many rows in table (tr)
|
|
84
|
-
expect(page).to have_table_row(count: 2)
|
|
85
|
-
# or cells (td)
|
|
86
|
-
expect(page).to have_table_cell(count: 10)
|
|
87
|
-
# or check cell of specific column contain specific value,
|
|
88
|
-
# accepts same options as `have_selector`, such as :text, :exact_text, :count, etc.
|
|
89
|
-
expect(page).to have_table_cell(text: 'John Doe', column: 'Full Name')
|
|
90
|
-
|
|
91
|
-
# we can check data inside specific row by record id,
|
|
92
|
-
# or we can find it by index in table `within_table_row(index: 0) do`.
|
|
93
|
-
within_table_row(id: users.first.id) do
|
|
94
|
-
# default columns for users table are id, full_name, created_at, updated_at, actions.
|
|
95
|
-
expect(page).to have_table_cell(count: 5)
|
|
96
|
-
expect(page).to have_table_cell(text: 'John Doe')
|
|
97
|
-
# or you can write
|
|
98
|
-
expect(page).to have_table_cell(text: 'John Doe', column: 'Full Name')
|
|
99
|
-
# negate matcher
|
|
100
|
-
expect(page).to_not have_table_cell(text: 'John Doe', column: 'Id')
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
within_table_row(id: users.second.id) do
|
|
104
|
-
expect(page).to have_table_cell(text: users.second.id, column: 'Id')
|
|
105
|
-
expect(page).to have_table_cell(text: 'Jane Air', column: 'Full Name')
|
|
106
|
-
expect(page).to_not have_table_cell(text: 'John Doe')
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
```
|