hash_dealer 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -14,4 +14,5 @@ group :development do
14
14
  gem "rcov"
15
15
  gem "guard-rspec", "=0.4.0"
16
16
  gem "ruby-debug19", :require => "ruby-debug"
17
+ gem "simplecov"
17
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
data/hash_dealer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash_dealer}
8
- s.version = "1.3.0"
8
+ s.version = "1.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
12
- s.date = %q{2011-08-26}
12
+ s.date = %q{2011-09-05}
13
13
  s.description = %q{Like Factory Girl but for Hashes only}
14
14
  s.email = %q{dan.langevin@lifebooker.com}
15
15
  s.extra_rdoc_files = [
@@ -53,6 +53,7 @@ Gem::Specification.new do |s|
53
53
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
54
  s.add_development_dependency(%q<guard-rspec>, ["= 0.4.0"])
55
55
  s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
56
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
56
57
  else
57
58
  s.add_dependency(%q<activesupport>, [">= 0"])
58
59
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -61,6 +62,7 @@ Gem::Specification.new do |s|
61
62
  s.add_dependency(%q<rcov>, [">= 0"])
62
63
  s.add_dependency(%q<guard-rspec>, ["= 0.4.0"])
63
64
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
65
+ s.add_dependency(%q<simplecov>, [">= 0"])
64
66
  end
65
67
  else
66
68
  s.add_dependency(%q<activesupport>, [">= 0"])
@@ -70,6 +72,7 @@ Gem::Specification.new do |s|
70
72
  s.add_dependency(%q<rcov>, [">= 0"])
71
73
  s.add_dependency(%q<guard-rspec>, ["= 0.4.0"])
72
74
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
75
+ s.add_dependency(%q<simplecov>, [">= 0"])
73
76
  end
74
77
  end
75
78
 
data/lib/matcher.rb CHANGED
@@ -22,7 +22,12 @@ RSpec::Matchers.define(:match_list) do |actual|
22
22
 
23
23
  def normalize(val)
24
24
  val = JSON.parse(val) if val.is_a?(String)
25
- val = val.first if val.is_a?(Array)
25
+ # if it's an array, we want just the first value
26
+ if val.is_a?(Array)
27
+ # we append :matcher to account for variable length arrays - that causes a problem
28
+ # when the array is at the root and we are looking for the first element
29
+ val = val.first == ":matcher" ? val[1] : val.first
30
+ end
26
31
  val
27
32
  end
28
33
 
data/lib/path_string.rb CHANGED
@@ -34,9 +34,9 @@ class PathString < String
34
34
 
35
35
  # helper method to be called recursively
36
36
  def self.sort_json(val)
37
- val = val.is_a?(String) ? ActiveSupport::JSON.decode(val).sort : ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(val)).sort
37
+ val = val.is_a?(String) ? ActiveSupport::JSON.decode(val) : ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(val))
38
38
  val = val.collect{|v| v.collect{|n| n.is_a?(Hash) ? self.sort_json(n) : n}}
39
- val
39
+ val.sort
40
40
  end
41
41
 
42
42
  #
@@ -141,4 +141,8 @@ describe HashDealer do
141
141
  HashDealer.roll(:b).should eql({:hash_a => {:a => "123"}})
142
142
  end
143
143
 
144
+ it "should allow nested blocks of attributes" do
145
+ HashDealer.roll(:b).should eql({:hash_a => {:a => "123"}})
146
+ end
147
+
144
148
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- describe "match_resonse Matcher" do
3
+ describe "match_response Matcher" do
4
4
 
5
5
  it "should match hashes" do
6
6
  {:a => "b"}.should match_response({"a" => ":test"})
@@ -14,6 +14,10 @@ describe "match_resonse Matcher" do
14
14
  {"a" => ":b"}.should match_list([{"a" => "test"}, {"a" => "test2"}])
15
15
  end
16
16
 
17
+ it "should account for the first :matcher param when it's at the root" do
18
+ JSON.unparse([{"a" => "b"}, {"a" => "c"}]).should match_list({"a" => ":b"})
19
+ end
20
+
17
21
  it "should match using wildcards for variable length arrays" do
18
22
  {"a" => ["a"]}.matcher.should match_response({"a" => ["a", "b", "c", "d"]})
19
23
  {"a" => [{"a" => "b"}]}.matcher.should match_response({"a" => [{"a" => "c"},{"a" => "x"},{"a" => "y"}]})
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,12 @@
1
+ require 'simplecov'
2
+ SimpleCov.start 'rails' do
3
+ add_filter 'spec'
4
+ end
5
+
6
+ SimpleCov.at_exit do
7
+ SimpleCov.result.format!
8
+ end
9
+
1
10
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
11
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
12
  require 'bundler'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hash_dealer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.0
5
+ version: 1.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Langevin
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-26 00:00:00 Z
13
+ date: 2011-09-05 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -89,6 +89,17 @@ dependencies:
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
+ name: simplecov
94
+ requirement: &id008 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *id008
92
103
  description: Like Factory Girl but for Hashes only
93
104
  email: dan.langevin@lifebooker.com
94
105
  executables: []
@@ -130,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
141
  requirements:
131
142
  - - ">="
132
143
  - !ruby/object:Gem::Version
133
- hash: -979585820027461548
144
+ hash: 967117454047752142
134
145
  segments:
135
146
  - 0
136
147
  version: "0"