rivendell-import 0.7 → 0.8
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/Gemfile +10 -0
- data/Gemfile.lock +21 -16
- data/README.md +10 -21
- data/examples/.gitignore +2 -0
- data/examples/config.rb +2 -0
- data/lib/rivendell/import/cart.rb +35 -7
- data/lib/rivendell/import/cut.rb +16 -1
- data/lib/rivendell/import/task.rb +14 -3
- data/lib/rivendell/import/version.rb +1 -1
- data/lib/rivendell/import.rb +9 -2
- data/rivendell-import.gemspec +1 -1
- data/spec/rivendell/import/base_spec.rb +2 -3
- data/spec/rivendell/import/cut_spec.rb +21 -0
- data/spec/rivendell/import/task_spec.rb +89 -26
- data/spec/rivendell/import_spec.rb +39 -4
- data/spec/simplecov-default.rb +19 -0
- data/spec/spec_helper.rb +1 -6
- metadata +321 -297
@@ -2,18 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Rivendell::Import do
|
4
4
|
|
5
|
-
describe "
|
6
|
-
|
5
|
+
describe ".config" do
|
6
|
+
|
7
7
|
context "without argument" do
|
8
8
|
|
9
9
|
it "should return Rivendell::Import::Config instance" do
|
10
10
|
Rivendell::Import.config.should be_instance_of(Rivendell::Import::Config)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
|
15
15
|
context "with a block" do
|
16
|
-
|
16
|
+
|
17
17
|
it "should yield block with Config instance" do
|
18
18
|
config_instance = Rivendell::Import.config
|
19
19
|
Rivendell::Import.should_receive(:config).and_yield(config_instance)
|
@@ -26,6 +26,41 @@ describe Rivendell::Import do
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".establish_connection" do
|
32
|
+
|
33
|
+
before do
|
34
|
+
ActiveRecord::Base.stub :establish_connection
|
35
|
+
ActiveRecord::Migrator.stub :migrate
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when a file is given" do
|
39
|
+
|
40
|
+
let(:file) { '/srv/rivendell/tmp/db.sqlite3' }
|
41
|
+
|
42
|
+
it "should initialize a sqlite database" do
|
43
|
+
ActiveRecord::Base.should_receive(:establish_connection).with({ :adapter => "sqlite3", :database => file })
|
44
|
+
Rivendell::Import.establish_connection file
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when an url is given" do
|
50
|
+
|
51
|
+
let(:url) { 'mysql://import:import@localhost/import' }
|
52
|
+
|
53
|
+
it "should initialize database with given url" do
|
54
|
+
ActiveRecord::Base.should_receive(:establish_connection).with(url)
|
55
|
+
Rivendell::Import.establish_connection url
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should migrate database" do
|
61
|
+
ActiveRecord::Migrator.should_receive(:migrate).with(File.expand_path("../../../db/migrate/", __FILE__), nil)
|
62
|
+
Rivendell::Import.establish_connection
|
63
|
+
end
|
29
64
|
|
30
65
|
end
|
31
66
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
if ENV['SIMPLECOV_RCOV_OUTPUT']
|
4
|
+
require 'simplecov-rcov'
|
5
|
+
|
6
|
+
class SimpleCov::Formatter::MergedFormatter
|
7
|
+
def format(result)
|
8
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
9
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
13
|
+
end
|
14
|
+
|
15
|
+
SimpleCov.start do
|
16
|
+
add_filter "/spec/"
|
17
|
+
add_filter "/db/"
|
18
|
+
add_filter "/vendor/"
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start do
|
3
|
-
add_filter "/spec/"
|
4
|
-
add_filter "/db/"
|
5
|
-
end
|
1
|
+
require 'simplecov-default'
|
6
2
|
|
7
3
|
require 'rivendell/import'
|
8
4
|
|
@@ -12,4 +8,3 @@ Rivendell::Import.logger = ActiveRecord::Base.logger = Logger.new("log/test.log"
|
|
12
8
|
Rivendell::Import.establish_connection "db/test.sqlite3"
|
13
9
|
|
14
10
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
15
|
-
|