diff --git a/.rubocop.yml b/.rubocop.yml index fe81d71..2f54469 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,8 @@ require: AllCops: TargetRubyVersion: 2.5 NewCops: enable + Exclude: + - prawn-swiss_qr_bill.gemspec # Prawn is descriptive and needs more branches (methods) Metrics/AbcSize: @@ -21,9 +23,11 @@ RSpec/ExampleLength: # Unlimited block length for specs Metrics/BlockLength: - IgnoredMethods: ['describe'] + AllowedMethods: ['describe'] Lint/AmbiguousBlockAssociation: Exclude: - 'spec/**/*' +RSpec/NoExpectationExample: + Enabled: false diff --git a/lib/prawn/swiss_qr_bill/qr/data.rb b/lib/prawn/swiss_qr_bill/qr/data.rb index 565dc76..3dba47e 100644 --- a/lib/prawn/swiss_qr_bill/qr/data.rb +++ b/lib/prawn/swiss_qr_bill/qr/data.rb @@ -76,12 +76,12 @@ def initialize(fields = {}, options = {}) # set defaults FIELDS.each_key do |field| - instance_variable_set("@#{field}", FIELDS[field].default) + instance_variable_set(:"@#{field}", FIELDS[field].default) end # set given fields.each_key do |field| - instance_variable_set("@#{field}", fields[field]) + instance_variable_set(:"@#{field}", fields[field]) end end @@ -90,7 +90,7 @@ def generate stack = [] FIELDS.each_key do |k| - var = instance_variable_get("@#{k}") + var = instance_variable_get(:"@#{k}") # TODO: fix possible wrong format if alt parameters (last one) is given next if FIELDS[k][:skippable] && var.nil? @@ -105,9 +105,9 @@ def generate def process FIELDS.each_key do |k| - var = instance_variable_get("@#{k}") + var = instance_variable_get(:"@#{k}") - instance_variable_set("@#{k}", FIELDS[k][:format].call(var)) if FIELDS[k][:format].is_a?(Proc) + instance_variable_set(:"@#{k}", FIELDS[k][:format].call(var)) if FIELDS[k][:format].is_a?(Proc) end end @@ -115,7 +115,7 @@ def validate FIELDS.each_key do |k| next unless FIELDS[k][:validation] - var = instance_variable_get("@#{k}") + var = instance_variable_get(:"@#{k}") call_validator(FIELDS[k][:validation], var) end @@ -133,7 +133,7 @@ def call_validator(validator, value) validator.call(value) # :nocov: when Symbol - send("#{validator}_validator", value) + send(:"#{validator}_validator", value) end end diff --git a/lib/prawn/swiss_qr_bill/specifications.rb b/lib/prawn/swiss_qr_bill/specifications.rb index 6cdb4d8..b6537e5 100644 --- a/lib/prawn/swiss_qr_bill/specifications.rb +++ b/lib/prawn/swiss_qr_bill/specifications.rb @@ -19,10 +19,10 @@ class Specifications height: Spec.new(nil, ->(v) { from_mm(v) }), content_font_size: Spec.new, content_font_leading: Spec.new(0), - content_font_style: Spec.new(:normal, ->(v) { v.to_sym }), + content_font_style: Spec.new(:normal, lambda(&:to_sym)), label_font_size: Spec.new, label_font_leading: Spec.new(0), - label_font_style: Spec.new(:bold, ->(v) { v.to_sym }) + label_font_style: Spec.new(:bold, lambda(&:to_sym)) }.freeze def initialize diff --git a/spec/features/compatibility_spec.rb b/spec/features/compatibility_spec.rb index 3d3851e..c31bee1 100644 --- a/spec/features/compatibility_spec.rb +++ b/spec/features/compatibility_spec.rb @@ -8,7 +8,7 @@ describe '#swiss_qr_bill' do context 'when one argument is given' do - it 'works' do + it 'works without arguments' do document.swiss_qr_bill(bill_full) end end diff --git a/spec/features/pdf_generation_spec.rb b/spec/features/pdf_generation_spec.rb index ffeb60e..61df30a 100644 --- a/spec/features/pdf_generation_spec.rb +++ b/spec/features/pdf_generation_spec.rb @@ -11,7 +11,7 @@ end before do - FileUtils.rm(outfile) if File.exist?(outfile) + FileUtils.rm_f(outfile) end after do |spec| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 928585e..0b73469 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,4 +30,4 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f } # Ensure tmp dir -FileUtils.mkdir(TMP_DIR) unless Dir.exist?(TMP_DIR) +FileUtils.mkdir_p(TMP_DIR)