assert_json 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,20 @@ module AssertJson
2
2
 
3
3
  def assert_json(json_string, &block)
4
4
  if block_given?
5
- json = AssertJson::Json.new(json_string)
6
- json.instance_exec(json, &block)
5
+ @json = AssertJson::Json.new(json_string)
6
+ # json.instance_exec(json, &block)
7
+ yield @json
7
8
  end
8
9
  end
9
10
 
11
+ def has(*args, &block)
12
+ @json.has(*args, &block)
13
+ end
14
+
15
+ def has_not(*args, &block)
16
+ @json.has_not(*args, &block)
17
+ end
18
+
10
19
  class Json
11
20
 
12
21
  def initialize(json_string)
@@ -1,3 +1,3 @@
1
1
  module AssertJson
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -31,6 +31,12 @@ class AssertJsonNewDslTest < Test::Unit::TestCase
31
31
  has 'key', 'value'
32
32
  end
33
33
  end
34
+ def test_single_hash_with_outer_variable
35
+ @values = {'value' => 'value'}
36
+ assert_json '{"key":"value"}' do
37
+ has 'key', @values['value']
38
+ end
39
+ end
34
40
  def test_single_hash_crosscheck_for_key
35
41
  assert_raises(MiniTest::Assertion) do
36
42
  assert_json '{"key":"value"}' do
@@ -264,5 +270,4 @@ class AssertJsonNewDslTest < Test::Unit::TestCase
264
270
  end
265
271
  end
266
272
  end
267
-
268
273
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: assert_json
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Thorsten B\xC3\xB6ttger"