Skip to content

Commit

Permalink
Add Specs for config.ignored_models
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Feb 10, 2019
1 parent 72c38e7 commit 86a26ed
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/active_record/annotate/configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +23,7 @@ def initialize

def reset
@yard = false
@annotate_ignore = []
@ignored_models = []
end

end
Expand Down
11 changes: 11 additions & 0 deletions spec/active_record/annotate/configurator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
12 changes: 12 additions & 0 deletions spec/active_record/annotate/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
require 'active_record/annotate'
require 'pry'
require 'awesome_print'

class User < ActiveRecord::Base
### Define User constant
end

0 comments on commit 86a26ed

Please sign in to comment.