Skip to content

Commit

Permalink
add annotate_models config test
Browse files Browse the repository at this point in the history
  • Loading branch information
Adeynack committed Nov 15, 2023
1 parent 756f71c commit df61c0c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/lib/tasks/annotate_models_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative '../../spec_helper'

describe 'annotate_models rake task and Annotate.set_defaults' do
before do
Rake.application = Rake::Application.new
Rake::Task.define_task('environment')
Rake.load_rakefile('tasks/annotate_models.rake')
end

let(:annotate_models_argument) do
argument = nil
expect(AnnotateModels).to receive(:do_annotations) { |arg| argument = arg }
Rake::Task['annotate_models'].invoke
argument
end

describe 'with_comment_column' do
after { ENV.delete('with_comment_column') }
subject { annotate_models_argument[:with_comment_column] }

context 'when Annotate.set_defaults is not called (defaults)' do
it { is_expected.to be_falsey }
end

context 'when Annotate.set_defaults sets it to "true"' do
before { Annotate.set_defaults('with_comment_column' => 'true') }
it { is_expected.to be_truthy }
end
end
end

0 comments on commit df61c0c

Please sign in to comment.