eac_active_scaffold 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_active_scaffold/rspec/controller_director/attribute_set.rb +41 -0
- data/lib/eac_active_scaffold/rspec/controller_director.rb +9 -0
- data/lib/eac_active_scaffold/rspec/shared_contexts/active_scaffold_controller.rb +2 -6
- data/lib/eac_active_scaffold/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d69265751bd71af4268328c69b1b30d69cffa89a179c90e6041c78ccf152511
|
4
|
+
data.tar.gz: 2c4bed407eb53bf70d8ed1598fd66a9c5b26e6cf0c997ac44406c7b20bbc46ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a0b3e704a4e8f067df54f5c7da30e6b16c009b2529fc43f90d57fa75a4e2b6d85722ef262b7007b03638b839acac8793f257f727af65451a142fa64ebb66fc0
|
7
|
+
data.tar.gz: 42f925360f83aa6840825c8c9837acda5180985688080c85d3a3d69afe24d336a9619f8a697c0492c12c7e3a78670a391b3c0892157e6f6557ab0c0d864f2a8f
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacActiveScaffold
|
6
|
+
module Rspec
|
7
|
+
class ControllerDirector
|
8
|
+
class AttributeSet
|
9
|
+
enable_method_class
|
10
|
+
common_constructor :director, :example, :name, :value
|
11
|
+
|
12
|
+
def result
|
13
|
+
text_fill
|
14
|
+
rescue ::Capybara::ElementNotFound
|
15
|
+
select_option
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [Capybara::Node::Element]
|
21
|
+
def field
|
22
|
+
example.find_field(label)
|
23
|
+
end
|
24
|
+
|
25
|
+
def label
|
26
|
+
director.attribute_label(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def select_option
|
30
|
+
example.within field do
|
31
|
+
example.find("option[value='#{value}']").select_option
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def text_fill
|
36
|
+
field.fill_in with: value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -17,6 +17,13 @@ module EacActiveScaffold
|
|
17
17
|
model_class.human_attribute_name(attr)
|
18
18
|
end
|
19
19
|
|
20
|
+
# @param example [RSpec::Core::ExampleGroup]
|
21
|
+
# @param attrs [Hash]
|
22
|
+
# @return [void]
|
23
|
+
def attributes_set(example, attrs)
|
24
|
+
attrs.each { |attr, value| attribute_set(example, attr, value) }
|
25
|
+
end
|
26
|
+
|
20
27
|
# @return [Class]
|
21
28
|
def controller_class
|
22
29
|
options[:controller_class] || example.described_class
|
@@ -51,6 +58,8 @@ module EacActiveScaffold
|
|
51
58
|
def valid_update_data
|
52
59
|
options[OPTION_VALID_UPDATE_DATA] || valid_data
|
53
60
|
end
|
61
|
+
|
62
|
+
require_sub __FILE__, require_mode: :kernel
|
54
63
|
end
|
55
64
|
end
|
56
65
|
end
|
@@ -24,9 +24,7 @@ require 'eac_active_scaffold/rspec/controller_director'
|
|
24
24
|
before do
|
25
25
|
before_create_count
|
26
26
|
click_on ::I18n.t('active_scaffold.create_new')
|
27
|
-
director.
|
28
|
-
fill_in director.attribute_label(key), with: value
|
29
|
-
end
|
27
|
+
director.attributes_set(self, director.valid_create_data)
|
30
28
|
click_on ::I18n.t('active_scaffold.create')
|
31
29
|
end
|
32
30
|
|
@@ -52,9 +50,7 @@ require 'eac_active_scaffold/rspec/controller_director'
|
|
52
50
|
before do
|
53
51
|
before_update_count
|
54
52
|
click_link(*edit_link_args)
|
55
|
-
director.
|
56
|
-
fill_in director.attribute_label(key), with: value
|
57
|
-
end
|
53
|
+
director.attributes_set(self, director.valid_update_data)
|
58
54
|
click_on ::I18n.t('active_scaffold.update')
|
59
55
|
end
|
60
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_active_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_scaffold
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/eac_active_scaffold/patches/action_dispatch.rb
|
85
85
|
- lib/eac_active_scaffold/rspec.rb
|
86
86
|
- lib/eac_active_scaffold/rspec/controller_director.rb
|
87
|
+
- lib/eac_active_scaffold/rspec/controller_director/attribute_set.rb
|
87
88
|
- lib/eac_active_scaffold/rspec/setup.rb
|
88
89
|
- lib/eac_active_scaffold/rspec/shared_contexts/active_scaffold_controller.rb
|
89
90
|
- lib/eac_active_scaffold/version.rb
|