capybara_active_admin 1.0.0 → 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 +56 -2
- data/README.md +67 -6
- data/lib/capybara/active_admin/selectors/attributes_table.rb +3 -1
- data/lib/capybara/active_admin/selectors/table.rb +11 -6
- data/lib/capybara/active_admin/util.rb +41 -4
- data/lib/capybara/active_admin/version.rb +1 -1
- metadata +1 -18
- data/.github/workflows/ci.yml +0 -88
- data/.github/workflows/codeql.yml +0 -104
- data/.gitignore +0 -21
- data/.rspec +0 -3
- data/.rubocop.yml +0 -82
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -16
- data/Rakefile +0 -8
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bafb813d42831673f3ea1a80e97e410b1dced0c55cdf4c043fbc24ff5fbcc11e
|
|
4
|
+
data.tar.gz: 6115f349a6204615861dd23f0b022c66086e72f9a054bc12a808858ac7824d38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2f006051d76bf7c4adc0d23e0098ff5ecf9703be0e11bf43d08301c06bd3770b23c85661218940c1ef60af8cad8a1306802436f6e85469ac2a7f436276559ae
|
|
7
|
+
data.tar.gz: 49557743c791ecfb6069a755771e47946ec0985627ee8c2b351bada208a38cd062ad65dff8c70f75d070f043c2cde102ff924d2ef5d5c680f20a85dad7513357
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.0.0] - 2026-10-01
|
|
10
|
+
|
|
11
|
+
Breaking: the selectors below build a different string than 1.0.0 did for the
|
|
12
|
+
same input, so a suite that passed on 1.0.0 can fail on this version without
|
|
13
|
+
changing a line.
|
|
14
|
+
|
|
15
|
+
### Migrating from 1.0.0
|
|
16
|
+
|
|
17
|
+
- If you wrote a helper that normalized labels before handing them to
|
|
18
|
+
`table_cell_selector` / `table_header_selector` / `attributes_row_selector`,
|
|
19
|
+
delete it. The gem now makes the same `parameterize(separator: '_')` call
|
|
20
|
+
ActiveAdmin makes, so normalizing twice corrupts the result — the second
|
|
21
|
+
pass strips the `_` the first one inserted.
|
|
22
|
+
- Labels with no Latin-transliterable characters (`'Имя'`, `'名前'`, `'№'`)
|
|
23
|
+
now raise instead of silently matching every such row. Match on text, or
|
|
24
|
+
pass the attribute name.
|
|
25
|
+
- Rails 7.2 is no longer tested.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- `attributes_table_selector`, `form_selector` and `table_selector` now ask the
|
|
29
|
+
model for its DOM name (`model_name.singular` / `.plural`, the same source
|
|
30
|
+
Arbre and ActiveAdmin use) instead of `gsub(' ', '_')`. A namespaced name
|
|
31
|
+
previously kept its `::` and produced `div.attributes_table.billing::employee`
|
|
32
|
+
— not a selector, so it aborted the example instead of failing it.
|
|
33
|
+
`table_selector` also accepts a model class now.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- `table_cell_selector`, `table_header_selector` and `attributes_row_selector`
|
|
37
|
+
now derive the CSS class with `parameterize(separator: '_')`, the same call
|
|
38
|
+
ActiveAdmin makes in `AttributesTable#row` and `TableFor::Column#html_class`,
|
|
39
|
+
instead of three different hand-rolled substitutions. Labels containing
|
|
40
|
+
punctuation change selector: `'E-mail'` was `col-email` and is now
|
|
41
|
+
`col-e-mail`, `"Customer's Name"` was `col-customers_name` and is now
|
|
42
|
+
`col-customer_s_name`, `:full_name` was `col-fullname` and is now
|
|
43
|
+
`col-full_name`. Previously these matched nothing (or raised
|
|
44
|
+
`Nokogiri::CSS::SyntaxError`), so an app carrying a workaround that
|
|
45
|
+
pre-normalized labels before calling these helpers should drop it.
|
|
46
|
+
- `table_header_selector(nil, column: 'x')` now honours the override instead
|
|
47
|
+
of returning the generic header selector.
|
|
48
|
+
- tested against Ruby 3.3, 3.4, 4.0 and Rails 8.0, 8.1 (EOL Rails 7.2 dropped from CI)
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- a label that `parameterize` cannot transliterate (`'Имя'`, `'名前'`, `'№'`, or
|
|
52
|
+
a blank string) now raises `ArgumentError` instead of building a bare
|
|
53
|
+
`.row-` / `.col-` selector. ActiveAdmin renders the same empty class for
|
|
54
|
+
every such label, so that selector matched all of them at once and the
|
|
55
|
+
matcher could pass against the wrong row.
|
|
56
|
+
|
|
9
57
|
## [1.0.0] - 2026-04-09
|
|
10
58
|
|
|
11
59
|
### Added
|
|
@@ -22,8 +70,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
70
|
- `have_status_tag` matcher for status tag elements
|
|
23
71
|
|
|
24
72
|
### Changed
|
|
25
|
-
- `
|
|
26
|
-
|
|
73
|
+
- `have_table_scope` now accepts an optional title as first positional argument and `selected:` keyword arg.
|
|
74
|
+
**Breaking**, and not spelled out at the time: the `active:` key it replaced
|
|
75
|
+
is no longer consumed, so it falls through to `have_selector` and Capybara
|
|
76
|
+
rejects it with `ArgumentError: Invalid option(s) :active`. Rename
|
|
77
|
+
`active:` to `selected:`; the selector built is the same.
|
|
78
|
+
- `within_sidebar` now scopes within the sidebar section directly using `ancestor`.
|
|
79
|
+
**Breaking** for a block that relied on the old scope being the panel rather
|
|
80
|
+
than the whole `.sidebar_section`.
|
|
27
81
|
|
|
28
82
|
## [0.3.3] - 2020-04-17
|
|
29
83
|
### Changed
|
data/README.md
CHANGED
|
@@ -55,17 +55,17 @@ RSpec.describe 'Users', js: true do
|
|
|
55
55
|
|
|
56
56
|
within_table_for('users') do
|
|
57
57
|
expect(page).to have_table_row(count: 2)
|
|
58
|
-
expect(page).to have_table_cell('John Doe')
|
|
58
|
+
expect(page).to have_table_cell(text: 'John Doe')
|
|
59
59
|
|
|
60
60
|
within_table_row(id: john.id) do
|
|
61
|
-
expect(page).to have_table_cell('John Doe'
|
|
62
|
-
expect(page).to have_table_cell('John Doe',
|
|
63
|
-
expect(page).to_not have_table_cell('John Doe',
|
|
61
|
+
expect(page).to have_table_cell(text: 'John Doe')
|
|
62
|
+
expect(page).to have_table_cell(text: 'John Doe', column: 'Full Name')
|
|
63
|
+
expect(page).to_not have_table_cell(text: 'John Doe', column: 'Id')
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
within_table_row(id: jane.id) do
|
|
67
|
-
expect(page).to_not have_table_cell('John Doe')
|
|
68
|
-
expect(page).to_not have_table_cell('John Doe',
|
|
67
|
+
expect(page).to_not have_table_cell(text: 'John Doe')
|
|
68
|
+
expect(page).to_not have_table_cell(text: 'John Doe', column: 'Full Name')
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -94,6 +94,67 @@ end
|
|
|
94
94
|
See `spec/support` for more user examples.
|
|
95
95
|
See `capybara/active_admin/test_helpers.rb` for available DSL methods.
|
|
96
96
|
|
|
97
|
+
## How labels become selectors
|
|
98
|
+
|
|
99
|
+
Most helpers take the label you see on the page and build a CSS selector from
|
|
100
|
+
it, because that is how ActiveAdmin names its own elements. Two derivations are
|
|
101
|
+
worth knowing, since a mismatch shows up as "element not found" with no hint of
|
|
102
|
+
why.
|
|
103
|
+
|
|
104
|
+
### Column and row labels
|
|
105
|
+
|
|
106
|
+
ActiveAdmin builds the class with `parameterize(separator: '_')` —
|
|
107
|
+
`AttributesTable#row` and `TableFor::Column#html_class` — and so does this gem:
|
|
108
|
+
|
|
109
|
+
| label | class ActiveAdmin renders |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `'Full Name'` | `col-full_name` |
|
|
112
|
+
| `:full_name` | `col-full_name` |
|
|
113
|
+
| `'VAT / TAX Number'` | `col-vat_tax_number` |
|
|
114
|
+
| `'E-mail'` | `col-e-mail` |
|
|
115
|
+
| `"Customer's Name"` | `col-customer_s_name` |
|
|
116
|
+
| `'# of DIDs'` | `col-of_dids` |
|
|
117
|
+
|
|
118
|
+
So pass the label as it appears, and do **not** normalize it yourself first —
|
|
119
|
+
doing it twice strips the separator the first pass inserted.
|
|
120
|
+
|
|
121
|
+
Two cases have no class to match:
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
# ActiveAdmin renders class="row" with no row-* at all when you give your own
|
|
125
|
+
row :salary, class: 'money'
|
|
126
|
+
|
|
127
|
+
# parameterize drops everything non-Latin, so AA renders a bare class="row row-"
|
|
128
|
+
# for every such label and they cannot be told apart. The gem raises rather
|
|
129
|
+
# than match the wrong one.
|
|
130
|
+
row 'Имя'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Match on text in both cases, or pass the attribute name rather than the label.
|
|
134
|
+
|
|
135
|
+
### Model and resource names
|
|
136
|
+
|
|
137
|
+
`have_attributes_table(model:)` and `within_form_for` follow the **model
|
|
138
|
+
class** — Arbre uses `model_name.singular`:
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
have_attributes_table(model: Billing::Employee) # div.attributes_table.billing_employee
|
|
142
|
+
have_attributes_table(model: 'Billing::Employee') # same
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`have_table(resource_name:)` and `within_table_for` follow the name the
|
|
146
|
+
resource was **registered** under, which `as:` detaches from the model:
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
ActiveAdmin.register Billing::Employee, as: 'Business Employee'
|
|
150
|
+
|
|
151
|
+
within_table_for('Business Employee') { ... } # table#index_table_business_employees
|
|
152
|
+
within_table_for(Billing::Employee) { ... } # table#index_table_billing_employees -- wrong
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
A renamed resource has to be addressed by its registered name; the class cannot
|
|
156
|
+
know it.
|
|
157
|
+
|
|
97
158
|
## Development
|
|
98
159
|
|
|
99
160
|
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.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'capybara/active_admin/util'
|
|
4
|
+
|
|
3
5
|
module Capybara
|
|
4
6
|
module ActiveAdmin
|
|
5
7
|
module Selectors
|
|
@@ -18,7 +20,7 @@ module Capybara
|
|
|
18
20
|
def attributes_row_selector(label = nil)
|
|
19
21
|
return 'tr.row > td' if label.nil?
|
|
20
22
|
|
|
21
|
-
label =
|
|
23
|
+
label = Util.css_class_for_label(label)
|
|
22
24
|
"tr.row.row-#{label} > td"
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'capybara/active_admin/util'
|
|
4
|
+
|
|
3
5
|
module Capybara
|
|
4
6
|
module ActiveAdmin
|
|
5
7
|
module Selectors
|
|
@@ -10,8 +12,12 @@ module Capybara
|
|
|
10
12
|
def table_selector(resource_name = nil)
|
|
11
13
|
return 'table.index_table' if resource_name.nil?
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
# NOTE: ActiveAdmin builds this id from the registered resource name
|
|
16
|
+
# (`active_admin_config.resource_name.plural`, index_as_table.rb:240),
|
|
17
|
+
# which `register Model, as: 'Other Name'` detaches from the model.
|
|
18
|
+
# A class can only ever yield the model's own name, so a renamed
|
|
19
|
+
# resource has to be addressed by the name it was registered under.
|
|
20
|
+
"table#index_table_#{Util.parse_model_name(resource_name, singular: false)}"
|
|
15
21
|
end
|
|
16
22
|
|
|
17
23
|
# @param record_id [String, Integer, nil] record ID.
|
|
@@ -29,9 +35,9 @@ module Capybara
|
|
|
29
35
|
# @option sort_direction [String, nil] sort direction ('asc' or 'desc').
|
|
30
36
|
# @return selector.
|
|
31
37
|
def table_header_selector(text = nil, options = {})
|
|
32
|
-
return 'thead > tr > th.col' if text.nil?
|
|
38
|
+
return 'thead > tr > th.col' if text.nil? && options[:column].nil?
|
|
33
39
|
|
|
34
|
-
column = (options[:column] || text)
|
|
40
|
+
column = Util.css_class_for_label(options[:column] || text)
|
|
35
41
|
selector = "th.col.col-#{column}"
|
|
36
42
|
selector += '.sortable' if options[:sortable]
|
|
37
43
|
selector += ".sorted-#{options[:sort_direction].to_s.downcase}" if options[:sort_direction].present?
|
|
@@ -43,8 +49,7 @@ module Capybara
|
|
|
43
49
|
def table_cell_selector(column = nil)
|
|
44
50
|
return 'td.col' if column.nil?
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_')
|
|
52
|
+
column = Util.css_class_for_label(column)
|
|
48
53
|
"td.col.col-#{column}"
|
|
49
54
|
end
|
|
50
55
|
|
|
@@ -5,12 +5,49 @@ module Capybara
|
|
|
5
5
|
module Util
|
|
6
6
|
# Common pure utility functions
|
|
7
7
|
|
|
8
|
+
# Arbre derives a record's DOM name from
|
|
9
|
+
# `record.class.model_name.singular`, falling back to
|
|
10
|
+
# `name.underscore.gsub('/', '_')` (arbre html/tag.rb:164-168). Ask the
|
|
11
|
+
# model the same question instead of approximating it: `gsub(' ', '_')`
|
|
12
|
+
# leaves the `::` of a namespaced name in place, and
|
|
13
|
+
# `div.attributes_table.billing::employee` is not a selector -- Nokogiri
|
|
14
|
+
# raises `SyntaxError` on it with nothing pointing at the cause.
|
|
8
15
|
def parse_model_name(model_name, singular: true)
|
|
9
16
|
return if model_name.nil?
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
if model_name.is_a?(Class) && model_name.respond_to?(:model_name)
|
|
19
|
+
name = model_name.model_name
|
|
20
|
+
return singular ? name.singular : name.plural
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
dom_model_name(model_name.is_a?(Class) ? model_name.name : model_name, singular: singular)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def dom_model_name(name, singular: true)
|
|
27
|
+
name = name.to_s.underscore.tr('/', '_').tr(' ', '_')
|
|
28
|
+
singular ? name.singularize : name.pluralize
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# ActiveAdmin derives the CSS class of a row or column from the
|
|
32
|
+
# label with `parameterize(separator: '_')` --
|
|
33
|
+
# `AttributesTable#row` and `TableFor::Column#html_class`. Mirror
|
|
34
|
+
# that call rather than approximating it, so every label lands on
|
|
35
|
+
# the class ActiveAdmin actually rendered.
|
|
36
|
+
def css_class_for_label(label)
|
|
37
|
+
css_class = label.to_s.parameterize(separator: '_')
|
|
38
|
+
return css_class if css_class.present?
|
|
39
|
+
|
|
40
|
+
# `parameterize` transliterates to Latin and drops the rest, so any
|
|
41
|
+
# label without Latin-transliterable characters -- 'Имя', '名前', '№',
|
|
42
|
+
# or a blank string -- comes back empty. ActiveAdmin makes the same
|
|
43
|
+
# call, so it renders `class="row row-"` for all of them, and a
|
|
44
|
+
# `.row-` selector would match every one at once: the matcher would
|
|
45
|
+
# pass against the wrong row instead of failing. Refuse to build it.
|
|
46
|
+
raise ArgumentError,
|
|
47
|
+
"cannot derive a CSS class from #{label.inspect}: " \
|
|
48
|
+
'ActiveAdmin parameterizes it to an empty string, so every such ' \
|
|
49
|
+
'row or column shares one class and cannot be told apart. ' \
|
|
50
|
+
'Match on text, or pass the attribute name instead of the label.'
|
|
14
51
|
end
|
|
15
52
|
|
|
16
53
|
def options_with_text(text, options = {})
|
|
@@ -19,7 +56,7 @@ module Capybara
|
|
|
19
56
|
options.except(:exact).merge(key => text)
|
|
20
57
|
end
|
|
21
58
|
|
|
22
|
-
module_function :parse_model_name, :options_with_text
|
|
59
|
+
module_function :parse_model_name, :dom_model_name, :css_class_for_label, :options_with_text
|
|
23
60
|
end
|
|
24
61
|
end
|
|
25
62
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara_active_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Talakevich
|
|
@@ -50,25 +50,9 @@ executables: []
|
|
|
50
50
|
extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
|
52
52
|
files:
|
|
53
|
-
- ".github/workflows/ci.yml"
|
|
54
|
-
- ".github/workflows/codeql.yml"
|
|
55
|
-
- ".gitignore"
|
|
56
|
-
- ".rspec"
|
|
57
|
-
- ".rubocop.yml"
|
|
58
53
|
- CHANGELOG.md
|
|
59
|
-
- CODE_OF_CONDUCT.md
|
|
60
|
-
- Gemfile
|
|
61
54
|
- LICENSE.txt
|
|
62
55
|
- README.md
|
|
63
|
-
- Rakefile
|
|
64
|
-
- bin/console
|
|
65
|
-
- bin/setup
|
|
66
|
-
- capybara_active_admin.gemspec
|
|
67
|
-
- docs/.vuepress/config.js
|
|
68
|
-
- docs/.vuepress/public/.keep
|
|
69
|
-
- docs/.vuepress/styles/index.styl
|
|
70
|
-
- docs/README.md
|
|
71
|
-
- docs/guide/README.md
|
|
72
56
|
- lib/capybara/active_admin.rb
|
|
73
57
|
- lib/capybara/active_admin/actions.rb
|
|
74
58
|
- lib/capybara/active_admin/actions/attributes_table.rb
|
|
@@ -95,7 +79,6 @@ files:
|
|
|
95
79
|
- lib/capybara/active_admin/util.rb
|
|
96
80
|
- lib/capybara/active_admin/version.rb
|
|
97
81
|
- lib/capybara_active_admin.rb
|
|
98
|
-
- package.json
|
|
99
82
|
homepage: https://github.com/active_admin_plugins/capybara_active_admin
|
|
100
83
|
licenses:
|
|
101
84
|
- MIT
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
push:
|
|
5
|
-
branches: [master]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
pages: write
|
|
10
|
-
id-token: write
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
test:
|
|
14
|
-
name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / AA ${{ matrix.activeadmin }}
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
strategy:
|
|
17
|
-
fail-fast: false
|
|
18
|
-
matrix:
|
|
19
|
-
ruby: ['3.3', '3.4', '4.0']
|
|
20
|
-
rails: ['~> 7.2.0', '~> 8.0.0', '~> 8.1.0']
|
|
21
|
-
activeadmin: ['~> 3.2', '~> 3.3', '~> 3.4', '~> 3.5']
|
|
22
|
-
env:
|
|
23
|
-
RAILS_VERSION: ${{ matrix.rails }}
|
|
24
|
-
ACTIVE_ADMIN_VERSION: ${{ matrix.activeadmin }}
|
|
25
|
-
steps:
|
|
26
|
-
- uses: actions/checkout@v4
|
|
27
|
-
- uses: ruby/setup-ruby@v1
|
|
28
|
-
with:
|
|
29
|
-
ruby-version: ${{ matrix.ruby }}
|
|
30
|
-
bundler-cache: true
|
|
31
|
-
- name: Run tests
|
|
32
|
-
run: bundle exec rspec spec
|
|
33
|
-
|
|
34
|
-
- name: Generate badge.json
|
|
35
|
-
if: matrix.ruby == '4.0' && matrix.rails == '~> 8.1.0' && matrix.activeadmin == '~> 3.5'
|
|
36
|
-
run: |
|
|
37
|
-
LAST_RUN="coverage/.last_run.json"
|
|
38
|
-
if [ ! -f "$LAST_RUN" ]; then
|
|
39
|
-
mkdir -p badge
|
|
40
|
-
echo '{"schemaVersion":1,"label":"coverage","message":"unknown","color":"lightgrey"}' > badge/badge.json
|
|
41
|
-
exit 0
|
|
42
|
-
fi
|
|
43
|
-
PERCENT=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line').round(1)")
|
|
44
|
-
PERCENT_NUM=$(ruby -rjson -e "puts JSON.parse(File.read('$LAST_RUN')).dig('result','line')")
|
|
45
|
-
if ruby -e "exit(($PERCENT_NUM >= 90) ? 0 : 1)"; then COLOR="brightgreen"
|
|
46
|
-
elif ruby -e "exit(($PERCENT_NUM >= 75) ? 0 : 1)"; then COLOR="green"
|
|
47
|
-
elif ruby -e "exit(($PERCENT_NUM >= 60) ? 0 : 1)"; then COLOR="yellow"
|
|
48
|
-
else COLOR="red"; fi
|
|
49
|
-
mkdir -p badge
|
|
50
|
-
echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PERCENT}%\",\"color\":\"${COLOR}\"}" > badge/badge.json
|
|
51
|
-
|
|
52
|
-
- name: Upload badge artifact
|
|
53
|
-
if: matrix.ruby == '4.0' && matrix.rails == '~> 8.1.0' && matrix.activeadmin == '~> 3.5'
|
|
54
|
-
uses: actions/upload-artifact@v4
|
|
55
|
-
with:
|
|
56
|
-
name: coverage-badge
|
|
57
|
-
path: badge
|
|
58
|
-
|
|
59
|
-
deploy-coverage:
|
|
60
|
-
needs: test
|
|
61
|
-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
62
|
-
runs-on: ubuntu-latest
|
|
63
|
-
environment:
|
|
64
|
-
name: github-pages
|
|
65
|
-
url: ${{ steps.deployment.outputs.page_url }}
|
|
66
|
-
|
|
67
|
-
steps:
|
|
68
|
-
- uses: actions/checkout@v4
|
|
69
|
-
with:
|
|
70
|
-
ref: gh-pages
|
|
71
|
-
|
|
72
|
-
- name: Download coverage badge
|
|
73
|
-
uses: actions/download-artifact@v4
|
|
74
|
-
with:
|
|
75
|
-
name: coverage-badge
|
|
76
|
-
path: .
|
|
77
|
-
|
|
78
|
-
- name: Setup Pages
|
|
79
|
-
uses: actions/configure-pages@v5
|
|
80
|
-
|
|
81
|
-
- name: Upload Pages artifact
|
|
82
|
-
uses: actions/upload-pages-artifact@v3
|
|
83
|
-
with:
|
|
84
|
-
path: .
|
|
85
|
-
|
|
86
|
-
- name: Deploy to GitHub Pages
|
|
87
|
-
id: deployment
|
|
88
|
-
uses: actions/deploy-pages@v4
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
-
# to commit it to your repository.
|
|
3
|
-
#
|
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
-
# or to provide custom queries or build logic.
|
|
6
|
-
#
|
|
7
|
-
# ******** NOTE ********
|
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
-
# supported CodeQL languages.
|
|
11
|
-
#
|
|
12
|
-
name: "CodeQL Advanced"
|
|
13
|
-
|
|
14
|
-
on:
|
|
15
|
-
push:
|
|
16
|
-
branches: [ "master" ]
|
|
17
|
-
pull_request:
|
|
18
|
-
branches: [ "master" ]
|
|
19
|
-
schedule:
|
|
20
|
-
- cron: '38 15 * * 0'
|
|
21
|
-
|
|
22
|
-
jobs:
|
|
23
|
-
analyze:
|
|
24
|
-
name: Analyze (${{ matrix.language }})
|
|
25
|
-
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
|
26
|
-
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
|
27
|
-
# - https://gh.io/supported-runners-and-hardware-resources
|
|
28
|
-
# - https://gh.io/using-larger-runners (GitHub.com only)
|
|
29
|
-
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
|
30
|
-
runs-on: 'ubuntu-latest'
|
|
31
|
-
permissions:
|
|
32
|
-
# required for all workflows
|
|
33
|
-
security-events: write
|
|
34
|
-
|
|
35
|
-
# required to fetch internal or private CodeQL packs
|
|
36
|
-
packages: read
|
|
37
|
-
|
|
38
|
-
# only required for workflows in private repositories
|
|
39
|
-
actions: read
|
|
40
|
-
contents: read
|
|
41
|
-
|
|
42
|
-
strategy:
|
|
43
|
-
fail-fast: false
|
|
44
|
-
matrix:
|
|
45
|
-
include:
|
|
46
|
-
- language: actions
|
|
47
|
-
build-mode: none
|
|
48
|
-
- language: ruby
|
|
49
|
-
build-mode: none
|
|
50
|
-
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
|
|
51
|
-
# Use `c-cpp` to analyze code written in C, C++ or both
|
|
52
|
-
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
|
53
|
-
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
|
54
|
-
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
|
55
|
-
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
|
56
|
-
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
|
57
|
-
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
|
58
|
-
steps:
|
|
59
|
-
- name: Checkout repository
|
|
60
|
-
uses: actions/checkout@v4
|
|
61
|
-
|
|
62
|
-
# Add any setup steps before running the `github/codeql-action/init` action.
|
|
63
|
-
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
|
64
|
-
# or others). This is typically only required for manual builds.
|
|
65
|
-
# - name: Setup runtime (example)
|
|
66
|
-
# uses: actions/setup-example@v1
|
|
67
|
-
|
|
68
|
-
# Initializes the CodeQL tools for scanning.
|
|
69
|
-
- name: Initialize CodeQL
|
|
70
|
-
uses: github/codeql-action/init@v4
|
|
71
|
-
with:
|
|
72
|
-
languages: ${{ matrix.language }}
|
|
73
|
-
build-mode: ${{ matrix.build-mode }}
|
|
74
|
-
config: |
|
|
75
|
-
paths-ignore:
|
|
76
|
-
- '**/spec/**'
|
|
77
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
78
|
-
# By default, queries listed here will override any specified in a config file.
|
|
79
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
80
|
-
|
|
81
|
-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
82
|
-
# queries: security-extended,security-and-quality
|
|
83
|
-
|
|
84
|
-
# If the analyze step fails for one of the languages you are analyzing with
|
|
85
|
-
# "We were unable to automatically build your code", modify the matrix above
|
|
86
|
-
# to set the build mode to "manual" for that language. Then modify this step
|
|
87
|
-
# to build your code.
|
|
88
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
|
89
|
-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
90
|
-
- name: Run manual build steps
|
|
91
|
-
if: matrix.build-mode == 'manual'
|
|
92
|
-
shell: bash
|
|
93
|
-
run: |
|
|
94
|
-
echo 'If you are using a "manual" build mode for one or more of the' \
|
|
95
|
-
'languages you are analyzing, replace this with the commands to build' \
|
|
96
|
-
'your code, for example:'
|
|
97
|
-
echo ' make bootstrap'
|
|
98
|
-
echo ' make release'
|
|
99
|
-
exit 1
|
|
100
|
-
|
|
101
|
-
- name: Perform CodeQL Analysis
|
|
102
|
-
uses: github/codeql-action/analyze@v4
|
|
103
|
-
with:
|
|
104
|
-
category: "/language:${{matrix.language}}"
|
data/.gitignore
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/_yardoc/
|
|
4
|
-
/coverage/
|
|
5
|
-
/doc/
|
|
6
|
-
/pkg/
|
|
7
|
-
/spec/reports/
|
|
8
|
-
/tmp/
|
|
9
|
-
/spec/dummy/tmp/
|
|
10
|
-
/spec/dummy/log/*.log
|
|
11
|
-
|
|
12
|
-
# rspec failure tracking
|
|
13
|
-
.rspec_status
|
|
14
|
-
|
|
15
|
-
Gemfile.lock
|
|
16
|
-
|
|
17
|
-
# docs
|
|
18
|
-
/docs/.vuepress/dist/
|
|
19
|
-
/docs/.vuepress/public/api/
|
|
20
|
-
/node_modules/
|
|
21
|
-
yarn.lock
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
DisplayCopNames: true
|
|
3
|
-
TargetRubyVersion: 2.3
|
|
4
|
-
Exclude:
|
|
5
|
-
- vendor/**/*
|
|
6
|
-
- tmp/**/*
|
|
7
|
-
- docs/**/*
|
|
8
|
-
|
|
9
|
-
# Capybara/RSpec uses have_ had_ as name convention for matchers.
|
|
10
|
-
Naming/PredicateName:
|
|
11
|
-
Enabled: false
|
|
12
|
-
|
|
13
|
-
Lint/RaiseException:
|
|
14
|
-
Enabled: true
|
|
15
|
-
|
|
16
|
-
Lint/StructNewOverride:
|
|
17
|
-
Enabled: true
|
|
18
|
-
|
|
19
|
-
Layout/LineLength:
|
|
20
|
-
Max: 180
|
|
21
|
-
|
|
22
|
-
Style/SymbolArray:
|
|
23
|
-
EnforcedStyle: brackets
|
|
24
|
-
|
|
25
|
-
Style/Lambda:
|
|
26
|
-
EnforcedStyle: literal
|
|
27
|
-
|
|
28
|
-
Naming/MethodParameterName:
|
|
29
|
-
AllowedNames:
|
|
30
|
-
- id
|
|
31
|
-
|
|
32
|
-
Style/HashEachMethods:
|
|
33
|
-
Enabled: true
|
|
34
|
-
|
|
35
|
-
Style/HashTransformKeys:
|
|
36
|
-
Enabled: true
|
|
37
|
-
|
|
38
|
-
Style/HashTransformValues:
|
|
39
|
-
Enabled: true
|
|
40
|
-
|
|
41
|
-
Style/Documentation:
|
|
42
|
-
Enabled: false
|
|
43
|
-
|
|
44
|
-
Metrics/PerceivedComplexity:
|
|
45
|
-
Enabled: false
|
|
46
|
-
|
|
47
|
-
Metrics/MethodLength:
|
|
48
|
-
Enabled: false
|
|
49
|
-
|
|
50
|
-
Metrics/AbcSize:
|
|
51
|
-
Enabled: false
|
|
52
|
-
|
|
53
|
-
Metrics/ModuleLength:
|
|
54
|
-
Enabled: false
|
|
55
|
-
|
|
56
|
-
Metrics/BlockLength:
|
|
57
|
-
Enabled: false
|
|
58
|
-
|
|
59
|
-
Metrics/ClassLength:
|
|
60
|
-
Enabled: false
|
|
61
|
-
|
|
62
|
-
Metrics/CyclomaticComplexity:
|
|
63
|
-
Enabled: false
|
|
64
|
-
|
|
65
|
-
Layout/MultilineOperationIndentation:
|
|
66
|
-
Enabled: false
|
|
67
|
-
|
|
68
|
-
Layout/FirstHashElementIndentation:
|
|
69
|
-
Enabled: false
|
|
70
|
-
|
|
71
|
-
Layout/FirstArrayElementIndentation:
|
|
72
|
-
Enabled: false
|
|
73
|
-
|
|
74
|
-
Layout/FirstArgumentIndentation:
|
|
75
|
-
Enabled: false
|
|
76
|
-
|
|
77
|
-
Layout/ClosingParenthesisIndentation:
|
|
78
|
-
Enabled: false
|
|
79
|
-
|
|
80
|
-
Layout/ArgumentAlignment:
|
|
81
|
-
Enabled: false
|
|
82
|
-
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
-
orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project e-mail
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at senid231@gmail.com. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
-
|
|
73
|
-
[homepage]: https://contributor-covenant.org
|
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
gemspec
|
|
3
|
-
|
|
4
|
-
gem 'activeadmin', ENV.fetch('ACTIVE_ADMIN_VERSION', '~> 3.2')
|
|
5
|
-
gem 'rails', ENV.fetch('RAILS_VERSION', '~> 7.1.0')
|
|
6
|
-
gem 'sprockets-rails'
|
|
7
|
-
gem 'sassc-rails'
|
|
8
|
-
|
|
9
|
-
group :test do
|
|
10
|
-
gem 'capybara'
|
|
11
|
-
gem 'cuprite'
|
|
12
|
-
gem 'puma'
|
|
13
|
-
gem 'rspec-rails', '~> 6.0'
|
|
14
|
-
gem 'simplecov', require: false
|
|
15
|
-
gem 'sqlite3', '~> 2.0'
|
|
16
|
-
end
|
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require 'bundler/setup'
|
|
5
|
-
require 'capybara_active_admin'
|
|
6
|
-
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require "pry"
|
|
12
|
-
# Pry.start
|
|
13
|
-
|
|
14
|
-
require 'irb'
|
|
15
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'lib/capybara/active_admin/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = 'capybara_active_admin'
|
|
7
|
-
spec.version = Capybara::ActiveAdmin::VERSION
|
|
8
|
-
spec.authors = ['Denis Talakevich']
|
|
9
|
-
spec.email = ['senid231@gmail.com']
|
|
10
|
-
|
|
11
|
-
spec.summary = 'Capybara DSL for fast and easy testing Active Admin applications.'
|
|
12
|
-
spec.description = 'Capybara DSL for fast and easy testing Active Admin applications.'
|
|
13
|
-
spec.homepage = 'https://github.com/active_admin_plugins/capybara_active_admin'
|
|
14
|
-
spec.license = 'MIT'
|
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.3.0')
|
|
16
|
-
|
|
17
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
-
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
-
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
|
20
|
-
|
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
-
end
|
|
26
|
-
spec.bindir = 'exe'
|
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
-
spec.require_paths = ['lib']
|
|
29
|
-
|
|
30
|
-
spec.add_dependency 'activeadmin', '>= 3.0', '< 4.0'
|
|
31
|
-
# spec.add_dependency 'devise'
|
|
32
|
-
spec.add_dependency 'rspec', '~> 3.0'
|
|
33
|
-
end
|
data/docs/.vuepress/config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
title: 'Capybara Active Admin',
|
|
3
|
-
description: 'Capybara DSL for fast and easy testing Active Admin applications.',
|
|
4
|
-
base: '/capybara_active_admin/',
|
|
5
|
-
themeConfig: {
|
|
6
|
-
nav: [
|
|
7
|
-
{ text: 'Guide', link: '/guide/' },
|
|
8
|
-
{ text: 'API Reference', link: '/api/', target: '_blank' },
|
|
9
|
-
{ text: 'GitHub', link: 'https://github.com/activeadmin-plugins/capybara_active_admin' }
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
}
|
data/docs/.vuepress/public/.keep
DELETED
|
File without changes
|
data/docs/README.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
home: true
|
|
3
|
-
actionText: Get Started →
|
|
4
|
-
actionLink: /guide/
|
|
5
|
-
footer: MIT Licensed | Copyright © 2020-present Denis Talakevich
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<div style="text-align: center">
|
|
9
|
-
<Bit/>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div class="features">
|
|
13
|
-
<div class="feature">
|
|
14
|
-
<h2>Fast Test Writing</h2>
|
|
15
|
-
<p>Allow to focus on what you want to test instead of how to do it.</p>
|
|
16
|
-
</div>
|
|
17
|
-
<div class="feature">
|
|
18
|
-
<h2>Simplicity</h2>
|
|
19
|
-
<p>Following Ruby an Capybara naming conventions allows easily to read and understand tests code.</p>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="feature">
|
|
22
|
-
<h2>Customizable</h2>
|
|
23
|
-
<p>You can easy extend, customize, and mix parts of library to fit your needs.</p>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
### As Easy as 1, 2, 3
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# install
|
|
31
|
-
gem install capybara_active_admin
|
|
32
|
-
# OR echo "gem 'capybara_active_admin', group: :test, require: false" >> Gemfile
|
|
33
|
-
```
|
|
34
|
-
```ruby
|
|
35
|
-
# require in in rspec/rails_helper.rb
|
|
36
|
-
require 'capybara/active_admin/rspec'
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
::: warning COMPATIBILITY NOTE
|
|
40
|
-
requires Ruby >= 2.3.
|
|
41
|
-
:::
|
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
|
-
```
|