king_placeholder 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gem 'king_views', :git => 'https://github.com/salesking/king_views.git', :branch => 'develop'
3
2
  gemspec
@@ -94,8 +94,8 @@ module KingPlaceholder
94
94
  else
95
95
  obj.send @field
96
96
  end
97
- #value = strfval(obj, @field)
98
- @result.gsub!(@placeholder, value.to_s) if value
97
+ value = '' if value.nil?
98
+ @result.gsub!(@placeholder, value.to_s)
99
99
  end
100
100
 
101
101
  # Namespaced notation, for related objects. E.g an invoice belonging to a
@@ -1,3 +1,3 @@
1
1
  module KingPlaceholder
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -127,17 +127,25 @@ describe 'Placeholder substitution' do
127
127
  it 'should parse multiple steps' do
128
128
  @detail1.expand_placeholders('[master.side.field]').should == '123'
129
129
  end
130
+
130
131
  end
131
132
 
132
133
  context 'with empty fields' do
134
+
133
135
  it 'should expand valid but empty placeholder group with empty string' do
134
136
  master = Master.new
135
137
  master.details = []
136
138
  master.expand_placeholders('[details][int_field][/details]').should == ''
137
139
  end
140
+
138
141
  it 'should expand single item group with empty string' do
139
142
  @master.expand_placeholders('[details.10.int_field]').should == ''
140
143
  end
144
+
145
+ it 'should parse related object field with empty string' do
146
+ @master.string_field = nil
147
+ @detail1.expand_placeholders('[master.string_field]').should == ''
148
+ end
141
149
  end
142
150
 
143
151
  context 'with collection' do
data/spec/spec_helper.rb CHANGED
@@ -12,5 +12,6 @@ require 'rspec'
12
12
  require 'active_record'
13
13
  require 'king_placeholder'
14
14
 
15
+ Dir[File.join(File.dirname(__FILE__),"support/**/*.rb")].each {|f| require f}
15
16
  RSpec.configure do |config|
16
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: king_placeholder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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: 2012-07-29 00:00:00.000000000 Z
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: statemachine
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: 3312225675603911462
176
+ hash: -1913045486927404314
177
177
  required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements:
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  segments:
184
184
  - 0
185
- hash: 3312225675603911462
185
+ hash: -1913045486927404314
186
186
  requirements: []
187
187
  rubyforge_project:
188
188
  rubygems_version: 1.8.24