Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
joel committed Sep 5, 2023
1 parent a4c34aa commit f6bd9c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/csvbuilder/importer/concerns/import/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions spec/csvbuilder/importer/internal/import/attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/csvbuilder/importer/public/import/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ 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 []

row = instance.next
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
Expand Down

0 comments on commit f6bd9c9

Please sign in to comment.