eac_active_scaffold 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97c012d3f0f8e7e4471a86abdffc2909783da3973fb4289870b672480b618c28
4
- data.tar.gz: 3801ffdf4e9b3c608d077b151ce25fad53aa787e67a948314a42bc8f998b5dbd
3
+ metadata.gz: 0afe61c33b10658e4cc09606b154fbec009e7aa2869dccaa847d688d55c1998f
4
+ data.tar.gz: 2b340b542c9b00657c956c16ea10bab6ee5ecd61bb45cde15272a77aaa6a9451
5
5
  SHA512:
6
- metadata.gz: df68a482be337f5db59d0bfd34826364600d0a8439a9c9ea5b4e646cf64d857f74b16d6cf4111028a0327c16bd3a9cce1715ab0764aeb87aa3737fab47f26629
7
- data.tar.gz: b2d33e2698cb46fc587587569e1bb831f0f0320a7d2e65a0ab8a5864e7ebd373bc682e503c187bf8d0fdb4ac86dabd4a1743b9b7ac0fa5bd769a0af45d355ba2
6
+ metadata.gz: 2680e6c170109dad1a75e92deeff177d5426090236b10dd65d01ee55fc5d35bc080a063d1a592000aadc6833a8cafc95893a51a086ffbf9711de0efbbbc8a8a7
7
+ data.tar.gz: b44620f387eaf697ccaac0739cc1fec9bf73f7052e732961078f75ad32b75b9736d1ecbeb0f8b665880a5f8914fa29a7cbc125be81cd872ab75ca6eef6e170da
@@ -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.valid_create_data.each do |key, value|
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.valid_update_data.each do |key, value|
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacActiveScaffold
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.1'
5
5
  end
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.0
4
+ version: 0.5.1
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-10 00:00:00.000000000 Z
11
+ date: 2023-06-15 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