dbmanager 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -0
- data/README.md +9 -0
- data/features/dump.feature +2 -1
- data/features/load.feature +16 -0
- data/features/rake_tasks.feature +5 -0
- data/features/readme.md +9 -0
- data/features/step_definitions/dump_steps.rb +10 -3
- data/features/step_definitions/load_steps.rb +8 -0
- data/features/support/dummy_app_initialization.rb +1 -0
- data/lib/dbmanager.rb +6 -5
- data/lib/dbmanager/adapters/mysql.rb +23 -6
- data/lib/dbmanager/version.rb +1 -1
- data/spec/dummy/.gitignore +4 -2
- data/spec/dummy/app/models/friend.rb +3 -0
- data/spec/dummy/db/migrate/20130401134155_create_friends.rb +8 -0
- data/spec/dummy/db/seeds.rb +2 -0
- data/spec/dummy/tmp/load/john_doe.sql +76 -0
- data/spec/lib/adapters/mysql_spec.rb +40 -24
- data/spec/lib/dbmanager_spec.rb +16 -12
- data/spec/lib/runner_spec.rb +1 -1
- data/spec/lib/yml_parser_spec.rb +1 -1
- data/spec/spec_helper.rb +14 -0
- metadata +14 -8
- data/spec/dummy/db/schema.rb +0 -16
- data/spec/dummy/rerun.txt +0 -1
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -129,6 +129,15 @@ Cucumber tests require mysql server running. Update spec/dummy/config/database.y
|
|
129
129
|
with your mysql configuration, if necessary.
|
130
130
|
|
131
131
|
|
132
|
+
## Upgrade Notice
|
133
|
+
|
134
|
+
If you're still on rails 2.x and you're upgrading dbmanager to the latest version please rerun the
|
135
|
+
dbmanager rake file generator with:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
script/generate dbmanager
|
139
|
+
```
|
140
|
+
|
132
141
|
|
133
142
|
### TODO
|
134
143
|
|
data/features/dump.feature
CHANGED
@@ -14,4 +14,5 @@ Scenario: Dump database to user specified file
|
|
14
14
|
|
15
15
|
When I run the task "db:dump" with input "1 tmp/dbmanager_dummy_dev.sql"
|
16
16
|
Then a sql dump should be created in "tmp/dbmanager_dummy_dev.sql"
|
17
|
-
And the dump file should
|
17
|
+
And the dump file should have expected schema
|
18
|
+
And the dump file should include "Andrea Longhi"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: load database
|
2
|
+
As a dbmanager gem user
|
3
|
+
I want to load a sql file into any of my app databases
|
4
|
+
so that the database becomes fully populated
|
5
|
+
|
6
|
+
After adding the gem, when running **rake db:load**
|
7
|
+
you can choose the environment db to be loaded with data,
|
8
|
+
and the sql file that you want to load. After the task
|
9
|
+
has completed the selected database will be populated
|
10
|
+
with the data from the sql file.
|
11
|
+
|
12
|
+
Scenario: Load database from tmp/load/john_doe.sql
|
13
|
+
Given I go to the dummy rails app folder
|
14
|
+
|
15
|
+
When I run the task "db:load" with input "1 tmp/load/john_doe.sql"
|
16
|
+
Then the "development" database should include a friend named "John Doe"
|
data/features/rake_tasks.feature
CHANGED
@@ -18,3 +18,8 @@ Scenario: db:import task
|
|
18
18
|
Given I go to the dummy rails app folder
|
19
19
|
When I execute "rake -T"
|
20
20
|
Then I should see "db:import" among the listed tasks
|
21
|
+
|
22
|
+
Scenario: db:load task
|
23
|
+
Given I go to the dummy rails app folder
|
24
|
+
When I execute "rake -T"
|
25
|
+
Then I should see "db:load" among the listed tasks
|
data/features/readme.md
CHANGED
@@ -129,6 +129,15 @@ Cucumber tests require mysql server running. Update spec/dummy/config/database.y
|
|
129
129
|
with your mysql configuration, if necessary.
|
130
130
|
|
131
131
|
|
132
|
+
## Upgrade Notice
|
133
|
+
|
134
|
+
If you're still on rails 2.x and you're upgrading dbmanager to the latest version please rerun the
|
135
|
+
dbmanager rake file generator with:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
script/generate dbmanager
|
139
|
+
```
|
140
|
+
|
132
141
|
|
133
142
|
### TODO
|
134
143
|
|
@@ -6,9 +6,16 @@ Then /^an? sql dump should be created in "(.*?)"$/ do |path|
|
|
6
6
|
File.file?(path).should be_true
|
7
7
|
end
|
8
8
|
|
9
|
-
Then /^the dump file should
|
10
|
-
dump = File.read('tmp/dbmanager_dummy_dev.sql')
|
9
|
+
Then /^the dump file should have expected schema$/ do
|
11
10
|
File.open('db/structure.sql').each do |line|
|
12
|
-
|
11
|
+
dump_file.should include(line) unless line =~ /INSERT INTO schema_migrations/
|
13
12
|
end
|
14
13
|
end
|
14
|
+
|
15
|
+
Then /^the dump file should include "(.*?)"$/ do |string|
|
16
|
+
dump_file.should include(string)
|
17
|
+
end
|
18
|
+
|
19
|
+
def dump_file
|
20
|
+
File.read('tmp/dbmanager_dummy_dev.sql')
|
21
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Then /^data should be loaded into the development database$/ do
|
2
|
+
#
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^the "(.*?)" database should include a friend named "(.*?)"$/ do |env, name|
|
6
|
+
names = `RAILS_ENV=#{env} bundle exec rails runner 'puts Friend.all.map(&:name)'`
|
7
|
+
names.should include name
|
8
|
+
end
|
data/lib/dbmanager.rb
CHANGED
@@ -37,12 +37,13 @@ module Dbmanager
|
|
37
37
|
Rails.root
|
38
38
|
end
|
39
39
|
|
40
|
-
def execute(command, output
|
41
|
-
output
|
42
|
-
system command
|
40
|
+
def execute(command, output=$stdout)
|
41
|
+
execute!(command, output) rescue false
|
43
42
|
end
|
44
43
|
|
45
|
-
def execute!(command)
|
46
|
-
|
44
|
+
def execute!(command, output=$stdout)
|
45
|
+
output.puts %(executing "#{command}")
|
46
|
+
result = `#{command}`
|
47
|
+
$?.exitstatus.zero? ? result : raise(CommandError)
|
47
48
|
end
|
48
49
|
end
|
@@ -27,8 +27,13 @@ module Dbmanager
|
|
27
27
|
Dbmanager.execute! dump_command
|
28
28
|
end
|
29
29
|
|
30
|
+
def mysqldump_version
|
31
|
+
Dbmanager.execute('mysqldump --version') =~ /Distrib\s+(\d+\.\d+)/
|
32
|
+
$1.to_f
|
33
|
+
end
|
34
|
+
|
30
35
|
def dump_command
|
31
|
-
"mysqldump #{ignoretables} #{params(source)} > '#{filename}'"
|
36
|
+
"mysqldump #{ignoretables} #{set_gtid_purged_off} #{params(source)} > '#{filename}'"
|
32
37
|
end
|
33
38
|
|
34
39
|
def ignoretables
|
@@ -38,6 +43,14 @@ module Dbmanager
|
|
38
43
|
end.join ' '
|
39
44
|
end
|
40
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# Extra parameter to fix a 5.6 mysqldump issue with older mysql server releases
|
50
|
+
# See http://bugs.mysql.com/bug.php?id=68314
|
51
|
+
def set_gtid_purged_off
|
52
|
+
mysqldump_version >= 5.6 ? '--set-gtid-purged=OFF' : ''
|
53
|
+
end
|
41
54
|
end
|
42
55
|
|
43
56
|
class Loader
|
@@ -50,7 +63,15 @@ module Dbmanager
|
|
50
63
|
end
|
51
64
|
|
52
65
|
def run
|
66
|
+
create_db_if_missing
|
67
|
+
load
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_db_if_missing
|
53
71
|
Dbmanager.execute! create_db_if_missing_command
|
72
|
+
end
|
73
|
+
|
74
|
+
def load
|
54
75
|
Dbmanager.execute! load_command
|
55
76
|
end
|
56
77
|
|
@@ -59,11 +80,7 @@ module Dbmanager
|
|
59
80
|
end
|
60
81
|
|
61
82
|
def create_db_if_missing_command
|
62
|
-
"
|
63
|
-
end
|
64
|
-
|
65
|
-
def bundle
|
66
|
-
Dbmanager.execute('which bundle > /dev/null') ? 'bundle exec' : nil
|
83
|
+
"bundle exec rake db:create RAILS_ENV=#{target.name}"
|
67
84
|
end
|
68
85
|
end
|
69
86
|
|
data/lib/dbmanager/version.rb
CHANGED
data/spec/dummy/.gitignore
CHANGED
@@ -12,10 +12,12 @@
|
|
12
12
|
|
13
13
|
# Ignore db structure dump. It is created by cucumber.
|
14
14
|
db/structure.sql
|
15
|
+
db/schema.rb
|
15
16
|
|
16
|
-
# Ignore
|
17
|
+
# Ignore logfiles and sql files in tmp
|
17
18
|
/log/*.log
|
18
|
-
/tmp
|
19
|
+
/tmp/*.sql
|
19
20
|
|
20
21
|
# Ignore STDIN stub file, created by cucumber
|
21
22
|
STDIN_stub
|
23
|
+
spec/dummy/rerun.txt
|
data/spec/dummy/db/seeds.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
-- MySQL dump 10.13 Distrib 5.5.28, for osx10.8 (i386)
|
2
|
+
--
|
3
|
+
-- Host: localhost Database: dbmanager_dummy_dev
|
4
|
+
-- ------------------------------------------------------
|
5
|
+
-- Server version 5.5.28
|
6
|
+
|
7
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
8
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
9
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
10
|
+
/*!40101 SET NAMES utf8 */;
|
11
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
12
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
13
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
14
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
15
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
16
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
17
|
+
|
18
|
+
--
|
19
|
+
-- Table structure for table `friends`
|
20
|
+
--
|
21
|
+
|
22
|
+
DROP TABLE IF EXISTS `friends`;
|
23
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
24
|
+
/*!40101 SET character_set_client = utf8 */;
|
25
|
+
CREATE TABLE `friends` (
|
26
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
27
|
+
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
28
|
+
`created_at` datetime NOT NULL,
|
29
|
+
`updated_at` datetime NOT NULL,
|
30
|
+
PRIMARY KEY (`id`)
|
31
|
+
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
32
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
33
|
+
|
34
|
+
--
|
35
|
+
-- Dumping data for table `friends`
|
36
|
+
--
|
37
|
+
|
38
|
+
LOCK TABLES `friends` WRITE;
|
39
|
+
/*!40000 ALTER TABLE `friends` DISABLE KEYS */;
|
40
|
+
INSERT INTO `friends` VALUES (1,'John Doe','2013-04-02 22:04:50','2013-04-02 22:08:29');
|
41
|
+
/*!40000 ALTER TABLE `friends` ENABLE KEYS */;
|
42
|
+
UNLOCK TABLES;
|
43
|
+
|
44
|
+
--
|
45
|
+
-- Table structure for table `schema_migrations`
|
46
|
+
--
|
47
|
+
|
48
|
+
DROP TABLE IF EXISTS `schema_migrations`;
|
49
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
50
|
+
/*!40101 SET character_set_client = utf8 */;
|
51
|
+
CREATE TABLE `schema_migrations` (
|
52
|
+
`version` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
53
|
+
UNIQUE KEY `unique_schema_migrations` (`version`)
|
54
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
55
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
56
|
+
|
57
|
+
--
|
58
|
+
-- Dumping data for table `schema_migrations`
|
59
|
+
--
|
60
|
+
|
61
|
+
LOCK TABLES `schema_migrations` WRITE;
|
62
|
+
/*!40000 ALTER TABLE `schema_migrations` DISABLE KEYS */;
|
63
|
+
INSERT INTO `schema_migrations` VALUES ('20130401134155');
|
64
|
+
/*!40000 ALTER TABLE `schema_migrations` ENABLE KEYS */;
|
65
|
+
UNLOCK TABLES;
|
66
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
67
|
+
|
68
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
69
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
70
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
71
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
72
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
73
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
74
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
75
|
+
|
76
|
+
-- Dump completed on 2013-04-03 0:08:48
|
@@ -29,7 +29,7 @@ module Dbmanager
|
|
29
29
|
|
30
30
|
context 'when there are no tables to be ignored' do
|
31
31
|
it 'returns nil' do
|
32
|
-
source.stub
|
32
|
+
source.stub(:ignoretables => nil)
|
33
33
|
subject.ignoretables.should be_nil
|
34
34
|
end
|
35
35
|
end
|
@@ -37,12 +37,41 @@ module Dbmanager
|
|
37
37
|
|
38
38
|
describe '#dump_command' do
|
39
39
|
it 'returns expected command' do
|
40
|
-
|
40
|
+
[
|
41
41
|
'mysqldump --ignore-table=database.a_view',
|
42
|
-
'--ignore-table=database.another_view
|
43
|
-
'-psecret -h0.0.0.0 -P42 database
|
44
|
-
|
45
|
-
|
42
|
+
'--ignore-table=database.another_view',
|
43
|
+
'-uroot -psecret -h0.0.0.0 -P42 database',
|
44
|
+
'> \'/tmp/dump_file.sql\''
|
45
|
+
].each do |command_part|
|
46
|
+
subject.dump_command.should include command_part
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when mysqldump version is >= than 5.6' do
|
51
|
+
before do
|
52
|
+
version = 'mysqldump Ver 10.13 Distrib 5.6.0, for osx10.8 (i386)'
|
53
|
+
Dbmanager.should_receive(:execute).with('mysqldump --version').and_return(version)
|
54
|
+
end
|
55
|
+
|
56
|
+
it {subject.mysqldump_version.should == 5.6 }
|
57
|
+
|
58
|
+
it 'adds a flag that sets off gtid-purged' do
|
59
|
+
subject.dump_command.should include '--set-gtid-purged=OFF'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when mysqldump version is < than 5.6' do
|
64
|
+
before do
|
65
|
+
version = 'mysqldump Ver 10.13 Distrib 5.5.28, for osx10.8 (i386)'
|
66
|
+
Dbmanager.should_receive(:execute).with('mysqldump --version').and_return(version)
|
67
|
+
end
|
68
|
+
|
69
|
+
it {subject.mysqldump_version.should == 5.5 }
|
70
|
+
|
71
|
+
it 'adds a flag that sets off gtid-purged' do
|
72
|
+
subject.dump_command.should_not include '--set-gtid-purged=OFF'
|
73
|
+
end
|
74
|
+
|
46
75
|
end
|
47
76
|
end
|
48
77
|
end
|
@@ -51,7 +80,7 @@ module Dbmanager
|
|
51
80
|
before { Dbmanager.stub :output => STDStub.new }
|
52
81
|
|
53
82
|
describe 'an importer instance' do
|
54
|
-
before { Time.stub
|
83
|
+
before { Time.stub :now => Time.parse('2012/03/23 12:30:32') }
|
55
84
|
let(:source) { Environment.new :protected => false, :name => 'development', :username => 'root' }
|
56
85
|
let(:target) { Environment.new :protected => false, :name => 'beta', :username => 'beta_user' }
|
57
86
|
let(:tmp_file) { '/some/arbitrary/path' }
|
@@ -73,23 +102,10 @@ module Dbmanager
|
|
73
102
|
end
|
74
103
|
end
|
75
104
|
|
76
|
-
describe '#bundle' do
|
77
|
-
it 'returns "bundle exec" when bundler is present' do
|
78
|
-
Dbmanager.should_receive(:execute).and_return true
|
79
|
-
subject.bundle.should == 'bundle exec'
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'returns nil when bundler is missing' do
|
83
|
-
Dbmanager.should_receive(:execute).and_return false
|
84
|
-
subject.bundle.should be_nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
105
|
describe '#run' do
|
89
106
|
it 'creates the db if missing and then imports the db' do
|
90
|
-
subject.stub
|
107
|
+
subject.stub(:load => nil, :remove_tmp_file => true)
|
91
108
|
Dbmanager.should_receive(:execute!).with(subject.create_db_if_missing_command)
|
92
|
-
Dbmanager.should_receive(:execute!).with(subject.load_command)
|
93
109
|
subject.run
|
94
110
|
end
|
95
111
|
end
|
@@ -105,7 +121,7 @@ module Dbmanager
|
|
105
121
|
before { Dbmanager.stub :output => STDStub.new }
|
106
122
|
|
107
123
|
describe 'an importer instance' do
|
108
|
-
before { Time.stub
|
124
|
+
before { Time.stub :now => Time.parse('2012/03/23 12:30:32') }
|
109
125
|
|
110
126
|
subject { Importer.new source, target, tmp_file }
|
111
127
|
|
@@ -126,13 +142,13 @@ module Dbmanager
|
|
126
142
|
|
127
143
|
describe '#run' do
|
128
144
|
it 'create ad Dumper that will dump the db' do
|
129
|
-
Dbmanager.stub
|
145
|
+
Dbmanager.stub(:execute! => nil)
|
130
146
|
Dumper.should_receive(:new).and_return(mock.as_null_object)
|
131
147
|
subject.run
|
132
148
|
end
|
133
149
|
|
134
150
|
it 'create ad Loader that will dump the db' do
|
135
|
-
Dbmanager.stub
|
151
|
+
Dbmanager.stub(:execute! => nil)
|
136
152
|
Loader.should_receive(:new).and_return(mock.as_null_object)
|
137
153
|
subject.run
|
138
154
|
end
|
data/spec/lib/dbmanager_spec.rb
CHANGED
@@ -10,29 +10,33 @@ describe Dbmanager do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#execute' do
|
13
|
-
it 'executes a system command' do
|
14
|
-
Dbmanager.should_receive(:system)
|
15
|
-
Dbmanager.execute('echo')
|
16
|
-
end
|
17
|
-
|
18
13
|
it 'outputs the command that is executing' do
|
19
14
|
output = STDStub.new
|
20
15
|
Dbmanager.execute('echo', output)
|
21
16
|
output.content.should include 'executing "echo"'
|
22
17
|
end
|
23
|
-
end
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
Dbmanager.should_receive(:execute).and_return(true)
|
28
|
-
Dbmanager.execute!('echo')
|
19
|
+
it 'executes a system command and returns the output' do
|
20
|
+
Dbmanager.execute!('echo asd').chomp.should == 'asd'
|
29
21
|
end
|
30
22
|
|
31
23
|
it 'raises an error when not successful' do
|
32
|
-
Dbmanager.stub!(:system => false)
|
33
24
|
expect do
|
34
|
-
Dbmanager.execute!('
|
25
|
+
Dbmanager.execute!('gibberish')
|
35
26
|
end.to raise_error(Dbmanager::CommandError)
|
36
27
|
end
|
37
28
|
end
|
29
|
+
|
30
|
+
describe '#execute' do
|
31
|
+
it 'wraps a call to #execute!' do
|
32
|
+
Dbmanager.should_receive(:execute!).and_return(true)
|
33
|
+
Dbmanager.execute!('echo')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises no error when not successful' do
|
37
|
+
expect do
|
38
|
+
Dbmanager.execute('gibberish')
|
39
|
+
end.to_not raise_error(Dbmanager::CommandError)
|
40
|
+
end
|
41
|
+
end
|
38
42
|
end
|
data/spec/lib/runner_spec.rb
CHANGED
data/spec/lib/yml_parser_spec.rb
CHANGED
@@ -40,7 +40,7 @@ module Dbmanager
|
|
40
40
|
context 'when there is a dbmanager_override file' do
|
41
41
|
context 'when the file is empty' do
|
42
42
|
it 'doesnt raise any error' do
|
43
|
-
YAML.stub
|
43
|
+
YAML.stub(:load => nil)
|
44
44
|
expect { YmlParser.config }.to_not raise_error
|
45
45
|
end
|
46
46
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,8 +9,10 @@ RSpec.configure do |config|
|
|
9
9
|
config.run_all_when_everything_filtered = true
|
10
10
|
config.filter_run :focus
|
11
11
|
config.before(:each) do
|
12
|
+
stub_stdout
|
12
13
|
stub_rails_root unless example.metadata[:skip_stub_rails_root]
|
13
14
|
end
|
15
|
+
config.after(:each) { reset_stdout }
|
14
16
|
end
|
15
17
|
|
16
18
|
|
@@ -21,6 +23,17 @@ class STDStub < StringIO
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
26
|
+
# to suppress all Dbmanager.execute outputs before each test
|
27
|
+
def stub_stdout
|
28
|
+
@old_stdout = $stdout
|
29
|
+
$stdout = STDStub.new
|
30
|
+
end
|
31
|
+
|
32
|
+
# to reset original $stdout after each test
|
33
|
+
def reset_stdout
|
34
|
+
$stdout = @old_stdout
|
35
|
+
end
|
36
|
+
|
24
37
|
def fixture_path
|
25
38
|
File.expand_path('../fixtures', __FILE__)
|
26
39
|
end
|
@@ -28,3 +41,4 @@ end
|
|
28
41
|
def stub_rails_root
|
29
42
|
Dbmanager.stub :rails_root => Pathname.new("#{fixture_path}/rails")
|
30
43
|
end
|
44
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -141,9 +141,11 @@ files:
|
|
141
141
|
- Rakefile
|
142
142
|
- dbmanager.gemspec
|
143
143
|
- features/dump.feature
|
144
|
+
- features/load.feature
|
144
145
|
- features/rake_tasks.feature
|
145
146
|
- features/readme.md
|
146
147
|
- features/step_definitions/dump_steps.rb
|
148
|
+
- features/step_definitions/load_steps.rb
|
147
149
|
- features/step_definitions/rake_tasks_steps.rb
|
148
150
|
- features/support/dummy_app_initialization.rb
|
149
151
|
- features/support/env.rb
|
@@ -172,6 +174,7 @@ files:
|
|
172
174
|
- spec/dummy/app/helpers/application_helper.rb
|
173
175
|
- spec/dummy/app/mailers/.gitkeep
|
174
176
|
- spec/dummy/app/models/.gitkeep
|
177
|
+
- spec/dummy/app/models/friend.rb
|
175
178
|
- spec/dummy/app/views/layouts/application.html.erb
|
176
179
|
- spec/dummy/config.ru
|
177
180
|
- spec/dummy/config/application.rb
|
@@ -189,7 +192,7 @@ files:
|
|
189
192
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
190
193
|
- spec/dummy/config/locales/en.yml
|
191
194
|
- spec/dummy/config/routes.rb
|
192
|
-
- spec/dummy/db/
|
195
|
+
- spec/dummy/db/migrate/20130401134155_create_friends.rb
|
193
196
|
- spec/dummy/db/seeds.rb
|
194
197
|
- spec/dummy/doc/README_FOR_APP
|
195
198
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -201,7 +204,6 @@ files:
|
|
201
204
|
- spec/dummy/public/favicon.ico
|
202
205
|
- spec/dummy/public/index.html
|
203
206
|
- spec/dummy/public/robots.txt
|
204
|
-
- spec/dummy/rerun.txt
|
205
207
|
- spec/dummy/script/rails
|
206
208
|
- spec/dummy/test/fixtures/.gitkeep
|
207
209
|
- spec/dummy/test/functional/.gitkeep
|
@@ -209,6 +211,7 @@ files:
|
|
209
211
|
- spec/dummy/test/performance/browsing_test.rb
|
210
212
|
- spec/dummy/test/test_helper.rb
|
211
213
|
- spec/dummy/test/unit/.gitkeep
|
214
|
+
- spec/dummy/tmp/load/john_doe.sql
|
212
215
|
- spec/dummy/vendor/assets/javascripts/.gitkeep
|
213
216
|
- spec/dummy/vendor/assets/stylesheets/.gitkeep
|
214
217
|
- spec/dummy/vendor/plugins/.gitkeep
|
@@ -238,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
241
|
version: '0'
|
239
242
|
segments:
|
240
243
|
- 0
|
241
|
-
hash:
|
244
|
+
hash: 3317854909553547235
|
242
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
246
|
none: false
|
244
247
|
requirements:
|
@@ -247,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
250
|
version: '0'
|
248
251
|
segments:
|
249
252
|
- 0
|
250
|
-
hash:
|
253
|
+
hash: 3317854909553547235
|
251
254
|
requirements: []
|
252
255
|
rubyforge_project: dbmanager
|
253
256
|
rubygems_version: 1.8.25
|
@@ -256,9 +259,11 @@ specification_version: 3
|
|
256
259
|
summary: database manager
|
257
260
|
test_files:
|
258
261
|
- features/dump.feature
|
262
|
+
- features/load.feature
|
259
263
|
- features/rake_tasks.feature
|
260
264
|
- features/readme.md
|
261
265
|
- features/step_definitions/dump_steps.rb
|
266
|
+
- features/step_definitions/load_steps.rb
|
262
267
|
- features/step_definitions/rake_tasks_steps.rb
|
263
268
|
- features/support/dummy_app_initialization.rb
|
264
269
|
- features/support/env.rb
|
@@ -273,6 +278,7 @@ test_files:
|
|
273
278
|
- spec/dummy/app/helpers/application_helper.rb
|
274
279
|
- spec/dummy/app/mailers/.gitkeep
|
275
280
|
- spec/dummy/app/models/.gitkeep
|
281
|
+
- spec/dummy/app/models/friend.rb
|
276
282
|
- spec/dummy/app/views/layouts/application.html.erb
|
277
283
|
- spec/dummy/config.ru
|
278
284
|
- spec/dummy/config/application.rb
|
@@ -290,7 +296,7 @@ test_files:
|
|
290
296
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
291
297
|
- spec/dummy/config/locales/en.yml
|
292
298
|
- spec/dummy/config/routes.rb
|
293
|
-
- spec/dummy/db/
|
299
|
+
- spec/dummy/db/migrate/20130401134155_create_friends.rb
|
294
300
|
- spec/dummy/db/seeds.rb
|
295
301
|
- spec/dummy/doc/README_FOR_APP
|
296
302
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -302,7 +308,6 @@ test_files:
|
|
302
308
|
- spec/dummy/public/favicon.ico
|
303
309
|
- spec/dummy/public/index.html
|
304
310
|
- spec/dummy/public/robots.txt
|
305
|
-
- spec/dummy/rerun.txt
|
306
311
|
- spec/dummy/script/rails
|
307
312
|
- spec/dummy/test/fixtures/.gitkeep
|
308
313
|
- spec/dummy/test/functional/.gitkeep
|
@@ -310,6 +315,7 @@ test_files:
|
|
310
315
|
- spec/dummy/test/performance/browsing_test.rb
|
311
316
|
- spec/dummy/test/test_helper.rb
|
312
317
|
- spec/dummy/test/unit/.gitkeep
|
318
|
+
- spec/dummy/tmp/load/john_doe.sql
|
313
319
|
- spec/dummy/vendor/assets/javascripts/.gitkeep
|
314
320
|
- spec/dummy/vendor/assets/stylesheets/.gitkeep
|
315
321
|
- spec/dummy/vendor/plugins/.gitkeep
|
data/spec/dummy/db/schema.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This file is auto-generated from the current state of the database. Instead
|
3
|
-
# of editing this file, please use the migrations feature of Active Record to
|
4
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
-
#
|
6
|
-
# Note that this schema.rb definition is the authoritative source for your
|
7
|
-
# database schema. If you need to create the application database on another
|
8
|
-
# system, you should be using db:schema:load, not running all the migrations
|
9
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
-
#
|
12
|
-
# It's strongly recommended to check this file into your version control system.
|
13
|
-
|
14
|
-
ActiveRecord::Schema.define(:version => 0) do
|
15
|
-
|
16
|
-
end
|
data/spec/dummy/rerun.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
features/dump.feature:12
|