-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathannotate_only_file_patterns_spec.rb
More file actions
31 lines (22 loc) · 1.31 KB
/
annotate_only_file_patterns_spec.rb
File metadata and controls
31 lines (22 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
require "integration_spec_helper"
RSpec.describe "Annotate with only_file_patterns specified", type: "aruba" do
let(:command_timeout_seconds) { 10 }
let(:migration_file) { "20231013230731_add_int_field_to_test_defaults.rb" }
let(:models_dir) { "app/models" }
it "avoids annotating a model not given" do
reset_database
run_migrations
# Start with the already annotated TestDefault model
copy(model_template("test_default.rb"), models_dir)
original_test_default = read_file(dummyapp_model("test_default.rb"))
copy(File.join(migrations_template_dir, migration_file), "db/migrate")
# Apply this specific migration
_run_migrations_cmd = run_command_and_stop("bin/rails db:migrate:up VERSION=20231013230731", fail_on_error: true, exit_timeout: command_timeout_seconds)
_run_annotations_cmd = run_command_and_stop("bundle exec annotaterb models --only-file-patterns=nonexistent_model.rb", fail_on_error: true, exit_timeout: command_timeout_seconds)
annotated_test_default = read_file(dummyapp_model("test_default.rb"))
# Because the model we restricted ourselves to doesn't exist, we expect the file to remain untouched
expect(last_command_started).to be_successfully_executed
expect(annotated_test_default).to eq(original_test_default)
end
end