ccp 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -88,7 +88,11 @@ module Ccp
88
88
  end
89
89
 
90
90
  def fixture_save?(cmd)
91
- return true if cmd.class.save # highest priority
91
+ # highest priority
92
+ case cmd.class.save
93
+ when true ; return true
94
+ when false ; return false
95
+ end
92
96
 
93
97
  case (obj = self[:fixture_save])
94
98
  when true ; true
data/lib/ccp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ccp
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+ require 'fileutils'
3
+
4
+ describe "Ccp::Commands::Core" do
5
+ describe ".execute" do
6
+ before do
7
+ FileUtils.rm_rf("tmp")
8
+ end
9
+
10
+ context "(:fixture_save=>true, :fixture_ext=>:msgpack)" do
11
+ it "should generate stub/mock fixtures in tmp/fixtures as yaml files" do
12
+ path = Pathname("tmp/fixtures")
13
+ data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
14
+ opts = {:fixture_save=>true, :fixture_ext=>:msgpack}
15
+
16
+ TSFC.execute(data.merge(opts))
17
+
18
+ load_fixture(path + "tsfc/stub.msgpack").should == {"a" => "a"}
19
+ load_fixture(path + "tsfc/mock.msgpack").should == {"x" => 10}
20
+ end
21
+ end
22
+
23
+ context "(:fixture_save=>true, :fixture_ext=>:msgpack, :fixture_kvs=>:dir)" do
24
+ it "should generate stub/mock fixtures in tmp/fixtures as yaml files" do
25
+ path = Pathname("tmp/fixtures")
26
+ data = {:a=>"a", :b=>"b", :x=>1, :y=>2}
27
+ opts = {:fixture_save=>true, :fixture_ext=>:msgpack, :fixture_kvs=>:dir}
28
+
29
+ TSFC.execute(data.merge(opts))
30
+
31
+ load_fixture(path + "tsfc/stub.msgpack/a.msgpack").should == "a"
32
+ load_fixture(path + "tsfc/mock.msgpack/x.msgpack").should == 10
33
+ end
34
+ end
35
+ end
36
+ end
@@ -45,6 +45,29 @@ describe Ccp::Commands::Composite do
45
45
  ["cmd1", "cmd2", "cmd3", "program"]
46
46
  end
47
47
 
48
+ ######################################################################
49
+ ### explict flag
50
+
51
+ context "flag: nil" do
52
+ before { Cmd1.save nil }
53
+ execute(:fixture_save => false) { [] }
54
+ execute(:fixture_save => true ) { ["cmd1", "cmd2", "cmd3", "program"] }
55
+ end
56
+
57
+ context "flag: true" do
58
+ before { Cmd1.save true }
59
+ after { Cmd1.save nil }
60
+ execute(:fixture_save => false) { ["cmd1"] }
61
+ execute(:fixture_save => true ) { ["cmd1", "cmd2", "cmd3", "program"] }
62
+ end
63
+
64
+ context "flag: false" do
65
+ before { Cmd1.save false }
66
+ after { Cmd1.save nil }
67
+ execute(:fixture_save => false) { [] }
68
+ execute(:fixture_save => true ) { ["cmd2", "cmd3", "program"] }
69
+ end
70
+
48
71
  ######################################################################
49
72
  ### accepts
50
73
 
data/spec/spec_helper.rb CHANGED
@@ -37,7 +37,7 @@ def breadcrumbs_receiver
37
37
  end
38
38
 
39
39
  def lookup_serializer(extname)
40
- {".json"=>JSON, ".yaml"=>YAML}[extname] or raise "no serializers for #{extname}"
40
+ {".json"=>JSON, ".yaml"=>YAML, ".msgpack"=>MessagePack}[extname] or raise "no serializers for #{extname}"
41
41
  end
42
42
 
43
43
  def load_fixture(path)
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.1
4
+ version: 0.4.2
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-11-26 00:00:00.000000000 Z
12
+ date: 2013-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -292,6 +292,7 @@ files:
292
292
  - spec/persistent/loadable_spec.rb
293
293
  - spec/persistent/tsv_spec.rb
294
294
  - spec/persistent/versioned_spec.rb
295
+ - spec/receivers/fixture_msgpack_spec.rb
295
296
  - spec/receivers/fixture_save_how_spec.rb
296
297
  - spec/receivers/fixture_save_ignore_logger_spec.rb
297
298
  - spec/receivers/fixture_save_what_spec.rb