mongify 0.3.1 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile.lock +20 -21
- data/README.rdoc +34 -35
- data/bin/mongify +6 -1
- data/features/options.feature +14 -16
- data/features/print.feature +1 -1
- data/features/process.feature +2 -2
- data/features/step_definitions/mongify_steps.rb +1 -1
- data/lib/mongify/cli.rb +5 -3
- data/lib/mongify/cli/application.rb +1 -2
- data/lib/mongify/cli/command/help.rb +19 -0
- data/lib/mongify/cli/command/version.rb +20 -0
- data/lib/mongify/cli/command/worker.rb +101 -0
- data/lib/mongify/cli/options.rb +28 -35
- data/lib/mongify/database/no_sql_connection.rb +1 -1
- data/lib/mongify/database/sql_connection.rb +0 -1
- data/lib/mongify/progressbar.rb +4 -2
- data/lib/mongify/version.rb +1 -1
- data/mongify.gemspec +5 -5
- data/spec/mongify/cli/application_spec.rb +3 -4
- data/spec/mongify/cli/{help_command_spec.rb → command/help_spec.rb} +2 -2
- data/spec/mongify/cli/{version_command_spec.rb → command/version_spec.rb} +3 -3
- data/spec/mongify/cli/options_spec.rb +24 -28
- data/spec/mongify/cli/worker_command_spec.rb +10 -10
- data/spec/mongify/database/no_sql_connection_spec.rb +1 -1
- data/spec/mongify/database/sql_connection_spec.rb +16 -28
- data/spec/mongify/translation/process_spec.rb +1 -0
- data/spec/support/database.example +1 -1
- metadata +31 -46
- data/lib/mongify/cli/help_command.rb +0 -17
- data/lib/mongify/cli/version_command.rb +0 -19
- data/lib/mongify/cli/worker_command.rb +0 -101
data/lib/mongify/cli/options.rb
CHANGED
@@ -11,82 +11,75 @@ module Mongify
|
|
11
11
|
@parser = OptionParser.new
|
12
12
|
#@command_class = ReekCommand
|
13
13
|
set_options
|
14
|
-
|
14
|
+
parse_options
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Banner for help output
|
18
18
|
def banner
|
19
19
|
progname = @parser.program_name
|
20
20
|
return <<EOB
|
21
|
-
Usage: #{progname} command [database_translation.rb]
|
21
|
+
Usage: #{progname} command database.config [database_translation.rb]
|
22
22
|
|
23
23
|
Commands:
|
24
|
-
#{Mongify::CLI::
|
24
|
+
#{Mongify::CLI::Command::Worker.list_commands.join("\n")}
|
25
25
|
|
26
26
|
Examples:
|
27
27
|
|
28
|
-
#{progname} check
|
29
|
-
#{progname} translation
|
30
|
-
#{progname} process database_translation.rb
|
28
|
+
#{progname} check database.config
|
29
|
+
#{progname} translation datbase.config > database_translation.rb
|
30
|
+
#{progname} process database.config database_translation.rb
|
31
31
|
|
32
32
|
See http://github.com/anlek/mongify for more details
|
33
33
|
|
34
34
|
EOB
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# Sets the options for CLI
|
38
38
|
# Also used for help output
|
39
39
|
def set_options
|
40
40
|
@parser.banner = banner
|
41
41
|
@parser.separator "Common options:"
|
42
42
|
@parser.on("-h", "--help", "Show this message") do
|
43
|
-
@command_class =
|
43
|
+
@command_class = Command::Help
|
44
44
|
end
|
45
45
|
@parser.on("-v", "--version", "Show version") do
|
46
|
-
@command_class =
|
47
|
-
end
|
48
|
-
@parser.on('-c', '--config FILE', "Configuration File to use") do |file|
|
49
|
-
@config_file = file
|
46
|
+
@command_class = Command::Version
|
50
47
|
end
|
51
48
|
end
|
52
|
-
|
49
|
+
|
53
50
|
# Parses CLI passed attributes and figures out what command user is trying to run
|
54
51
|
def parse
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
elsif @command_class == VersionCommand
|
60
|
-
VersionCommand.new(@parser.program_name)
|
52
|
+
if @command_class == Command::Help
|
53
|
+
Command::Help.new(@parser)
|
54
|
+
elsif @command_class == Command::Version
|
55
|
+
Command::Version.new(@parser.program_name)
|
61
56
|
else
|
62
|
-
|
63
|
-
#TODO: In the future, request sql_connection and nosql_connection from user input
|
64
|
-
config = Configuration.parse(@config_file)
|
65
|
-
|
66
|
-
WorkerCommand.new(action, config, translation_file, @parser)
|
57
|
+
Command::Worker.new(action, config_file, translation_file, @parser)
|
67
58
|
end
|
68
59
|
end
|
69
|
-
|
60
|
+
|
70
61
|
#######
|
71
62
|
private
|
72
63
|
#######
|
73
|
-
|
64
|
+
|
74
65
|
# Returns the translation_file or nil
|
75
66
|
def translation_file(argv=@argv)
|
76
|
-
|
77
|
-
return nil if argv.length < 2
|
78
|
-
argv[1]
|
67
|
+
argv[2] if argv.length >= 3 and File.exist?(argv[2]) and !File.directory?(argv[2])
|
79
68
|
end
|
80
|
-
|
69
|
+
|
81
70
|
# Returns action (command) user is calling or ''
|
82
71
|
def action(argv=@argv)
|
83
|
-
parse_options
|
84
72
|
@argv.try(:[],0) || ''
|
85
73
|
end
|
86
|
-
|
87
|
-
#
|
74
|
+
|
75
|
+
# Returns the config file
|
76
|
+
def config_file(argv=@argv)
|
77
|
+
@config_file ||= Configuration.parse(argv[1]) if argv.length >= 2 and File.exist?(argv[1]) and !File.directory?(argv[1])
|
78
|
+
end
|
79
|
+
|
80
|
+
# option parser, ensuring parse_options is only called once
|
88
81
|
def parse_options
|
89
|
-
@
|
82
|
+
@parser.parse!(@argv)
|
90
83
|
rescue OptionParser::InvalidOption => er
|
91
84
|
raise Mongify::InvalidOption, er.message, er.backtrace
|
92
85
|
end
|
@@ -95,7 +95,7 @@ module Mongify
|
|
95
95
|
|
96
96
|
# Inserts into the collection a given row
|
97
97
|
def insert_into(colleciton_name, row)
|
98
|
-
db[colleciton_name].insert(row
|
98
|
+
db[colleciton_name].insert(row)
|
99
99
|
end
|
100
100
|
|
101
101
|
# Updates a collection item with a given ID with the given attributes
|
data/lib/mongify/progressbar.rb
CHANGED
@@ -19,10 +19,10 @@ module Mongify
|
|
19
19
|
#Progress bar version
|
20
20
|
VERSION = "0.9.1"
|
21
21
|
|
22
|
-
def initialize (title, total
|
22
|
+
def initialize (title, total)
|
23
23
|
@title = title
|
24
24
|
@total = total
|
25
|
-
@out =
|
25
|
+
@out = Mongify::Configuration.out_stream
|
26
26
|
@terminal_width = 80
|
27
27
|
@bar_mark = "o"
|
28
28
|
@current = 0
|
@@ -156,6 +156,7 @@ module Mongify
|
|
156
156
|
|
157
157
|
# Draws the bar
|
158
158
|
def show
|
159
|
+
return unless @out
|
159
160
|
arguments = @format_arguments.map {|method|
|
160
161
|
method = sprintf("fmt_%s", method)
|
161
162
|
send(method)
|
@@ -196,6 +197,7 @@ module Mongify
|
|
196
197
|
public
|
197
198
|
# Clear's line
|
198
199
|
def clear
|
200
|
+
return unless @out
|
199
201
|
@out.print "\r"
|
200
202
|
@out.print(" " * (get_width - 1))
|
201
203
|
@out.print "\r"
|
data/lib/mongify/version.rb
CHANGED
data/mongify.gemspec
CHANGED
@@ -14,19 +14,19 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_dependency('activerecord', ">=3.0.3")
|
16
16
|
s.add_dependency('activesupport', ">=3.0.3")
|
17
|
-
s.add_dependency('
|
18
|
-
s.add_dependency('
|
19
|
-
s.add_dependency('bson_ext', ">= 1.1.5")
|
17
|
+
s.add_dependency('mongo', "~> 1.8.2")
|
18
|
+
s.add_dependency('bson_ext', "~> 1.8.2") unless RUBY_PLATFORM == 'java'
|
20
19
|
s.add_dependency('highline', '>= 1.6.1')
|
21
20
|
|
21
|
+
|
22
22
|
s.add_development_dependency('rspec', '>= 2.0')
|
23
23
|
s.add_development_dependency('rcov', '>= 0.9.9')
|
24
24
|
s.add_development_dependency('cucumber', '>= 0.10')
|
25
25
|
s.add_development_dependency('mocha', '>= 0.9.8')
|
26
26
|
s.add_development_dependency('yard', '>= 0.5.3')
|
27
|
-
s.add_development_dependency('watchr', '>= 0.6')
|
28
27
|
s.add_development_dependency('sqlite3-ruby', '>= 1.3')
|
29
|
-
s.add_development_dependency('
|
28
|
+
s.add_development_dependency('mysql2', '~> 0.2.7')
|
29
|
+
s.add_development_dependency('watchr', '>= 0.6')
|
30
30
|
s.add_development_dependency('rake')
|
31
31
|
|
32
32
|
s.files = `git ls-files`.split("\n")
|
@@ -1,17 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mongify::CLI::Application do
|
4
|
-
before(:each) do
|
5
|
-
@application = Mongify::CLI::Application.new()
|
6
|
-
end
|
7
|
-
|
8
4
|
context "execute!" do
|
9
5
|
it "should return a 0" do
|
6
|
+
@application = Mongify::CLI::Application.new()
|
7
|
+
Mongify::Configuration.out_stream = nil
|
10
8
|
@application.execute!.should == 0
|
11
9
|
end
|
12
10
|
|
13
11
|
it "should return a 1 on error" do
|
14
12
|
@application = Mongify::CLI::Application.new(["door"])
|
13
|
+
Mongify::Configuration.out_stream = nil
|
15
14
|
@application.execute!.should == 1
|
16
15
|
end
|
17
16
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
describe Mongify::CLI::
|
2
|
+
describe Mongify::CLI::Command::Help do
|
3
3
|
before :each do
|
4
4
|
@text = 'Piece of interesting text'
|
5
|
-
@cmd = Mongify::CLI::
|
5
|
+
@cmd = Mongify::CLI::Command::Help.new(@text)
|
6
6
|
@view = mock('view').as_null_object
|
7
7
|
end
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongify::CLI::
|
3
|
+
describe Mongify::CLI::Command::Version do
|
4
4
|
before :each do
|
5
5
|
@text = 'Piece of interesting text'
|
6
|
-
@cmd = Mongify::CLI::
|
6
|
+
@cmd = Mongify::CLI::Command::Version.new(@text)
|
7
7
|
@view = mock('view').as_null_object
|
8
8
|
end
|
9
9
|
|
@@ -12,7 +12,7 @@ describe Mongify::CLI::VersionCommand do
|
|
12
12
|
@cmd.execute(@view)
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'displays
|
15
|
+
it 'displays Mongify version on the view' do
|
16
16
|
@view.should_receive(:output).with(/#{Mongify::VERSION}/)
|
17
17
|
@cmd.execute(@view)
|
18
18
|
end
|
@@ -1,62 +1,58 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mongify::CLI::Options do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:config_file){File.join(Mongify.root, 'spec', 'files', 'base_configuration.rb')}
|
5
|
+
let(:translation_file){File.join(Mongify.root, 'spec', 'files', 'translation.rb')}
|
6
|
+
|
7
7
|
it "should run help command when passed an -h" do
|
8
8
|
@options = Mongify::CLI::Options.new(['-h'])
|
9
9
|
@options.parse
|
10
|
-
@options.instance_variable_get(:@command_class).should == Mongify::CLI::
|
10
|
+
@options.instance_variable_get(:@command_class).should == Mongify::CLI::Command::Help
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should run version command when passed an -h" do
|
14
14
|
@options = Mongify::CLI::Options.new(['-v'])
|
15
15
|
@options.parse
|
16
|
-
@options.instance_variable_get(:@command_class).should == Mongify::CLI::
|
16
|
+
@options.instance_variable_get(:@command_class).should == Mongify::CLI::Command::Version
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
context "action" do
|
20
20
|
it "should get action command" do
|
21
21
|
@options = Mongify::CLI::Options.new(['check'])
|
22
22
|
@options.send(:action).should == 'check'
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should return blank if no action is sent" do
|
26
26
|
@options = Mongify::CLI::Options.new(['-v'])
|
27
27
|
@options.send(:action).should == ''
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
# using check here just so that it doesn't have translate but still tests the args properly
|
31
32
|
context "translation" do
|
32
33
|
it "should return path" do
|
33
|
-
@options = Mongify::CLI::Options.new(['check',
|
34
|
-
@options.send(:translation_file).should ==
|
34
|
+
@options = Mongify::CLI::Options.new(['check', config_file, translation_file])
|
35
|
+
@options.send(:translation_file).should == translation_file
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
it "should return nil if no path specified" do
|
38
|
-
@options = Mongify::CLI::Options.new(['check',
|
39
|
+
@options = Mongify::CLI::Options.new(['check', config_file])
|
39
40
|
@options.send(:translation_file).should be_nil
|
40
41
|
end
|
41
42
|
end
|
42
|
-
|
43
|
-
|
44
|
-
context "
|
45
|
-
it "should
|
46
|
-
@options = Mongify::CLI::Options.new(['
|
43
|
+
|
44
|
+
|
45
|
+
context "config_file" do
|
46
|
+
it "should get config after action" do
|
47
|
+
@options = Mongify::CLI::Options.new(['check', config_file])
|
47
48
|
@options.parse
|
48
|
-
@options.instance_variable_get(:@config_file).
|
49
|
+
@options.instance_variable_get(:@config_file).should_not be_nil
|
49
50
|
end
|
50
|
-
|
51
|
-
it "should be require" do
|
52
|
-
@options = Mongify::CLI::Options.new(["database_translation.rb"])
|
53
|
-
lambda {@options.parse}.should raise_error(Mongify::ConfigurationFileNotFound)
|
54
|
-
end
|
55
|
-
|
51
|
+
|
56
52
|
it "should call Configuration.parse" do
|
57
|
-
Mongify::Configuration.should_receive(:parse)
|
58
|
-
@options = Mongify::CLI::Options.new(['
|
59
|
-
@options.parse
|
53
|
+
Mongify::Configuration.should_receive(:parse).and_return(Mongify::Configuration.new)
|
54
|
+
@options = Mongify::CLI::Options.new(['check', config_file])
|
55
|
+
@options.parse
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongify::CLI::
|
3
|
+
describe Mongify::CLI::Command::Worker do
|
4
4
|
before(:each) do
|
5
5
|
@config = Mongify::Configuration.new()
|
6
6
|
@sql_connection = Mongify::Database::SqlConnection.new()
|
@@ -20,13 +20,13 @@ describe Mongify::CLI::WorkerCommand do
|
|
20
20
|
|
21
21
|
context "list_commands" do
|
22
22
|
it "should return same number as available" do
|
23
|
-
Mongify::CLI::
|
23
|
+
Mongify::CLI::Command::Worker.list_commands.size.should == Mongify::CLI::Command::Worker::AVAILABLE_COMMANDS.size
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context "check command" do
|
28
28
|
before(:each) do
|
29
|
-
@command = Mongify::CLI::
|
29
|
+
@command = Mongify::CLI::Command::Worker.new('check', @config)
|
30
30
|
@command.stub(:check_sql_connection).and_return(true)
|
31
31
|
@command.stub(:check_nosql_connection).and_return(true)
|
32
32
|
end
|
@@ -39,13 +39,13 @@ describe Mongify::CLI::WorkerCommand do
|
|
39
39
|
@command.execute(@view)
|
40
40
|
end
|
41
41
|
it "should require config file" do
|
42
|
-
lambda { @command = Mongify::CLI::
|
42
|
+
lambda { @command = Mongify::CLI::Command::Worker.new('check').execute(@view) }.should raise_error(Mongify::ConfigurationFileNotFound)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
context "non-existing command" do
|
47
47
|
before(:each) do
|
48
|
-
@command = Mongify::CLI::
|
48
|
+
@command = Mongify::CLI::Command::Worker.new('unknown')
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should report error" do
|
@@ -61,12 +61,12 @@ describe Mongify::CLI::WorkerCommand do
|
|
61
61
|
|
62
62
|
context "translation command" do
|
63
63
|
before(:each) do
|
64
|
-
@command = Mongify::CLI::
|
64
|
+
@command = Mongify::CLI::Command::Worker.new('translation', @config)
|
65
65
|
Mongify::Translation.stub(:load).with(@sql_connection).and_return(stub(:print => 'worked'))
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should require configuration file" do
|
69
|
-
lambda { Mongify::CLI::
|
69
|
+
lambda { Mongify::CLI::Command::Worker.new('translation').execute(@view) }.should raise_error(Mongify::ConfigurationFileNotFound)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should check sql connection" do
|
@@ -82,7 +82,7 @@ describe Mongify::CLI::WorkerCommand do
|
|
82
82
|
|
83
83
|
context "process command" do
|
84
84
|
before(:each) do
|
85
|
-
@command = Mongify::CLI::
|
85
|
+
@command = Mongify::CLI::Command::Worker.new('process', @config, 'spec/files/translation.rb')
|
86
86
|
Mongify::Translation.stub(:parse).and_return(mock(:process => true))
|
87
87
|
end
|
88
88
|
it "should report success" do
|
@@ -92,11 +92,11 @@ describe Mongify::CLI::WorkerCommand do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should require config file" do
|
95
|
-
lambda { @command = Mongify::CLI::
|
95
|
+
lambda { @command = Mongify::CLI::Command::Worker.new('process').execute(@view) }.should raise_error(Mongify::ConfigurationFileNotFound)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should require transaction file" do
|
99
|
-
lambda { @command = Mongify::CLI::
|
99
|
+
lambda { @command = Mongify::CLI::Command::Worker.new('process', @config).execute(@view) }.should raise_error(Mongify::TranslationFileNotFound)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should check_connection" do
|
@@ -77,7 +77,7 @@ describe Mongify::Database::NoSqlConnection do
|
|
77
77
|
end
|
78
78
|
context "insert_into" do
|
79
79
|
it "should insert into a table using the mongo driver" do
|
80
|
-
@collection.should_receive(:insert).with({'first_name' => 'bob'}
|
80
|
+
@collection.should_receive(:insert).with({'first_name' => 'bob'})
|
81
81
|
@mongodb_connection.insert_into('users', {'first_name' => 'bob'})
|
82
82
|
end
|
83
83
|
end
|
@@ -1,38 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
2
|
describe Mongify::Database::SqlConnection do
|
4
3
|
before(:all) do
|
5
4
|
@db_path = DatabaseGenerator.sqlite
|
6
5
|
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
let(:sqlite_connection){Mongify::Database::SqlConnection.new(:adapter => 'sqlite3', :database => @db_path)}
|
8
|
+
let(:mysql_connection){@sql_connection = DatabaseGenerator.mysql_connection}
|
11
9
|
|
12
10
|
context "Sqlite 3 config" do
|
13
|
-
before(:each) do
|
14
|
-
@adapter = 'sqlite3'
|
15
|
-
@sql_connection = Mongify::Database::SqlConnection.new(:adapter => @adapter, :database => @db_path)
|
16
|
-
end
|
17
|
-
|
18
11
|
context "valid?" do
|
19
12
|
it "should be true" do
|
20
|
-
|
13
|
+
sqlite_connection.should be_valid
|
21
14
|
end
|
22
15
|
end
|
23
16
|
|
24
17
|
context "testing connection" do
|
25
18
|
it "should work" do
|
26
|
-
|
19
|
+
sqlite_connection.should have_connection
|
27
20
|
end
|
28
21
|
end
|
29
22
|
end
|
30
23
|
|
31
24
|
context "MySql config" do
|
32
|
-
before(:each) do
|
33
|
-
@sql_connection = DatabaseGenerator.mysql_connection
|
34
|
-
end
|
35
|
-
|
36
25
|
context "valid?" do
|
37
26
|
it "should be true" do
|
38
27
|
Mongify::Database::SqlConnection.new(:adapter => 'mysql', :host => 'localhost', :database => 'blue').should be_valid
|
@@ -43,13 +32,12 @@ describe Mongify::Database::SqlConnection do
|
|
43
32
|
end
|
44
33
|
|
45
34
|
context "testing connection" do
|
46
|
-
it "should call setup_connection_adapter before testing connection" do
|
47
|
-
@sql_connection.should_receive(:setup_connection_adapter)
|
48
|
-
@sql_connection.has_connection?
|
49
|
-
end
|
50
|
-
|
51
35
|
it "should work" do
|
52
|
-
|
36
|
+
mysql_connection.should have_connection
|
37
|
+
end
|
38
|
+
it "should call setup_connection_adapter before testing connection" do
|
39
|
+
mysql_connection.should_receive(:setup_connection_adapter)
|
40
|
+
mysql_connection.has_connection?
|
53
41
|
end
|
54
42
|
end
|
55
43
|
end
|
@@ -57,24 +45,24 @@ describe Mongify::Database::SqlConnection do
|
|
57
45
|
context "Sqlite connection" do
|
58
46
|
context "testing connection" do
|
59
47
|
it "should call setup_connection_adapter before testing connection" do
|
60
|
-
|
61
|
-
|
48
|
+
sqlite_connection.should_receive(:setup_connection_adapter)
|
49
|
+
sqlite_connection.has_connection?
|
62
50
|
end
|
63
51
|
|
64
52
|
it "should work" do
|
65
|
-
|
53
|
+
sqlite_connection.should have_connection
|
66
54
|
end
|
67
55
|
end
|
68
56
|
|
69
57
|
context "tables" do
|
70
58
|
it "should be able to get a list" do
|
71
|
-
|
59
|
+
sqlite_connection.tables.should =~ ['comments', 'notes', 'posts', 'preferences', 'users']
|
72
60
|
end
|
73
61
|
end
|
74
62
|
|
75
63
|
context "columns" do
|
76
64
|
it "should see columns for a table" do
|
77
|
-
|
65
|
+
sqlite_connection.columns_for(:users).map{ |column| column.name }.should =~ ['id', 'first_name', 'last_name', 'created_at', 'updated_at']
|
78
66
|
end
|
79
67
|
end
|
80
68
|
end
|
@@ -83,8 +71,8 @@ describe Mongify::Database::SqlConnection do
|
|
83
71
|
it "should generate correct select statement" do
|
84
72
|
@mock_conn = mock
|
85
73
|
@mock_conn.should_receive(:select_all).with('SELECT * FROM users')
|
86
|
-
|
87
|
-
|
74
|
+
sqlite_connection.stub(:connection).and_return(@mock_conn)
|
75
|
+
sqlite_connection.select_rows('users')
|
88
76
|
end
|
89
77
|
end
|
90
78
|
end
|