|
3 | 3 | describe Overcommit::Hook::PreCommit::RailsSchemaUpToDate do
|
4 | 4 | let(:config) { Overcommit::ConfigurationLoader.default_configuration }
|
5 | 5 | let(:context) { double('context') }
|
6 |
| - let(:migration_files) { %w{db/migrate/20140304042233_some_migration.rb |
7 |
| - db/migrate/20140305123456_some_migration.rb} } |
8 | 6 | let(:ruby_schema_file) { 'db/schema.rb' }
|
9 | 7 | let(:sql_schema_file) { 'db/structure.sql' }
|
10 | 8 |
|
11 |
| - subject { described_class.new(config, context) } |
| 9 | + let(:migration_files) do |
| 10 | + %w[ |
| 11 | + db/migrate/20140304042233_some_migration.rb |
| 12 | + db/migrate/20140305123456_some_migration.rb |
| 13 | + ] |
| 14 | + end |
| 15 | + |
| 16 | + subject { described_class.new(config, context) } |
12 | 17 |
|
13 | 18 | context "when a migration was added but the schema wasn't updated" do
|
14 | 19 | before do
|
|
31 | 36 | it { should fail_hook }
|
32 | 37 | end
|
33 | 38 |
|
34 |
| - context "when a ruby schema file was added but no migration files were" do |
| 39 | + context 'when a Ruby schema file was added but no migration files were' do |
35 | 40 | before do
|
36 | 41 | subject.stub(:applicable_files).and_return([ruby_schema_file])
|
37 | 42 | end
|
|
48 | 53 | it { should fail_hook }
|
49 | 54 | end
|
50 | 55 |
|
51 |
| - context "when a SQL schema file was added but no migration files were" do |
| 56 | + context 'when a SQL schema file was added but no migration files were' do |
52 | 57 | before do
|
53 | 58 | subject.stub(:applicable_files).and_return([sql_schema_file])
|
54 | 59 | end
|
|
65 | 70 | it { should fail_hook }
|
66 | 71 | end
|
67 | 72 |
|
68 |
| - context "when both a Ruby schema file with the latest version and migrations are added" do |
| 73 | + context 'when a Ruby schema file with the latest version and migrations are added' do |
69 | 74 | before do
|
70 | 75 | subject.stub(:applicable_files).and_return(migration_files << ruby_schema_file)
|
71 | 76 | end
|
|
89 | 94 | it { should pass }
|
90 | 95 | end
|
91 | 96 |
|
92 |
| - context "when both a Ruby schema file which is not at the latest version and migrations are added" do |
| 97 | + context 'when a Ruby schema file which is not at the latest version and migrations are added' do |
93 | 98 | before do
|
94 | 99 | subject.stub(:applicable_files).and_return(migration_files << ruby_schema_file)
|
95 | 100 | end
|
|
113 | 118 | it { should fail_hook }
|
114 | 119 | end
|
115 | 120 |
|
116 |
| - context "when both a SQL schema file with the latest version and migrations are added" do |
| 121 | + context 'when a SQL schema file with the latest version and migrations are added' do |
117 | 122 | before do
|
118 | 123 | subject.stub(:applicable_files).and_return(migration_files << sql_schema_file)
|
119 | 124 | end
|
|
137 | 142 | it { should pass }
|
138 | 143 | end
|
139 | 144 |
|
140 |
| - context "when both a SQL schema file which is not at the latest version and migrations are added" do |
| 145 | + context 'when a SQL schema file which is not at the latest version and migrations are added' do |
141 | 146 | before do
|
142 | 147 | subject.stub(:applicable_files).and_return(migration_files << sql_schema_file)
|
143 | 148 | end
|
|
0 commit comments