jsonit 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,12 @@ module Jsonit
15
15
  def to_json(*args)
16
16
  @document.to_json(*args)
17
17
  end
18
+ alias_method :as_json, :to_json
19
+
20
+ def encode_json(*)
21
+ @document
22
+ end
23
+ alias_method :as_json, :encode_json
18
24
 
19
25
  def set!(key=nil, value=nil, &blk)
20
26
  if !block_given?
@@ -1,3 +1,3 @@
1
1
  module Jsonit
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -126,11 +126,10 @@ describe Jsonit::Builder do
126
126
 
127
127
  it 'does not raise method missing for method with format /^[a-z][a-z0-9]+$/' do
128
128
  [:a, :b, :c].each do |m|
129
- expect { json.send(m) }.to_not raise_error
129
+ expect { eval("json.#{m.to_s}") }.to_not raise_error(NoMethodError)
130
130
  end
131
131
  end
132
132
 
133
-
134
133
  it 'raises method missing for ending with a "?"' do
135
134
  [:a?, :b?, :c?].each do |m|
136
135
  expect { eval("json.#{m.to_s}") }.to raise_error(NoMethodError)
@@ -142,6 +141,16 @@ describe Jsonit::Builder do
142
141
  expect { eval("json.#{m.to_s}") }.to raise_error(NoMethodError)
143
142
  end
144
143
  end
144
+
145
+ it 'ignores #encode_json' do
146
+ json.encode_json
147
+ json.to_json.should_not match /"encode_json"/
148
+ end
149
+
150
+ it 'ignores #as_json' do
151
+ json.as_json
152
+ json.to_json.should_not match /"as_json"/
153
+ end
145
154
  end
146
155
 
147
156
  describe "DSL" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jsonit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Klaas Speller
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-26 00:00:00 +02:00
13
+ date: 2011-04-29 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency