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.
- data/lib/assert_json/assert_json.rb +11 -2
- data/lib/assert_json/version.rb +1 -1
- data/test/assert_json_new_dsl_test.rb +6 -1
- metadata +1 -1
@@ -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)
|
data/lib/assert_json/version.rb
CHANGED
@@ -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
|