capybara_active_admin 0.3.3 → 1.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/.github/workflows/ci.yml +88 -0
- data/.github/workflows/codeql.yml +104 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +12 -19
- data/README.md +7 -1
- data/Rakefile +1 -11
- data/capybara_active_admin.gemspec +2 -2
- 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 +1 -1
- data/lib/capybara/active_admin/selectors/form.rb +7 -1
- data/lib/capybara/active_admin/selectors/table.rb +23 -3
- data/lib/capybara/active_admin/version.rb +1 -1
- metadata +14 -11
- data/.travis.yml +0 -45
- data/yarn.lock +0 -7947
|
@@ -14,7 +14,7 @@ module Capybara
|
|
|
14
14
|
def have_table(options = {})
|
|
15
15
|
resource_name = options.delete(:resource_name)
|
|
16
16
|
selector = table_selector(resource_name)
|
|
17
|
-
have_selector(selector, options)
|
|
17
|
+
have_selector(selector, **options)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# @param options [Hash]
|
|
@@ -30,7 +30,7 @@ module Capybara
|
|
|
30
30
|
def have_table_row(options = {})
|
|
31
31
|
row_id = options.delete(:id)
|
|
32
32
|
selector = table_row_selector(row_id)
|
|
33
|
-
have_selector(selector, options)
|
|
33
|
+
have_selector(selector, **options)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# @param options [Hash]
|
|
@@ -51,7 +51,43 @@ module Capybara
|
|
|
51
51
|
column = options.delete(:column)
|
|
52
52
|
selector = table_cell_selector(column)
|
|
53
53
|
|
|
54
|
-
have_selector(selector, options)
|
|
54
|
+
have_selector(selector, **options)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# @param options [Hash]
|
|
58
|
+
# @option count [Integer] qty of nodes
|
|
59
|
+
def have_table_scopes(options = {})
|
|
60
|
+
have_selector("#{table_scopes_container_selector} > #{table_scope_selector}", **options)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @param title [String, nil] exact title of scope to match.
|
|
64
|
+
# @param selected [Boolean] whether to match selected (active) scope only (default false).
|
|
65
|
+
# @param options [Hash] additional options passed to have_selector.
|
|
66
|
+
def have_table_scope(title = nil, selected: false, **options)
|
|
67
|
+
selector = "#{table_scopes_container_selector} > #{table_scope_selector}"
|
|
68
|
+
if title.nil?
|
|
69
|
+
selector = selected ? "#{selector}.selected" : "#{selector}:not(.selected)"
|
|
70
|
+
have_selector(selector, **options)
|
|
71
|
+
else
|
|
72
|
+
selector = selected ? "#{selector}.selected" : selector
|
|
73
|
+
have_selector(selector, exact_text: title.to_s, **options)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @param text [String] column header text.
|
|
78
|
+
# @param options [Hash]
|
|
79
|
+
# @option column [String, nil] column name override (defaults to text).
|
|
80
|
+
# @option sortable [Boolean] whether the column is sortable.
|
|
81
|
+
# @option sort_direction [String, nil] sort direction ('asc' or 'desc').
|
|
82
|
+
# @example
|
|
83
|
+
# expect(page).to have_table_header('Full Name')
|
|
84
|
+
# expect(page).to have_table_header('Full Name', sortable: true)
|
|
85
|
+
# expect(page).to have_table_header('Full Name', sort_direction: :asc)
|
|
86
|
+
#
|
|
87
|
+
def have_table_header(text, options = {})
|
|
88
|
+
selector = table_header_selector(text, options)
|
|
89
|
+
opts = options.except(:column, :sortable, :sort_direction).merge(exact_text: text)
|
|
90
|
+
have_selector(selector, **opts)
|
|
55
91
|
end
|
|
56
92
|
end
|
|
57
93
|
end
|
|
@@ -35,6 +35,12 @@ module Capybara
|
|
|
35
35
|
"div.has_many_container.#{association_name} > fieldset.inputs.has_many_fields"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# @param association_name [String]
|
|
39
|
+
# @return [String] .has_many_container selector.
|
|
40
|
+
def has_many_container_selector(association_name)
|
|
41
|
+
".has_many_container.#{association_name}"
|
|
42
|
+
end
|
|
43
|
+
|
|
38
44
|
# @param text [String, nil] submit button text.
|
|
39
45
|
# @return [String] selector.
|
|
40
46
|
def form_submit_selector(text = nil)
|
|
@@ -50,7 +56,7 @@ module Capybara
|
|
|
50
56
|
return 'li' if label.nil?
|
|
51
57
|
|
|
52
58
|
label_opts = Util.options_with_text(label, exact: exact)
|
|
53
|
-
label_node = find(label_selector, label_opts)
|
|
59
|
+
label_node = find(label_selector, **label_opts)
|
|
54
60
|
li_id = label_node.ancestor('li')[:id]
|
|
55
61
|
"li##{li_id}"
|
|
56
62
|
end
|
|
@@ -22,9 +22,20 @@ module Capybara
|
|
|
22
22
|
%(tbody > tr[id$="_#{record_id}"])
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# @param text [String] column header text.
|
|
26
|
+
# @param options [Hash]
|
|
27
|
+
# @option column [String, nil] column name override (defaults to text).
|
|
28
|
+
# @option sortable [Boolean] whether column is sortable.
|
|
29
|
+
# @option sort_direction [String, nil] sort direction ('asc' or 'desc').
|
|
25
30
|
# @return selector.
|
|
26
|
-
def table_header_selector
|
|
27
|
-
'thead > tr > th.col'
|
|
31
|
+
def table_header_selector(text = nil, options = {})
|
|
32
|
+
return 'thead > tr > th.col' if text.nil?
|
|
33
|
+
|
|
34
|
+
column = (options[:column] || text).to_s.tr(' ', '_').downcase
|
|
35
|
+
selector = "th.col.col-#{column}"
|
|
36
|
+
selector += '.sortable' if options[:sortable]
|
|
37
|
+
selector += ".sorted-#{options[:sort_direction].to_s.downcase}" if options[:sort_direction].present?
|
|
38
|
+
"thead > tr > #{selector}"
|
|
28
39
|
end
|
|
29
40
|
|
|
30
41
|
# @param column [String, nil] column name.
|
|
@@ -32,9 +43,18 @@ module Capybara
|
|
|
32
43
|
def table_cell_selector(column = nil)
|
|
33
44
|
return 'td.col' if column.nil?
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
# Downcase, strip non-alphanumeric chars (e.g. '/'), convert spaces to '_', deduplicate '_'
|
|
47
|
+
column = column.to_s.downcase.gsub(/[^a-z0-9\s]/, '').gsub(/\s+/, '_').squeeze('_')
|
|
36
48
|
"td.col.col-#{column}"
|
|
37
49
|
end
|
|
50
|
+
|
|
51
|
+
def table_scopes_container_selector
|
|
52
|
+
'.scopes > ul.table_tools_segmented_control'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def table_scope_selector
|
|
56
|
+
'li.scope'
|
|
57
|
+
end
|
|
38
58
|
end
|
|
39
59
|
end
|
|
40
60
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara_active_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Talakevich
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activeadmin
|
|
@@ -16,14 +15,20 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
18
|
+
version: '3.0'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '4.0'
|
|
20
22
|
type: :runtime
|
|
21
23
|
prerelease: false
|
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
25
|
requirements:
|
|
24
26
|
- - ">="
|
|
25
27
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
28
|
+
version: '3.0'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '4.0'
|
|
27
32
|
- !ruby/object:Gem::Dependency
|
|
28
33
|
name: rspec
|
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,10 +50,11 @@ executables: []
|
|
|
45
50
|
extensions: []
|
|
46
51
|
extra_rdoc_files: []
|
|
47
52
|
files:
|
|
53
|
+
- ".github/workflows/ci.yml"
|
|
54
|
+
- ".github/workflows/codeql.yml"
|
|
48
55
|
- ".gitignore"
|
|
49
56
|
- ".rspec"
|
|
50
57
|
- ".rubocop.yml"
|
|
51
|
-
- ".travis.yml"
|
|
52
58
|
- CHANGELOG.md
|
|
53
59
|
- CODE_OF_CONDUCT.md
|
|
54
60
|
- Gemfile
|
|
@@ -90,7 +96,6 @@ files:
|
|
|
90
96
|
- lib/capybara/active_admin/version.rb
|
|
91
97
|
- lib/capybara_active_admin.rb
|
|
92
98
|
- package.json
|
|
93
|
-
- yarn.lock
|
|
94
99
|
homepage: https://github.com/active_admin_plugins/capybara_active_admin
|
|
95
100
|
licenses:
|
|
96
101
|
- MIT
|
|
@@ -98,7 +103,6 @@ metadata:
|
|
|
98
103
|
homepage_uri: https://github.com/active_admin_plugins/capybara_active_admin
|
|
99
104
|
source_code_uri: https://github.com/active_admin_plugins/capybara_active_admin
|
|
100
105
|
changelog_uri: https://github.com/active_admin_plugins/capybara_active_admin/blob/master/CHANGELOG.md
|
|
101
|
-
post_install_message:
|
|
102
106
|
rdoc_options: []
|
|
103
107
|
require_paths:
|
|
104
108
|
- lib
|
|
@@ -106,15 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
106
110
|
requirements:
|
|
107
111
|
- - ">="
|
|
108
112
|
- !ruby/object:Gem::Version
|
|
109
|
-
version:
|
|
113
|
+
version: 3.3.0
|
|
110
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
115
|
requirements:
|
|
112
116
|
- - ">="
|
|
113
117
|
- !ruby/object:Gem::Version
|
|
114
118
|
version: '0'
|
|
115
119
|
requirements: []
|
|
116
|
-
rubygems_version: 3.
|
|
117
|
-
signing_key:
|
|
120
|
+
rubygems_version: 3.6.9
|
|
118
121
|
specification_version: 4
|
|
119
122
|
summary: Capybara DSL for fast and easy testing Active Admin applications.
|
|
120
123
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
# test config on https://config.travis-ci.com/explore
|
|
3
|
-
language: ruby
|
|
4
|
-
cache: bundler
|
|
5
|
-
before_install:
|
|
6
|
-
- gem install bundler -v 2.1.4
|
|
7
|
-
stages:
|
|
8
|
-
- test
|
|
9
|
-
- deploy
|
|
10
|
-
jobs:
|
|
11
|
-
include:
|
|
12
|
-
- name: "Test Ruby-2.5.7 Rails-6.0"
|
|
13
|
-
stage: test
|
|
14
|
-
rvm: 2.5.7
|
|
15
|
-
env: RAILS_VERSION="~> 6.0"
|
|
16
|
-
before_script: bundle install
|
|
17
|
-
script: bundle exec rake default
|
|
18
|
-
- name: "Test Ruby-2.5.7 Rails-5.2"
|
|
19
|
-
stage: test
|
|
20
|
-
rvm: 2.5.7
|
|
21
|
-
env: RAILS_VERSION="~> 5.2"
|
|
22
|
-
before_script: bundle install
|
|
23
|
-
script: bundle exec rake default
|
|
24
|
-
- name: "Test Ruby-2.3.8 Rails-5.2"
|
|
25
|
-
stage: test
|
|
26
|
-
rvm: 2.3.8
|
|
27
|
-
env: RAILS_VERSION="~> 5.2"
|
|
28
|
-
before_script: bundle install
|
|
29
|
-
script: bundle exec rake default
|
|
30
|
-
- name: "Deploy documentation"
|
|
31
|
-
stage: deploy
|
|
32
|
-
before_script: yarn install
|
|
33
|
-
script:
|
|
34
|
-
- bundle exec rake yard
|
|
35
|
-
- yarn docs:build
|
|
36
|
-
deploy:
|
|
37
|
-
provider: pages
|
|
38
|
-
edge: true
|
|
39
|
-
verbose: true
|
|
40
|
-
cleanup: false
|
|
41
|
-
local_dir: docs/.vuepress/dist
|
|
42
|
-
token: $GITHUB_TOKEN
|
|
43
|
-
keep_history: true
|
|
44
|
-
on:
|
|
45
|
-
branch: master
|