|
31 | 31 |
|
32 | 32 | let(:task_model) do
|
33 | 33 | patch = <<~PATCH
|
34 |
| - +# == Schema Information |
35 |
| - +# |
36 |
| - +# Table name: tasks |
37 |
| - +# |
38 |
| - +# id :integer not null, primary key |
39 |
| - +# content :string |
40 |
| - +# count :integer default("0") |
41 |
| - +# status :boolean default("0") |
42 |
| - +# created_at :datetime not null |
43 |
| - +# updated_at :datetime not null |
44 |
| - +# |
| 34 | + +# == Schema Information |
| 35 | + +# |
| 36 | + +# Table name: tasks |
| 37 | + +# |
| 38 | + +# id :integer not null, primary key |
| 39 | + +# content :string |
| 40 | + +# count :integer default("0") |
| 41 | + +# status :boolean default("0") |
| 42 | + +# created_at :datetime not null |
| 43 | + +# updated_at :datetime not null |
| 44 | + +# |
45 | 45 | PATCH
|
46 | 46 |
|
47 | 47 | path = 'app/models/task.rb'
|
|
52 | 52 | end
|
53 | 53 | let(:task_test) do
|
54 | 54 | patch = <<~PATCH
|
55 |
| - +# == Schema Information |
56 |
| - +# |
57 |
| - +# Table name: tasks |
58 |
| - +# |
59 |
| - +# id :integer not null, primary key |
60 |
| - +# content :string |
61 |
| - +# count :integer default("0") |
62 |
| - +# status :boolean default("0") |
63 |
| - +# created_at :datetime not null |
64 |
| - +# updated_at :datetime not null |
65 |
| - +# |
| 55 | + +# == Schema Information |
| 56 | + +# |
| 57 | + +# Table name: tasks |
| 58 | + +# |
| 59 | + +# id :integer not null, primary key |
| 60 | + +# content :string |
| 61 | + +# count :integer default("0") |
| 62 | + +# status :boolean default("0") |
| 63 | + +# created_at :datetime not null |
| 64 | + +# updated_at :datetime not null |
| 65 | + +# |
66 | 66 | PATCH
|
67 | 67 |
|
68 | 68 | path = 'test/models/task_test.rb'
|
|
73 | 73 | end
|
74 | 74 | let(:task_fixture) do
|
75 | 75 | patch = <<~PATCH
|
76 |
| - +# == Schema Information |
77 |
| - +# |
78 |
| - +# Table name: tasks |
79 |
| - +# |
80 |
| - +# id :integer not null, primary key |
81 |
| - +# content :string |
82 |
| - +# count :integer default("0") |
83 |
| - +# status :boolean default("0") |
84 |
| - +# created_at :datetime not null |
85 |
| - +# updated_at :datetime not null |
86 |
| - +# |
| 76 | + +# == Schema Information |
| 77 | + +# |
| 78 | + +# Table name: tasks |
| 79 | + +# |
| 80 | + +# id :integer not null, primary key |
| 81 | + +# content :string |
| 82 | + +# count :integer default("0") |
| 83 | + +# status :boolean default("0") |
| 84 | + +# created_at :datetime not null |
| 85 | + +# updated_at :datetime not null |
| 86 | + +# |
87 | 87 | PATCH
|
88 | 88 |
|
89 | 89 | path = 'test/fixtures/tasks.yml'
|
|
101 | 101 | puts `#{command}`
|
102 | 102 |
|
103 | 103 | expect(git.diff.entries).to contain_exactly(
|
104 |
| - an_object_having_attributes(task_model), |
105 |
| - an_object_having_attributes(task_test), |
106 |
| - an_object_having_attributes(task_fixture) |
107 |
| - ) |
| 104 | + an_object_having_attributes(task_model), |
| 105 | + an_object_having_attributes(task_test), |
| 106 | + an_object_having_attributes(task_fixture) |
| 107 | + ) |
| 108 | + end |
| 109 | + end |
| 110 | + end |
| 111 | + end |
| 112 | + |
| 113 | + describe 'annotate --routes' do |
| 114 | + let(:command) { 'bundle exec annotate --routes' } |
| 115 | + |
| 116 | + let(:task_routes) do |
| 117 | + task_routes_diff = <<-DIFF |
| 118 | ++# == Route Map |
| 119 | ++# |
| 120 | ++# Prefix Verb URI Pattern Controller#Action |
| 121 | ++# tasks GET /tasks(.:format) tasks#index |
| 122 | ++# POST /tasks(.:format) tasks#create |
| 123 | ++# new_task GET /tasks/new(.:format) tasks#new |
| 124 | ++# edit_task GET /tasks/:id/edit(.:format) tasks#edit |
| 125 | ++# task GET /tasks/:id(.:format) tasks#show |
| 126 | ++# PATCH /tasks/:id(.:format) tasks#update |
| 127 | ++# PUT /tasks/:id(.:format) tasks#update |
| 128 | ++# DELETE /tasks/:id(.:format) tasks#destroy |
| 129 | + DIFF |
| 130 | + |
| 131 | + default_routes_diff = <<-DIFF |
| 132 | ++# rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show |
| 133 | ++# rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show |
| 134 | ++# rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show |
| 135 | ++# update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update |
| 136 | ++# rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create |
| 137 | + DIFF |
| 138 | + |
| 139 | + path = 'config/routes.rb' |
| 140 | + { |
| 141 | + path: include(path), |
| 142 | + patch: include(task_routes_diff, default_routes_diff) |
| 143 | + } |
| 144 | + end |
| 145 | + |
| 146 | + it 'annotate routes.rb' do |
| 147 | + Bundler.with_clean_env do |
| 148 | + Dir.chdir app_path do |
| 149 | + expect(git.diff.any?).to be_falsy |
| 150 | + |
| 151 | + puts `#{command}` |
| 152 | + |
| 153 | + expect(git.diff.entries).to include( |
| 154 | + an_object_having_attributes(task_routes) |
| 155 | + ) |
108 | 156 | end
|
109 | 157 | end
|
110 | 158 | end
|
|
0 commit comments