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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3832601395165ae09ded4ba1609528ae1743142e
4
- data.tar.gz: 2ad9a69f0b54b83b0aa9f86ea5b91fe80726358a
3
+ metadata.gz: f4552c429867842324c75472fbdbc53fc02f77f2
4
+ data.tar.gz: e14bc8afb270954806a23918acd59e9df279f53b
5
5
  SHA512:
6
- metadata.gz: bbde24c5b3c6a5a998438c41411be08472823725f7e89ddbaa38ba055775d4ef109c76e3ae02f0b545b922926ee3c52794fe9ee0d84ab4b586dd276dfddba93e
7
- data.tar.gz: 02fe7cd0bf6b53c5327b9206b5432d63520cdb0c37530e0b665ccaa71a2b79ff35810bb96c81c77d2fba8e9c539c0648f9923364199319c5300ea5c39a85a265
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 Rails.root.join(ActiveRecord::Migrator.migrations_paths).join('20130906111511_create_users.rb')
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
@@ -1,3 +1,3 @@
1
1
  module MigrationData
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
File without changes
@@ -1,8 +1,4 @@
1
- require 'minitest/autorun'
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
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'active_record'
3
+ require 'migration_data'
4
+
5
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'tmp/test.sqlite3')
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.1
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-28 00:00:00.000000000 Z
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: