eac_rails_utils 0.8.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper.rb +8 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder.rb +12 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/association_select_field.rb +5 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/common_text_fields.rb +4 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/currency_field.rb +14 -12
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/date_field.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/fields_for.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/file_field.rb +2 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/radio_select_field.rb +5 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/searchable_association_field.rb +7 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/select_field.rb +3 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/time_field.rb +2 -1
- data/{lib/eac → app/helpers/eac_rails_utils}/common_form_helper/form_builder/year_month_field.rb +2 -1
- data/app/helpers/eac_rails_utils/data_table_helper.rb +13 -0
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/column.rb +6 -3
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/data_table.rb +13 -11
- data/{lib/eac → app/helpers/eac_rails_utils}/data_table_helper/setup.rb +3 -2
- data/app/helpers/eac_rails_utils/formatter_helper.rb +2 -0
- data/app/helpers/eac_rails_utils/links_helper.rb +12 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper.rb +10 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/bootstrap_gui_builder.rb +8 -5
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/data_builder.rb +7 -2
- data/{lib/eac → app/helpers/eac_rails_utils}/menus_helper/gui_builder.rb +6 -3
- data/app/helpers/eac_rails_utils/open_graph_protocol_helper.rb +2 -0
- data/{lib/eac → app/validators/eac_rails_utils}/cpf_validator.rb +8 -4
- data/{lib/eac → app/validators/eac_rails_utils}/no_presence_validator.rb +3 -3
- data/lib/assets/javascripts/jMenu.jquery.min.js +12 -12
- data/lib/eac_rails_utils.rb +3 -41
- data/lib/eac_rails_utils/engine.rb +3 -0
- data/lib/{eac → eac_rails_utils}/htmlbeautifier.rb +3 -1
- data/lib/eac_rails_utils/models.rb +9 -0
- data/lib/eac_rails_utils/models/attribute_required.rb +43 -0
- data/lib/eac_rails_utils/models/fetch_errors.rb +92 -0
- data/lib/eac_rails_utils/models/inequality_queries.rb +39 -0
- data/lib/eac_rails_utils/models/tableless.rb +97 -0
- data/lib/eac_rails_utils/models/test_utils.rb +65 -0
- data/lib/eac_rails_utils/patches.rb +9 -0
- data/lib/eac_rails_utils/patches/action_controller_base.rb +3 -0
- data/lib/eac_rails_utils/version.rb +2 -1
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/models/job.rb +2 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/boot.rb +3 -1
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/db/migrate/20160415125333_create_users.rb +2 -0
- data/test/dummy/db/migrate/20160415143123_create_jobs.rb +2 -0
- data/test/dummy/db/migrate/20160415143229_add_job_to_users.rb +2 -0
- data/test/{lib/eac → helpers/eac_rails_utils}/common_form_helper_test.rb +4 -2
- data/test/{lib/eac/data_table_test_helper.rb → helpers/eac_rails_utils/data_table_test_helper_test.rb} +4 -3
- data/test/{app/helpers → helpers}/eac_rails_utils/formatter_helper_test.rb +1 -0
- data/test/lib/eac_rails_utils/{patches/model_attribute_required_test.rb → models/attribute_required_test.rb} +3 -0
- data/test/lib/eac_rails_utils/models/fetch_errors_test.rb +80 -0
- data/test/lib/eac_rails_utils/models/tableless_test.rb +25 -0
- data/test/test_helper.rb +3 -1
- data/test/{lib/eac → validators}/cpf_validator_test.rb +4 -2
- metadata +91 -98
- data/lib/eac/data_table_helper.rb +0 -12
- data/lib/eac/inequality_queries.rb +0 -36
- data/lib/eac/model.rb +0 -87
- data/lib/eac/parsers/files_test.rb +0 -63
- data/lib/eac/source_target_fixtures.rb +0 -66
- data/lib/eac/test_utils.rb +0 -56
- data/lib/eac_rails_utils/patches/model_attribute_required.rb +0 -31
- data/lib/eac_rails_utils/patches/ofx_parser.rb +0 -42
- data/lib/eac_rails_utils/tableless_model.rb +0 -90
- data/test/lib/eac/model_test.rb +0 -76
- data/test/lib/eac/parsers/files_test_test.rb +0 -27
- data/test/lib/eac/parsers/ok_test_files/a.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/a.target.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.target.yaml +0 -1
- data/test/lib/eac/source_target_fixtures_test.rb +0 -41
- data/test/lib/eac/source_target_fixtures_test_files/a.source.html +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/a.target.yaml +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/b.source.html +0 -1
- data/test/lib/eac/source_target_fixtures_test_files/c.target.yaml +0 -1
- data/test/lib/eac_rails_utils/tableless_model_test.rb +0 -23
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
module Eac
|
5
|
-
module Parsers
|
6
|
-
module FilesTest
|
7
|
-
def test_data
|
8
|
-
if ENV['EAC_PARSERS_FILES_TEST_WRITE'].present?
|
9
|
-
write_results
|
10
|
-
else
|
11
|
-
test_results
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def source_data(source_file)
|
18
|
-
parser_class.new(source_file).data
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_results
|
22
|
-
sts = source_target_fixtures.source_target_files
|
23
|
-
assert_not_equal 0, sts.count, 'Source/target files count cannot be zero'
|
24
|
-
sts.each do |st|
|
25
|
-
assert_source_target_complete(st)
|
26
|
-
sd = source_data(st.source)
|
27
|
-
td = YAML.load_file(st.target)
|
28
|
-
assert_equal sort_results(td), sort_results(sd)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def write_results
|
33
|
-
source_target_fixtures.source_files.each do |source_file|
|
34
|
-
sd = sort_results(source_data(source_file))
|
35
|
-
basename = ::Eac::SourceTargetFixtures.source_target_basename(source_file)
|
36
|
-
target_file = File.expand_path("../#{basename}.target.yaml", source_file)
|
37
|
-
File.write(target_file, sd.to_yaml)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def sort_results(r)
|
42
|
-
r
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def assert_source_target_complete(st)
|
48
|
-
assert st.source, "Source not found (Target: #{st.target})"
|
49
|
-
assert st.target, "Target not found (Source: #{st.source})"
|
50
|
-
end
|
51
|
-
|
52
|
-
def source_target_fixtures
|
53
|
-
@source_target_fixtures ||= ::Eac::SourceTargetFixtures.new(
|
54
|
-
File.expand_path("../#{self.class.name.demodulize.underscore}_files", test_file)
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def parser_class
|
59
|
-
self.class.name.gsub(/Test\z/, '').constantize
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
module Eac
|
7
|
-
# Lists pairs of source/target files in a directory. See {Eac::Parsers::FilesTest} to see
|
8
|
-
# a use of this class.
|
9
|
-
class SourceTargetFixtures
|
10
|
-
class << self
|
11
|
-
def source_target_basename(file)
|
12
|
-
m = /^(.+)\.(?:source|target)(?:\..+)?$/.match(File.basename(file))
|
13
|
-
m ? m[1] : nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :fixtures_directory
|
18
|
-
|
19
|
-
def initialize(fixtures_directory)
|
20
|
-
@fixtures_directory = fixtures_directory
|
21
|
-
end
|
22
|
-
|
23
|
-
def source_target_files
|
24
|
-
sources_targets_basenames.map do |basename|
|
25
|
-
OpenStruct.new(source: source_file(basename), target: target_file(basename))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def source_files
|
30
|
-
r = []
|
31
|
-
source_target_files.each do |st|
|
32
|
-
r << st.source if st.source
|
33
|
-
end
|
34
|
-
r
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def target_file(basename)
|
40
|
-
fixture_file(basename, 'target')
|
41
|
-
end
|
42
|
-
|
43
|
-
def source_file(basename)
|
44
|
-
fixture_file(basename, 'source')
|
45
|
-
end
|
46
|
-
|
47
|
-
def fixture_file(basename, suffix)
|
48
|
-
prefix = "#{basename}.#{suffix}"
|
49
|
-
Dir.foreach(fixtures_directory) do |item|
|
50
|
-
next if item == '.' || item == '..'
|
51
|
-
return File.expand_path(item, fixtures_directory) if item.starts_with?(prefix)
|
52
|
-
end
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def sources_targets_basenames
|
57
|
-
basenames = Set.new
|
58
|
-
Dir.foreach(fixtures_directory) do |item|
|
59
|
-
next if item == '.' || item == '..'
|
60
|
-
b = self.class.source_target_basename(item)
|
61
|
-
basenames << b if b.present?
|
62
|
-
end
|
63
|
-
basenames
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/eac/test_utils.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Eac
|
3
|
-
module TestUtils
|
4
|
-
# Add more helper methods to be used by all tests here...
|
5
|
-
def valid_invalid_column_values_test(record, column, valid_values, invalid_values)
|
6
|
-
valid_values.each do |v|
|
7
|
-
record.send("#{column}=", v)
|
8
|
-
assert record.valid?, "#{record.errors.messages}, #{column} = #{v.inspect} should be valid"
|
9
|
-
end
|
10
|
-
invalid_values.each do |v|
|
11
|
-
record.send("#{column}=", v)
|
12
|
-
assert_not record.valid?, "#{column} = #{v.inspect} should be invalid"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Verifica falhas em campos específicos de um record
|
17
|
-
def assert_record_errors(record, fields_without_error, fields_with_error)
|
18
|
-
fields_without_error.each do |c|
|
19
|
-
assert record.errors[c].empty?, "Column: #{c} should not have errors (#{record.errors[c]})"
|
20
|
-
end
|
21
|
-
fields_with_error. each do |c|
|
22
|
-
assert_not record.errors[c].empty?, "Column: #{c} should have errors"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Verifica, campo por campo, se invalida o registro.
|
27
|
-
def assert_column_changes(ppp, expected_valid_result, changes)
|
28
|
-
changes.each do |k, v|
|
29
|
-
ppp.send("#{k}=", v)
|
30
|
-
assert_equal expected_valid_result, ppp.valid?, "\"#{k}\" change should be " +
|
31
|
-
(expected_valid_result ? 'valid' : 'invalid')
|
32
|
-
assert_not ppp.errors[k].empty? unless expected_valid_result
|
33
|
-
ppp.restore_attributes
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Ex.: attrs = {a: 1, b: 2} resulta em
|
38
|
-
# [{a: nil, b: nil}, {a: 1, b: nil}, {a: nil, b: 2}, {a: 1, b: 2}].
|
39
|
-
def all_combinations(attrs)
|
40
|
-
combs = [{}]
|
41
|
-
attrs.each do |attr_name, value|
|
42
|
-
new_comb = []
|
43
|
-
assert_not value.nil?, "#{attr_name}=#{value}"
|
44
|
-
[nil, value].each do |vv|
|
45
|
-
combs.each do |c|
|
46
|
-
cc = c.dup
|
47
|
-
cc[attr_name] = vv
|
48
|
-
new_comb << cc
|
49
|
-
end
|
50
|
-
end
|
51
|
-
combs = new_comb
|
52
|
-
end
|
53
|
-
combs
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
module EacRailsUtils
|
4
|
-
module Patches
|
5
|
-
module ModelAttributeRequired
|
6
|
-
def self.included(base)
|
7
|
-
base.extend ClassMethods
|
8
|
-
base.include InstanceMethods
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
12
|
-
def column_required?(column)
|
13
|
-
m = new
|
14
|
-
m.validate
|
15
|
-
m.errors.key?(column.to_sym)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module InstanceMethods
|
20
|
-
def attribute_required?(column)
|
21
|
-
self.class.column_required?(column)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
[::ActiveRecord::Base, ::ActiveModel::Model].each do |c|
|
29
|
-
next if c.included_modules.include? ::EacRailsUtils::Patches::ModelAttributeRequired
|
30
|
-
c.include ::EacRailsUtils::Patches::ModelAttributeRequired
|
31
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'ofx-parser'
|
3
|
-
|
4
|
-
module EacRailsUtils
|
5
|
-
module Patches
|
6
|
-
module OfxParser
|
7
|
-
module OfxParser
|
8
|
-
def self.included(base)
|
9
|
-
base.class_eval do
|
10
|
-
class << self
|
11
|
-
prepend ClassMethods
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module ClassMethods
|
17
|
-
def build_transaction(t)
|
18
|
-
r = super
|
19
|
-
r.currate = (t / 'CURRENCY/CURRATE').inner_text
|
20
|
-
r
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module Transaction
|
26
|
-
attr_accessor :currate, :cursym
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
unless ::OfxParser::OfxParser.included_modules.include?(
|
33
|
-
::EacRailsUtils::Patches::OfxParser::OfxParser
|
34
|
-
)
|
35
|
-
::OfxParser::OfxParser.send(:include, ::EacRailsUtils::Patches::OfxParser::OfxParser)
|
36
|
-
end
|
37
|
-
|
38
|
-
unless ::OfxParser::Transaction.included_modules.include?(
|
39
|
-
::EacRailsUtils::Patches::OfxParser::Transaction
|
40
|
-
)
|
41
|
-
::OfxParser::Transaction.send(:include, ::EacRailsUtils::Patches::OfxParser::Transaction)
|
42
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module EacRailsUtils
|
3
|
-
class TablelessModel
|
4
|
-
include ActiveModel::Model
|
5
|
-
include Virtus.model
|
6
|
-
include ActiveModel::Associations
|
7
|
-
|
8
|
-
def initialize(values = {})
|
9
|
-
super(build_attributes(values))
|
10
|
-
end
|
11
|
-
|
12
|
-
def attributes=(values)
|
13
|
-
super(build_attributes(values))
|
14
|
-
end
|
15
|
-
|
16
|
-
# need hash like accessor, used internal Rails
|
17
|
-
def [](attr)
|
18
|
-
send(attr)
|
19
|
-
end
|
20
|
-
|
21
|
-
# need hash like accessor, used internal Rails
|
22
|
-
def []=(attr, value)
|
23
|
-
send("#{attr}=", value)
|
24
|
-
end
|
25
|
-
|
26
|
-
def save!
|
27
|
-
save || raise("#{self.class}.save failed: #{errors.messages}")
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def build_attributes(values)
|
33
|
-
AttributesBuilder.new(self.class, values).to_attributes
|
34
|
-
end
|
35
|
-
|
36
|
-
class AttributesBuilder
|
37
|
-
DATE_TIME_FIELDS = %i(year month day hour min sec).freeze
|
38
|
-
|
39
|
-
def initialize(model_class, values)
|
40
|
-
@model_class = model_class
|
41
|
-
@values = {}
|
42
|
-
values.each { |k, v| add(k, v) }
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_attributes
|
46
|
-
@values
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def add(key, value)
|
52
|
-
array_attr = parse_array_attr_key(key)
|
53
|
-
if array_attr
|
54
|
-
array_value_set(array_attr, value)
|
55
|
-
else
|
56
|
-
@values[key] = value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def parse_array_attr_key(key)
|
61
|
-
m = /\A(.+)\(([0-9]+)(.)\)\z/.match(key)
|
62
|
-
if m
|
63
|
-
::OpenStruct.new(key: m[1], index: m[2].to_i - 1, converter: array_value_converter(m[3]))
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def array_value_set(array_attr, value)
|
68
|
-
@values[array_attr.key] ||= {}
|
69
|
-
@values[array_attr.key].merge!(
|
70
|
-
DATE_TIME_FIELDS[array_attr.index] => value.send(array_attr.converter)
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
def array_value_converter(str_type)
|
75
|
-
case str_type
|
76
|
-
when 'i'
|
77
|
-
'to_i'
|
78
|
-
else
|
79
|
-
raise "Unknown array type: \"#{str_type}\""
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def date_time_attribute?(key)
|
84
|
-
attr = @model_class.attributes[key]
|
85
|
-
return false unless attr
|
86
|
-
raise attr.to_s
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
data/test/lib/eac/model_test.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Eac
|
4
|
-
class ModelTest < ActiveSupport::TestCase
|
5
|
-
class M1
|
6
|
-
include ActiveModel::Model
|
7
|
-
include Eac::Model
|
8
|
-
attr_accessor :name, :age, :account, :country_id, :other
|
9
|
-
end
|
10
|
-
|
11
|
-
class M2
|
12
|
-
include ActiveModel::Model
|
13
|
-
attr_accessor :name, :myage, :account_id, :country
|
14
|
-
|
15
|
-
validate :my_validate
|
16
|
-
|
17
|
-
def my_validate
|
18
|
-
errors.add(:name, 'NAME_ERROR')
|
19
|
-
errors.add(:myage, 'MYAGE_ERROR')
|
20
|
-
errors.add(:account_id, 'ACCOUNT_ID_ERROR')
|
21
|
-
errors.add(:country, 'COUNTRY_ERROR')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def setup
|
26
|
-
reset_m1
|
27
|
-
reset_m2
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_fetch_column_errors
|
31
|
-
@m1.fetch_column_errors(@m2, :myage, :age)
|
32
|
-
assert_equal @m2.errors[:myage], @m1.errors[:age]
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_fetch_record_errors
|
36
|
-
@m1.fetch_record_errors(@m2)
|
37
|
-
{ name: :name, account_id: :account, country: :country_id }.each do |c2, c1|
|
38
|
-
assert_equal @m2.errors[c2], @m1.errors[c1], "c2: #{c2}, c1: #{c1}"
|
39
|
-
end
|
40
|
-
assert @m1.errors[:age].empty?
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_fetch_record_errors_with_default_column
|
44
|
-
@m1.fetch_record_errors(@m2, default_column: :other)
|
45
|
-
assert_equal @m2.errors[:name], @m1.errors[:name]
|
46
|
-
assert @m1.errors[:age].empty?
|
47
|
-
assert_equal ['Myage: MYAGE_ERROR'], @m1.errors[:other]
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_fetch_record_errors_with_skip_option
|
51
|
-
@m1.fetch_record_errors(@m2, skip: [:name])
|
52
|
-
assert @m1.errors[:name].empty?
|
53
|
-
assert @m1.errors[:age].empty?
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_fetch_record_errors_by_mapping
|
57
|
-
@m1.fetch_record_errors_by_mapping(@m2, name: :name, myage: :age)
|
58
|
-
assert_equal @m2.errors[:name], @m1.errors[:name]
|
59
|
-
assert_equal @m2.errors[:myage], @m1.errors[:age]
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def reset_m1
|
65
|
-
@m1 = M1.new
|
66
|
-
assert @m1.errors.empty?
|
67
|
-
end
|
68
|
-
|
69
|
-
def reset_m2
|
70
|
-
@m2 = M2.new
|
71
|
-
assert_not @m2.valid?
|
72
|
-
assert_not @m2.errors[:name].empty?
|
73
|
-
assert_not @m2.errors[:myage].empty?
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
module Eac
|
5
|
-
module Parsers
|
6
|
-
class BaseStub
|
7
|
-
def initialize(source)
|
8
|
-
@source = source
|
9
|
-
end
|
10
|
-
|
11
|
-
def data
|
12
|
-
YAML.load(File.read(@source))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Ok < BaseStub
|
17
|
-
end
|
18
|
-
|
19
|
-
class OkTest < ActiveSupport::TestCase
|
20
|
-
include ::Eac::Parsers::FilesTest
|
21
|
-
|
22
|
-
def test_file
|
23
|
-
__FILE__
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|