|
4 | 4 | require_relative 'integration_helper'
|
5 | 5 |
|
6 | 6 | describe 'Integration testing on Rails 6.0.2.1', if: IntegrationHelper.able_to_run?(__FILE__, RUBY_VERSION) do
|
7 |
| - let(:app_name) { 'rails_6.0.2.1' } |
8 |
| - |
9 |
| - let(:project_path) { File.expand_path('../..', __dir__) } |
10 |
| - let!(:app_path) { File.expand_path(app_name, __dir__) } |
11 |
| - |
12 |
| - let!(:git) { Git.open(project_path) } |
13 |
| - |
14 |
| - let(:command) { 'bundle exec annotate --models' } |
15 |
| - let(:migration_command) { 'bin/rails db:migrate' } |
16 |
| - |
17 |
| - let(:task_model) do |
18 |
| - patch = <<~PATCH |
19 |
| - +# == Schema Information |
20 |
| - +# |
21 |
| - +# Table name: tasks |
22 |
| - +# |
23 |
| - +# id :integer not null, primary key |
24 |
| - +# content :string |
25 |
| - +# count :integer default("0") |
26 |
| - +# status :boolean default("0") |
27 |
| - +# created_at :datetime not null |
28 |
| - +# updated_at :datetime not null |
29 |
| - +# |
30 |
| - PATCH |
31 |
| - |
32 |
| - path = 'app/models/task.rb' |
33 |
| - { |
34 |
| - path: include(path), |
35 |
| - patch: include(patch) |
36 |
| - } |
37 |
| - end |
38 |
| - let(:task_test) do |
39 |
| - patch = <<~PATCH |
40 |
| - +# == Schema Information |
41 |
| - +# |
42 |
| - +# Table name: tasks |
43 |
| - +# |
44 |
| - +# id :integer not null, primary key |
45 |
| - +# content :string |
46 |
| - +# count :integer default("0") |
47 |
| - +# status :boolean default("0") |
48 |
| - +# created_at :datetime not null |
49 |
| - +# updated_at :datetime not null |
50 |
| - +# |
51 |
| - PATCH |
52 |
| - |
53 |
| - path = 'test/models/task_test.rb' |
54 |
| - { |
55 |
| - path: include(path), |
56 |
| - patch: include(patch) |
57 |
| - } |
58 |
| - end |
59 |
| - let(:task_fixture) do |
60 |
| - patch = <<~PATCH |
61 |
| - +# == Schema Information |
62 |
| - +# |
63 |
| - +# Table name: tasks |
64 |
| - +# |
65 |
| - +# id :integer not null, primary key |
66 |
| - +# content :string |
67 |
| - +# count :integer default("0") |
68 |
| - +# status :boolean default("0") |
69 |
| - +# created_at :datetime not null |
70 |
| - +# updated_at :datetime not null |
71 |
| - +# |
72 |
| - PATCH |
73 |
| - |
74 |
| - path = 'test/fixtures/tasks.yml' |
75 |
| - { |
76 |
| - path: include(path), |
77 |
| - patch: include(patch) |
78 |
| - } |
79 |
| - end |
| 7 | + ::APP_NAME = 'rails_6.0.2.1'.freeze |
| 8 | + ::PROJECT_PATH = File.expand_path('../..', __dir__) |
| 9 | + ::APP_PATH = File.expand_path(APP_NAME, __dir__) |
| 10 | + ::MIGRATION_COMMAND = 'bin/rails db:migrate'.freeze |
| 11 | + |
| 12 | + let!(:git) { Git.open(PROJECT_PATH) } |
80 | 13 |
|
81 |
| - before do |
| 14 | + before(:all) do |
82 | 15 | Bundler.with_clean_env do
|
83 |
| - Dir.chdir app_path do |
| 16 | + Dir.chdir APP_PATH do |
84 | 17 | puts `bundle install`
|
85 |
| - puts `#{migration_command}` |
| 18 | + puts `#{MIGRATION_COMMAND}` |
86 | 19 | end
|
87 | 20 | end
|
88 | 21 | end
|
89 | 22 |
|
90 |
| - after do |
| 23 | + after(:each) do |
91 | 24 | git.reset_hard
|
92 | 25 | end
|
93 | 26 |
|
94 |
| - it 'annotate models' do |
95 |
| - Bundler.with_clean_env do |
96 |
| - Dir.chdir app_path do |
97 |
| - expect(git.diff.any?).to be_falsy |
| 27 | + describe 'annotate --models' do |
| 28 | + let(:command) { 'bundle exec annotate --models' } |
| 29 | + |
| 30 | + let(:task_model) do |
| 31 | + patch = <<~PATCH |
| 32 | + +# == Schema Information |
| 33 | + +# |
| 34 | + +# Table name: tasks |
| 35 | + +# |
| 36 | + +# id :integer not null, primary key |
| 37 | + +# content :string |
| 38 | + +# count :integer default("0") |
| 39 | + +# status :boolean default("0") |
| 40 | + +# created_at :datetime not null |
| 41 | + +# updated_at :datetime not null |
| 42 | + +# |
| 43 | + PATCH |
| 44 | + |
| 45 | + path = 'app/models/task.rb' |
| 46 | + { |
| 47 | + path: include(path), |
| 48 | + patch: include(patch) |
| 49 | + } |
| 50 | + end |
| 51 | + let(:task_test) do |
| 52 | + patch = <<~PATCH |
| 53 | + +# == Schema Information |
| 54 | + +# |
| 55 | + +# Table name: tasks |
| 56 | + +# |
| 57 | + +# id :integer not null, primary key |
| 58 | + +# content :string |
| 59 | + +# count :integer default("0") |
| 60 | + +# status :boolean default("0") |
| 61 | + +# created_at :datetime not null |
| 62 | + +# updated_at :datetime not null |
| 63 | + +# |
| 64 | + PATCH |
| 65 | + |
| 66 | + path = 'test/models/task_test.rb' |
| 67 | + { |
| 68 | + path: include(path), |
| 69 | + patch: include(patch) |
| 70 | + } |
| 71 | + end |
| 72 | + let(:task_fixture) do |
| 73 | + patch = <<~PATCH |
| 74 | + +# == Schema Information |
| 75 | + +# |
| 76 | + +# Table name: tasks |
| 77 | + +# |
| 78 | + +# id :integer not null, primary key |
| 79 | + +# content :string |
| 80 | + +# count :integer default("0") |
| 81 | + +# status :boolean default("0") |
| 82 | + +# created_at :datetime not null |
| 83 | + +# updated_at :datetime not null |
| 84 | + +# |
| 85 | + PATCH |
| 86 | + |
| 87 | + path = 'test/fixtures/tasks.yml' |
| 88 | + { |
| 89 | + path: include(path), |
| 90 | + patch: include(patch) |
| 91 | + } |
| 92 | + end |
| 93 | + |
| 94 | + it 'annotate models' do |
| 95 | + Bundler.with_clean_env do |
| 96 | + Dir.chdir APP_PATH do |
| 97 | + expect(git.diff.any?).to be_falsy |
| 98 | + |
| 99 | + puts `#{command}` |
| 100 | + |
| 101 | + expect(git.diff.entries).to contain_exactly( |
| 102 | + an_object_having_attributes(task_model), |
| 103 | + an_object_having_attributes(task_test), |
| 104 | + an_object_having_attributes(task_fixture) |
| 105 | + ) |
| 106 | + end |
| 107 | + end |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + describe 'annotate --routes' do |
| 112 | + let(:command) { 'bundle exec annotate --routes' } |
| 113 | + |
| 114 | + let(:task_routes) do |
| 115 | + task_routes_diff = <<-DIFF |
| 116 | ++# == Route Map |
| 117 | ++# |
| 118 | ++# Prefix Verb URI Pattern Controller#Action |
| 119 | ++# tasks GET /tasks(.:format) tasks#index |
| 120 | ++# POST /tasks(.:format) tasks#create |
| 121 | ++# new_task GET /tasks/new(.:format) tasks#new |
| 122 | ++# edit_task GET /tasks/:id/edit(.:format) tasks#edit |
| 123 | ++# task GET /tasks/:id(.:format) tasks#show |
| 124 | ++# PATCH /tasks/:id(.:format) tasks#update |
| 125 | ++# PUT /tasks/:id(.:format) tasks#update |
| 126 | ++# DELETE /tasks/:id(.:format) tasks#destroy |
| 127 | + DIFF |
| 128 | + |
| 129 | + default_routes_diff = <<-DIFF |
| 130 | ++# rails_mandrill_inbound_emails POST /rails/action_mailbox/mandrill/inbound_emails(.:format) action_mailbox/ingresses/mandrill/inbound_emails#create |
| 131 | ++# rails_postmark_inbound_emails POST /rails/action_mailbox/postmark/inbound_emails(.:format) action_mailbox/ingresses/postmark/inbound_emails#create |
| 132 | ++# rails_relay_inbound_emails POST /rails/action_mailbox/relay/inbound_emails(.:format) action_mailbox/ingresses/relay/inbound_emails#create |
| 133 | ++# rails_sendgrid_inbound_emails POST /rails/action_mailbox/sendgrid/inbound_emails(.:format) action_mailbox/ingresses/sendgrid/inbound_emails#create |
| 134 | ++# rails_mailgun_inbound_emails POST /rails/action_mailbox/mailgun/inbound_emails/mime(.:format) action_mailbox/ingresses/mailgun/inbound_emails#create |
| 135 | ++# rails_conductor_inbound_emails GET /rails/conductor/action_mailbox/inbound_emails(.:format) rails/conductor/action_mailbox/inbound_emails#index |
| 136 | ++# POST /rails/conductor/action_mailbox/inbound_emails(.:format) rails/conductor/action_mailbox/inbound_emails#create |
| 137 | ++# new_rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/new(.:format) rails/conductor/action_mailbox/inbound_emails#new |
| 138 | ++# edit_rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/:id/edit(.:format) rails/conductor/action_mailbox/inbound_emails#edit |
| 139 | ++# rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#show |
| 140 | ++# PATCH /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#update |
| 141 | ++# PUT /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#update |
| 142 | ++# DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#destroy |
| 143 | ++# rails_conductor_inbound_email_reroute POST /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format) rails/conductor/action_mailbox/reroutes#create |
| 144 | ++# rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show |
| 145 | ++# rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show |
| 146 | ++# rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show |
| 147 | ++# update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update |
| 148 | ++# rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create |
| 149 | + DIFF |
| 150 | + |
| 151 | + |
| 152 | + path = 'config/routes.rb' |
| 153 | + { |
| 154 | + path: include(path), |
| 155 | + patch: include(task_routes_diff, default_routes_diff) |
| 156 | + } |
| 157 | + end |
| 158 | + |
| 159 | + it 'annotate routes.rb' do |
| 160 | + Bundler.with_clean_env do |
| 161 | + Dir.chdir APP_PATH do |
| 162 | + expect(git.diff.any?).to be_falsy |
98 | 163 |
|
99 |
| - puts `#{command}` |
| 164 | + puts `#{command}` |
100 | 165 |
|
101 |
| - expect(git.diff.entries).to contain_exactly( |
102 |
| - an_object_having_attributes(task_model), |
103 |
| - an_object_having_attributes(task_test), |
104 |
| - an_object_having_attributes(task_fixture) |
105 |
| - ) |
| 166 | + expect(git.diff.entries).to contain_exactly(an_object_having_attributes(task_routes)) |
| 167 | + end |
106 | 168 | end
|
107 | 169 | end
|
108 | 170 | end
|
|
0 commit comments