ccp 0.4.2 → 0.4.3
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/.gitignore +1 -0
- data/Gemfile.jruby +3 -0
- data/lib/ccp/persistent/dir.rb +2 -2
- data/lib/ccp/persistent/file.rb +2 -2
- data/lib/ccp/persistent/versioned.rb +1 -1
- data/lib/ccp/receivers/fixtures.rb +2 -2
- data/lib/ccp/version.rb +1 -1
- data/spec/commands/fixturable_test_composite_spec.rb +14 -14
- data/spec/commands/fixturable_test_spec.rb +6 -6
- data/spec/examples/fixture_save_dir_and_test_spec.rb +18 -18
- data/spec/invokers/save_fixture_spec.rb +4 -3
- data/spec/persistent/dir_spec.rb +19 -6
- data/spec/persistent/file_spec.rb +38 -0
- data/spec/receivers/fixture_msgpack_spec.rb +6 -6
- data/spec/receivers/fixture_save_how_spec.rb +8 -8
- data/spec/receivers/fixture_save_ignore_logger_spec.rb +2 -2
- data/spec/receivers/fixture_save_what_spec.rb +2 -1
- data/spec/receivers/fixture_save_where_spec.rb +10 -10
- data/spec/receivers/fixture_save_why_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -7
- metadata +3 -2
data/.gitignore
CHANGED
data/Gemfile.jruby
ADDED
data/lib/ccp/persistent/dir.rb
CHANGED
@@ -12,7 +12,7 @@ class Ccp::Persistent::Dir < Ccp::Persistent::Base
|
|
12
12
|
def load!(key)
|
13
13
|
path = path_for(key)
|
14
14
|
if path.exist?
|
15
|
-
decode(path.read{})
|
15
|
+
decode(path.open("rb").read{})
|
16
16
|
else
|
17
17
|
raise Ccp::Persistent::NotFound, key.to_s
|
18
18
|
end
|
@@ -25,7 +25,7 @@ class Ccp::Persistent::Dir < Ccp::Persistent::Base
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def []=(key, val)
|
28
|
-
path_for(key).open("
|
28
|
+
path_for(key).open("wb+"){|f| f.print encode(val)}
|
29
29
|
end
|
30
30
|
|
31
31
|
def keys
|
data/lib/ccp/persistent/file.rb
CHANGED
@@ -55,12 +55,12 @@ class Ccp::Persistent::File < Ccp::Persistent::Base
|
|
55
55
|
|
56
56
|
def read!
|
57
57
|
path.exist? or raise Ccp::Persistent::NotFound, path.to_s
|
58
|
-
decode(path.read{}).must(Hash)
|
58
|
+
decode(path.open("rb").read{}).must(Hash)
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
62
62
|
def raw_write(buf)
|
63
63
|
path.parent.mkpath
|
64
|
-
path.open("
|
64
|
+
path.open("wb+"){|f| f.print buf}
|
65
65
|
end
|
66
66
|
end
|
@@ -33,8 +33,8 @@ module Ccp
|
|
33
33
|
|
34
34
|
# Values
|
35
35
|
self[:fixture_dir] = "tmp/fixtures"
|
36
|
-
self[:fixture_kvs] = :
|
37
|
-
self[:fixture_ext] = :
|
36
|
+
self[:fixture_kvs] = :dir
|
37
|
+
self[:fixture_ext] = :msgpack
|
38
38
|
self[:fixture_save] = false
|
39
39
|
self[:fixture_test] = false
|
40
40
|
self[:fixture_keys] = true
|
data/lib/ccp/version.rb
CHANGED
@@ -29,19 +29,19 @@ describe Ccp::Receivers::Fixtures do
|
|
29
29
|
it "should test CRFC1, CRFC2, CRFF in order" do
|
30
30
|
lambda {
|
31
31
|
CRFCC.test
|
32
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc1/mock.
|
32
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc1/mock.msgpack")
|
33
33
|
|
34
|
-
save_fixture("tmp/fixtures/crfc1/mock.
|
34
|
+
save_fixture("tmp/fixtures/crfc1/mock.msgpack", "a"=>1)
|
35
35
|
lambda {
|
36
36
|
CRFCC.test
|
37
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.
|
37
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.msgpack")
|
38
38
|
|
39
|
-
save_fixture("tmp/fixtures/crfc2/mock.
|
39
|
+
save_fixture("tmp/fixtures/crfc2/mock.msgpack", "b"=>2)
|
40
40
|
lambda {
|
41
41
|
CRFCC.test
|
42
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfcc/mock.
|
42
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfcc/mock.msgpack")
|
43
43
|
|
44
|
-
save_fixture("tmp/fixtures/crfcc/mock.
|
44
|
+
save_fixture("tmp/fixtures/crfcc/mock.msgpack", {})
|
45
45
|
lambda {
|
46
46
|
CRFCC.test
|
47
47
|
}.should_not raise_error
|
@@ -51,7 +51,7 @@ describe Ccp::Receivers::Fixtures do
|
|
51
51
|
it "should test only CRFC2" do
|
52
52
|
lambda {
|
53
53
|
CRFCC.test(:fixture_test=>'CRFC2')
|
54
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.
|
54
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.msgpack")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -61,19 +61,19 @@ describe Ccp::Receivers::Fixtures do
|
|
61
61
|
it "should test CRFC1, CRFC2, CRFF in order" do
|
62
62
|
lambda {
|
63
63
|
CRFCC.execute(:fixture_test=>true)
|
64
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc1/mock.
|
64
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc1/mock.msgpack")
|
65
65
|
|
66
|
-
save_fixture("tmp/fixtures/crfc1/mock.
|
66
|
+
save_fixture("tmp/fixtures/crfc1/mock.msgpack", "a"=>1)
|
67
67
|
lambda {
|
68
68
|
CRFCC.execute(:fixture_test=>true)
|
69
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.
|
69
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.msgpack")
|
70
70
|
|
71
|
-
save_fixture("tmp/fixtures/crfc2/mock.
|
71
|
+
save_fixture("tmp/fixtures/crfc2/mock.msgpack", "b"=>2)
|
72
72
|
lambda {
|
73
73
|
CRFCC.execute(:fixture_test=>true)
|
74
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfcc/mock.
|
74
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfcc/mock.msgpack")
|
75
75
|
|
76
|
-
save_fixture("tmp/fixtures/crfcc/mock.
|
76
|
+
save_fixture("tmp/fixtures/crfcc/mock.msgpack", {})
|
77
77
|
lambda {
|
78
78
|
CRFCC.execute(:fixture_test=>true)
|
79
79
|
}.should_not raise_error
|
@@ -84,7 +84,7 @@ describe Ccp::Receivers::Fixtures do
|
|
84
84
|
it "should test only CRFC2" do
|
85
85
|
lambda {
|
86
86
|
CRFCC.execute(:fixture_test=>'CRFC2')
|
87
|
-
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.
|
87
|
+
}.should raise_error(Ccp::Fixtures::NotFound, "tmp/fixtures/crfc2/mock.msgpack")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Ccp::Commands::Fixturable do
|
4
4
|
before do
|
5
|
-
@stub = Pathname("tmp/fixtures/square_cmd/stub.
|
6
|
-
@mock = Pathname("tmp/fixtures/square_cmd/mock.
|
5
|
+
@stub = Pathname("tmp/fixtures/square_cmd/stub.msgpack")
|
6
|
+
@mock = Pathname("tmp/fixtures/square_cmd/mock.msgpack")
|
7
7
|
@stub.parent.mkpath
|
8
8
|
save_fixture(@stub, "x"=>10)
|
9
9
|
save_fixture(@mock, "x"=>100)
|
@@ -21,13 +21,13 @@ describe Ccp::Commands::Fixturable do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class SquareCmdPass < SquareCmd
|
24
|
-
stub "tmp/fixtures/square_cmd/stub.
|
25
|
-
mock "tmp/fixtures/square_cmd/mock.
|
24
|
+
stub "tmp/fixtures/square_cmd/stub.msgpack"
|
25
|
+
mock "tmp/fixtures/square_cmd/mock.msgpack"
|
26
26
|
end
|
27
27
|
|
28
28
|
class SquareCmdFail < SquareCmd
|
29
|
-
stub "tmp/fixtures/square_cmd/stub.
|
30
|
-
mock "tmp/fixtures/square_cmd/mock.
|
29
|
+
stub "tmp/fixtures/square_cmd/stub.msgpack"
|
30
|
+
mock "tmp/fixtures/square_cmd/mock.msgpack"
|
31
31
|
|
32
32
|
def execute
|
33
33
|
data[:x] = data[:x] + 1
|
@@ -32,46 +32,46 @@ describe Ccp::Receivers::Fixtures do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe ".execute" do
|
35
|
-
context "(:fixture_save=>true, :fixture_kvs=>:dir, :fixture_ext=>:
|
36
|
-
before { @options = {:fixture_save=>true, :fixture_kvs=>:dir, :fixture_ext=>:
|
35
|
+
context "(:fixture_save=>true, :fixture_kvs=>:dir, :fixture_ext=>:msgpack)" do
|
36
|
+
before { @options = {:fixture_save=>true, :fixture_kvs=>:dir, :fixture_ext=>:msgpack} }
|
37
37
|
|
38
38
|
it "should create stubs and mocks as dir" do
|
39
39
|
Example1::Main.execute(@options)
|
40
40
|
|
41
41
|
Pathname("tmp/fixtures/example1").should exist
|
42
|
-
Dir["tmp/**/*.
|
43
|
-
["tmp/fixtures/example1/calculate_mean/mock.
|
44
|
-
"tmp/fixtures/example1/calculate_mean/mock.
|
45
|
-
"tmp/fixtures/example1/calculate_mean/stub.
|
46
|
-
"tmp/fixtures/example1/calculate_mean/stub.
|
47
|
-
"tmp/fixtures/example1/load_ints/mock.
|
48
|
-
"tmp/fixtures/example1/load_ints/mock.
|
49
|
-
"tmp/fixtures/example1/main/mock.
|
50
|
-
"tmp/fixtures/example1/main/mock.
|
51
|
-
"tmp/fixtures/example1/main/mock.
|
52
|
-
"tmp/fixtures/example1/main/stub.
|
53
|
-
"tmp/fixtures/example1/main/stub.
|
42
|
+
Dir["tmp/**/*.msgpack"].sort.should ==
|
43
|
+
["tmp/fixtures/example1/calculate_mean/mock.msgpack",
|
44
|
+
"tmp/fixtures/example1/calculate_mean/mock.msgpack/mean.msgpack",
|
45
|
+
"tmp/fixtures/example1/calculate_mean/stub.msgpack",
|
46
|
+
"tmp/fixtures/example1/calculate_mean/stub.msgpack/ints.msgpack",
|
47
|
+
"tmp/fixtures/example1/load_ints/mock.msgpack",
|
48
|
+
"tmp/fixtures/example1/load_ints/mock.msgpack/ints.msgpack",
|
49
|
+
"tmp/fixtures/example1/main/mock.msgpack",
|
50
|
+
"tmp/fixtures/example1/main/mock.msgpack/ints.msgpack",
|
51
|
+
"tmp/fixtures/example1/main/mock.msgpack/mean.msgpack",
|
52
|
+
"tmp/fixtures/example1/main/stub.msgpack",
|
53
|
+
"tmp/fixtures/example1/main/stub.msgpack/ints.msgpack"]
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should pass all test" do
|
57
57
|
Example1::Main.execute(@options)
|
58
58
|
lambda {
|
59
|
-
Example1::Main.test
|
59
|
+
Example1::Main.test(:fixture_kvs=>:dir, :fixture_ext=>:msgpack)
|
60
60
|
}.should_not raise_error
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should pass partial test" do
|
64
64
|
Example1::Main.execute(@options)
|
65
65
|
lambda {
|
66
|
-
Example1::CalculateMean.test
|
66
|
+
Example1::CalculateMean.test(:fixture_kvs=>:dir, :fixture_ext=>:msgpack)
|
67
67
|
}.should_not raise_error
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should raise Typed::NotDefined when partial stub file is deleted" do
|
71
71
|
Example1::Main.execute(@options)
|
72
|
-
Pathname("tmp/fixtures/example1/calculate_mean/stub.
|
72
|
+
Pathname("tmp/fixtures/example1/calculate_mean/stub.msgpack/ints.msgpack").unlink
|
73
73
|
lambda {
|
74
|
-
Example1::CalculateMean.test
|
74
|
+
Example1::CalculateMean.test(:fixture_kvs=>:dir, :fixture_ext=>:msgpack)
|
75
75
|
}.should raise_error(Typed::NotDefined, /'ints' is not initialized/)
|
76
76
|
end
|
77
77
|
end
|
@@ -8,15 +8,16 @@ describe Ccp::Invokers::Base do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
context "(:fixture_save=>true)" do
|
11
|
-
it "should generate stub/mock fixtures in tmp/fixtures as
|
11
|
+
it "should generate stub/mock fixtures in tmp/fixtures as msgpack files" do
|
12
12
|
path = Pathname("tmp/fixtures")
|
13
13
|
data = {:breadcrumbs => []}
|
14
14
|
opts = {:fixture_save=>true}
|
15
15
|
|
16
16
|
CompositeInvoker.execute(data.merge(opts))
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
stub = path + "composite_invoker/stub.msgpack"
|
19
|
+
stub.should exist
|
20
|
+
load_fixture("#{stub}/breadcrumbs.msgpack").should ==
|
20
21
|
["CompositeInvoker#before",
|
21
22
|
"Cmd1#before", "Cmd1#execute", "Cmd1#after",
|
22
23
|
"Cmd23#before",
|
data/spec/persistent/dir_spec.rb
CHANGED
@@ -137,12 +137,25 @@ describe Ccp::Persistent::Dir do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
context "(:json)" do
|
141
|
+
it "should save data into storage and load it" do
|
142
|
+
kvs = Ccp::Persistent::Dir.new(db1, :json)
|
143
|
+
kvs[:foo] = "[1,2,3]"
|
144
|
+
|
145
|
+
FileUtils.mv(db1, db2)
|
146
|
+
kvs = Ccp::Persistent::Dir.new(db2, :json)
|
147
|
+
kvs[:foo].should == "[1,2,3]"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "(:msgpack)" do
|
152
|
+
it "should save data into storage and load it" do
|
153
|
+
kvs = Ccp::Persistent::Dir.new(db1, :msgpack)
|
154
|
+
kvs[:flag] = [false, [], true, 1.2]
|
143
155
|
|
144
|
-
|
145
|
-
|
146
|
-
|
156
|
+
FileUtils.mv(db1, db2)
|
157
|
+
kvs = Ccp::Persistent::Dir.new(db2, :msgpack)
|
158
|
+
kvs[:flag].should == [false, [], true, 1.2]
|
159
|
+
end
|
147
160
|
end
|
148
161
|
end
|
@@ -156,4 +156,42 @@ describe Ccp::Persistent::File do
|
|
156
156
|
db.should_not exist
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
context "(:json)" do
|
161
|
+
def db1; Pathname("tmp/spec/ccp/persistent/file/db1.json"); end
|
162
|
+
def db2; Pathname("tmp/spec/ccp/persistent/file/db2.json"); end
|
163
|
+
|
164
|
+
before do
|
165
|
+
FileUtils.rm_rf(db1)
|
166
|
+
FileUtils.rm_rf(db2)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should save data into storage and load it" do
|
170
|
+
kvs = Ccp::Persistent::File.new(db1, :json)
|
171
|
+
kvs[:foo] = "[1,2,3]"
|
172
|
+
|
173
|
+
FileUtils.mv(db1, db2)
|
174
|
+
kvs = Ccp::Persistent::File.new(db2, :json)
|
175
|
+
kvs[:foo].should == "[1,2,3]"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "(:msgpack)" do
|
180
|
+
def db1; Pathname("tmp/spec/ccp/persistent/file/db1.msgpack"); end
|
181
|
+
def db2; Pathname("tmp/spec/ccp/persistent/file/db2.msgpack"); end
|
182
|
+
|
183
|
+
before do
|
184
|
+
FileUtils.rm_rf(db1)
|
185
|
+
FileUtils.rm_rf(db2)
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should save data into storage and load it" do
|
189
|
+
kvs = Ccp::Persistent::File.new(db1, :msgpack)
|
190
|
+
kvs[:flag] = [false, [], true, 1.2]
|
191
|
+
|
192
|
+
FileUtils.mv(db1, db2)
|
193
|
+
kvs = Ccp::Persistent::File.new(db2, :msgpack)
|
194
|
+
kvs[:flag].should == [false, [], true, 1.2]
|
195
|
+
end
|
196
|
+
end
|
159
197
|
end
|
@@ -7,16 +7,16 @@ describe "Ccp::Commands::Core" do
|
|
7
7
|
FileUtils.rm_rf("tmp")
|
8
8
|
end
|
9
9
|
|
10
|
-
context "(:fixture_save=>true, :fixture_ext=>:msgpack)" do
|
10
|
+
context "(:fixture_save=>true, :fixture_ext=>:msgpack, :fixture_kvs=>:file)" do
|
11
11
|
it "should generate stub/mock fixtures in tmp/fixtures as yaml files" do
|
12
12
|
path = Pathname("tmp/fixtures")
|
13
13
|
data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
|
14
|
-
opts = {:fixture_save=>true, :fixture_ext=>:msgpack}
|
14
|
+
opts = {:fixture_save=>true, :fixture_ext=>:msgpack, :fixture_kvs=>:file}
|
15
15
|
|
16
16
|
TSFC.execute(data.merge(opts))
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
Ccp::Persistent::File.new(path + "tsfc/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
19
|
+
Ccp::Persistent::File.new(path + "tsfc/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -28,8 +28,8 @@ describe "Ccp::Commands::Core" do
|
|
28
28
|
|
29
29
|
TSFC.execute(data.merge(opts))
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
Ccp::Persistent::Dir.new(path + "tsfc/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
32
|
+
Ccp::Persistent::Dir.new(path + "tsfc/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -8,15 +8,15 @@ describe "Ccp::Commands::Core" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
context "(:fixture_save=>true)" do
|
11
|
-
it "should generate stub/mock fixtures in tmp/fixtures as
|
11
|
+
it "should generate stub/mock fixtures in tmp/fixtures as msgpack files" do
|
12
12
|
path = Pathname("tmp/fixtures")
|
13
13
|
data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
|
14
14
|
opts = {:fixture_save=>true}
|
15
15
|
|
16
16
|
TSFC.execute(data.merge(opts))
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
Ccp::Persistent::Dir.new(path + "tsfc/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
19
|
+
Ccp::Persistent::Dir.new(path + "tsfc/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -28,21 +28,21 @@ describe "Ccp::Commands::Core" do
|
|
28
28
|
|
29
29
|
TSFC.execute(data.merge(opts))
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
Ccp::Persistent::Dir.new(path + "tsfc/stub.yaml", :yaml).read.should == {"a" => "a"}
|
32
|
+
Ccp::Persistent::Dir.new(path + "tsfc/mock.yaml", :yaml).read.should == {"x" => 10}
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context "(:fixture_save=>true, :fixture_kvs=>:dir)" do
|
37
|
-
it "should generate
|
37
|
+
it "should generate msgpack files in stub/mock dir" do
|
38
38
|
path = Pathname("tmp/fixtures")
|
39
39
|
data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
|
40
40
|
opts = {:fixture_save=>true, :fixture_kvs=>:dir}
|
41
41
|
|
42
42
|
TSFC.execute(data.merge(opts))
|
43
43
|
|
44
|
-
load_fixture(path + "tsfc/stub.
|
45
|
-
load_fixture(path + "tsfc/mock.
|
44
|
+
load_fixture(path + "tsfc/stub.msgpack/a.msgpack").should == "a"
|
45
|
+
load_fixture(path + "tsfc/mock.msgpack/x.msgpack").should == 10
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -21,8 +21,8 @@ describe Ccp::Invokers::Base do
|
|
21
21
|
it "should ignore :logger in default" do
|
22
22
|
ULI.execute(:a=>"a", :fixture_save=>true)
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
Ccp::Persistent::Dir.new("tmp/fixtures/uli/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
25
|
+
Ccp::Persistent::Dir.new("tmp/fixtures/uli/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -8,15 +8,15 @@ describe "Ccp::Commands::Core" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
context "(:fixture_save=>true, :fixture_dir=>...)" do
|
11
|
-
it "should generate stub/mock fixtures in <save_fixture_dir> as
|
11
|
+
it "should generate stub/mock fixtures in <save_fixture_dir> as msgpack files" do
|
12
12
|
path = Pathname("tmp/test/fixtures")
|
13
13
|
data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
|
14
14
|
opts = {:fixture_save=>true, :fixture_dir=>path.to_s}
|
15
15
|
|
16
16
|
TSFC.execute(data.merge(opts))
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
Ccp::Persistent::Dir.new(path + "tsfc/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
19
|
+
Ccp::Persistent::Dir.new(path + "tsfc/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -26,8 +26,8 @@ describe "Ccp::Commands::Core" do
|
|
26
26
|
opts = {:fixture_save=>true}
|
27
27
|
|
28
28
|
begin
|
29
|
-
TSFC.stub "tmp/tsfc/in.
|
30
|
-
TSFC.mock "tmp/tsfc/out.
|
29
|
+
TSFC.stub "tmp/tsfc/in.msgpack"
|
30
|
+
TSFC.mock "tmp/tsfc/out.msgpack"
|
31
31
|
|
32
32
|
TSFC.execute(data.merge(opts))
|
33
33
|
ensure
|
@@ -35,11 +35,11 @@ describe "Ccp::Commands::Core" do
|
|
35
35
|
TSFC.mock nil
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
Ccp::Persistent::Dir.new("tmp/tsfc/in.msgpack" , :msgpack).read.should == {"a" => "a"}
|
39
|
+
Ccp::Persistent::Dir.new("tmp/tsfc/out.msgpack", :msgpack).read.should == {"x" => 10}
|
40
40
|
end
|
41
41
|
|
42
|
-
it "should generate stub/mock fixtures in <dir> as
|
42
|
+
it "should generate stub/mock fixtures in <dir> as msgpack files" do
|
43
43
|
data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
|
44
44
|
opts = {:fixture_save=>true}
|
45
45
|
|
@@ -51,8 +51,8 @@ describe "Ccp::Commands::Core" do
|
|
51
51
|
TSFC.dir nil
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
Ccp::Persistent::Dir.new("tmp/foo/tsfc/stub.msgpack", :msgpack).read.should == {"a" => "a"}
|
55
|
+
Ccp::Persistent::Dir.new("tmp/foo/tsfc/mock.msgpack", :msgpack).read.should == {"x" => 10}
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -13,7 +13,7 @@ describe Ccp::Commands::Composite do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def created_fixtures
|
16
|
-
Dir.chdir(FIXTURE_ROOT){Dir["*/stub.
|
16
|
+
Dir.chdir(FIXTURE_ROOT){Dir["*/stub.msgpack"].map{|i| File.dirname(i)}.sort}
|
17
17
|
rescue Errno::ENOENT
|
18
18
|
[]
|
19
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -36,19 +36,17 @@ def breadcrumbs_receiver
|
|
36
36
|
return r
|
37
37
|
end
|
38
38
|
|
39
|
-
def lookup_serializer(extname)
|
40
|
-
{".json"=>JSON, ".yaml"=>YAML, ".msgpack"=>MessagePack}[extname] or raise "no serializers for #{extname}"
|
41
|
-
end
|
42
|
-
|
43
39
|
def load_fixture(path)
|
44
40
|
path = Pathname(path)
|
45
|
-
|
41
|
+
ext = Ccp::Serializers.lookup(path.extname.sub(/^\./, ''))
|
42
|
+
ext.decode(path.open("rb").read{})
|
46
43
|
end
|
47
44
|
|
48
45
|
def save_fixture(path, obj)
|
49
46
|
path = Pathname(path)
|
50
|
-
|
51
|
-
|
47
|
+
ext = Ccp::Serializers.lookup(path.extname.sub(/^\./, ''))
|
48
|
+
buf = ext.encode(obj)
|
49
|
+
path.open("wb+"){|f| f.print buf}
|
52
50
|
end
|
53
51
|
|
54
52
|
def truncate_pathname(dir)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
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-
|
12
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -196,6 +196,7 @@ extra_rdoc_files: []
|
|
196
196
|
files:
|
197
197
|
- .gitignore
|
198
198
|
- Gemfile
|
199
|
+
- Gemfile.jruby
|
199
200
|
- README.rdoc
|
200
201
|
- Rakefile
|
201
202
|
- ccp.gemspec
|