migration_data 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/migration_data/testing.rb +13 -0
- data/lib/migration_data/version.rb +1 -1
- data/test/db/20130906111511_test_migration.rb +0 -0
- data/test/migration_test.rb +1 -5
- data/test/require_migration_test.rb +23 -0
- data/test/test_helper.rb +5 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4552c429867842324c75472fbdbc53fc02f77f2
|
4
|
+
data.tar.gz: e14bc8afb270954806a23918acd59e9df279f53b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0294bc30af216c53a2f8be71719b1f8b5baa288d12f5c3b81243c056de53d472dfcead29fe78663f2488ba2429966f94c6d87c790f6f2d875a70ffc9691235b
|
7
|
+
data.tar.gz: 3cba7c9e880c5515da1fb85b34a9624f67da3c02c97e40034c4ff84e69027a633e54b44ab9446e50a4be55502a016fd3e00a19a6f23c5a5dde74c2b1e49d391e
|
data/README.md
CHANGED
@@ -50,8 +50,10 @@ To keep your migrations working don't forget to write test foe them.
|
|
50
50
|
Possible `RSpec` test for the migration looks like this:
|
51
51
|
|
52
52
|
```ruby
|
53
|
+
|
53
54
|
require 'spec_helper'
|
54
|
-
require
|
55
|
+
require 'migration_data/testing'
|
56
|
+
require_migration 'create_users'
|
55
57
|
|
56
58
|
desribe CreateUsers do
|
57
59
|
describe '#data' do
|
@@ -62,6 +64,9 @@ desribe CreateUsers do
|
|
62
64
|
end
|
63
65
|
```
|
64
66
|
|
67
|
+
The helper to load migrations `require_migration` is defined in the `migration_data/testing`. So you should to require it
|
68
|
+
to have access to this convinient require extension.
|
69
|
+
|
65
70
|
## Contributing
|
66
71
|
|
67
72
|
1. Fork it ( http://github.com/ka8725/migration_data/fork )
|
@@ -0,0 +1,13 @@
|
|
1
|
+
def require_migration(migration_name)
|
2
|
+
path = ActiveRecord::Migrator.migrations_path
|
3
|
+
all_migrations = ActiveRecord::Migrator.migrations(path)
|
4
|
+
|
5
|
+
migration_name += '.rb' unless migration_name.end_with?('.rb')
|
6
|
+
file = all_migrations.detect do |m|
|
7
|
+
m.filename.end_with?(migration_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
raise LoadError, "cannot load such file -- #{migration_name}" unless file
|
11
|
+
|
12
|
+
require file.filename
|
13
|
+
end
|
File without changes
|
data/test/migration_test.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'active_record'
|
3
|
-
require 'migration_data'
|
4
|
-
|
5
|
-
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'tmp/test.sqlite3')
|
1
|
+
require 'test_helper'
|
6
2
|
|
7
3
|
class MyMigration < ActiveRecord::Migration
|
8
4
|
attr_reader :migrated_data
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'migration_data/testing'
|
3
|
+
|
4
|
+
describe '#require_migration' do
|
5
|
+
let(:db_path) do
|
6
|
+
test_dir = File.expand_path(File.dirname(__FILE__))
|
7
|
+
File.join(test_dir, 'db')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'loads existed migation' do
|
11
|
+
ActiveRecord::Migrator.stub(:migrations_path, db_path) do
|
12
|
+
require_migration 'test_migration'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'raises exception on load unexisted migration' do
|
17
|
+
ActiveRecord::Migrator.stub(:migrations_path, db_path) do
|
18
|
+
assert_raises LoadError, 'cannot load such file -- test_migration2.rb' do
|
19
|
+
require_migration('test_migration2')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Koleshko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,9 +84,13 @@ files:
|
|
84
84
|
- README.md
|
85
85
|
- Rakefile
|
86
86
|
- lib/migration_data.rb
|
87
|
+
- lib/migration_data/testing.rb
|
87
88
|
- lib/migration_data/version.rb
|
88
89
|
- migration_data.gemspec
|
90
|
+
- test/db/20130906111511_test_migration.rb
|
89
91
|
- test/migration_test.rb
|
92
|
+
- test/require_migration_test.rb
|
93
|
+
- test/test_helper.rb
|
90
94
|
homepage: ''
|
91
95
|
licenses:
|
92
96
|
- MIT
|
@@ -112,5 +116,8 @@ signing_key:
|
|
112
116
|
specification_version: 4
|
113
117
|
summary: Provides possibility to write any code in migrations safely without regression.
|
114
118
|
test_files:
|
119
|
+
- test/db/20130906111511_test_migration.rb
|
115
120
|
- test/migration_test.rb
|
121
|
+
- test/require_migration_test.rb
|
122
|
+
- test/test_helper.rb
|
116
123
|
has_rdoc:
|