diff --git a/lib/csvbuilder/importer/concerns/import/attributes.rb b/lib/csvbuilder/importer/concerns/import/attributes.rb index 4b2d5e1..473cb34 100644 --- a/lib/csvbuilder/importer/concerns/import/attributes.rb +++ b/lib/csvbuilder/importer/concerns/import/attributes.rb @@ -45,7 +45,7 @@ def _attribute_objects class_methods do def define_attribute_method(column_name) - return if super { original_attribute(column_name) }.nil? + nil if super { original_attribute(column_name) }.nil? end end end diff --git a/spec/csvbuilder/importer/internal/import/attribute_spec.rb b/spec/csvbuilder/importer/internal/import/attribute_spec.rb index 9486e82..dc91a4a 100644 --- a/spec/csvbuilder/importer/internal/import/attribute_spec.rb +++ b/spec/csvbuilder/importer/internal/import/attribute_spec.rb @@ -8,13 +8,13 @@ module Csvbuilder module Import RSpec.describe Attribute do describe "instance" do - let(:import_errors) { nil } - let(:row_model_class) { Class.new BasicImportModel } - let(:source_value) { "alpha" } - let(:source_row) { [source_value, "original_beta"] } - let(:row_model) { row_model_class.new(source_row) } - let(:options) { {} } - let(:instance) { described_class.new(:alpha, source_value, import_errors, row_model) } + let(:import_errors) { nil } + let(:row_model_class) { Class.new BasicImportModel } + let(:source_value) { "alpha" } + let(:source_row) { [source_value, "original_beta"] } + let(:row_model) { row_model_class.new(source_row) } + let(:options) { {} } + let(:instance) { described_class.new(:alpha, source_value, import_errors, row_model) } it_behaves_like "has_needed_value_methods" @@ -38,6 +38,14 @@ module Import expect(value).to eql("alpha") end end + + context "with import_errors" do + let(:import_errors) { [:whatever] } + + it "returns nil" do + expect(value).to be_nil + end + end end describe "#parsed_value" do diff --git a/spec/csvbuilder/importer/public/import/file_spec.rb b/spec/csvbuilder/importer/public/import/file_spec.rb index 9c6ad70..6b56352 100644 --- a/spec/csvbuilder/importer/public/import/file_spec.rb +++ b/spec/csvbuilder/importer/public/import/file_spec.rb @@ -99,7 +99,7 @@ module Import expect(row.source_row).to eql %w[alpha beta] invalid_row = instance.next - expect(invalid_row).to be_invalid + expect(invalid_row).not_to be_valid expect(invalid_row.errors.full_messages).to eql ["Csv has Any value after quoted field isn't allowed in line 3."] expect(invalid_row.source_row).to eql [] @@ -107,8 +107,8 @@ module Import expect(row).to be_valid expect(row.source_row).to eql %w[lang1 lang2] - expect(instance.next).to be_invalid - expect(instance.next).to be_invalid + expect(instance.next).not_to be_valid + expect(instance.next).not_to be_valid expect(instance.next).to be_nil end end