diff --git a/lib/active_record/annotate/configurator.rb b/lib/active_record/annotate/configurator.rb index c82679e..12d2c82 100644 --- a/lib/active_record/annotate/configurator.rb +++ b/lib/active_record/annotate/configurator.rb @@ -7,7 +7,7 @@ class Configurator end attr_accessor :ignored_models - def annotate_ignore=(models) + def ignored_models=(models) if models.is_a?(Array) @ignored_models = models else @@ -23,7 +23,7 @@ def initialize def reset @yard = false - @annotate_ignore = [] + @ignored_models = [] end end diff --git a/spec/active_record/annotate/configurator_spec.rb b/spec/active_record/annotate/configurator_spec.rb index 09c1d77..48d6c51 100644 --- a/spec/active_record/annotate/configurator_spec.rb +++ b/spec/active_record/annotate/configurator_spec.rb @@ -4,6 +4,7 @@ describe "#initialize" do it "resets all settings to their default values" do expect(subject.yard).to be_falsy + expect(subject.ignored_models).to eq([]) end end @@ -13,6 +14,16 @@ subject.yard = true expect(subject.yard).to be_truthy + + expect(subject.ignored_models).to eq([]) + + subject.ignored_models = [:foobar] + subject.ignored_models.push(:bar) + expect(subject.ignored_models).to eq([:foobar, :bar]) + + expect { + subject.ignored_models = "bad value" + }.to raise_exception(StandardError) end end end diff --git a/spec/active_record/annotate/file_spec.rb b/spec/active_record/annotate/file_spec.rb index 7cfba27..8a66759 100644 --- a/spec/active_record/annotate/file_spec.rb +++ b/spec/active_record/annotate/file_spec.rb @@ -52,6 +52,18 @@ class User < ActiveRecord::Base # t.integer :age, null: false, default: 0 # end +class User < ActiveRecord::Base + has_many :posts +end + FILE + end + + let(:expected_ignored_result) do + <<-FILE +# enCoding: utf-8 +# frozen_string_literal: true +# warn_indent: true + class User < ActiveRecord::Base has_many :posts end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9929083..5a34c88 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,3 +2,7 @@ require 'active_record/annotate' require 'pry' require 'awesome_print' + +class User < ActiveRecord::Base + ### Define User constant +end