citrus_test 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data.tar.gz.sig +0 -0
  2. data/lib/citrus_test.rb +18 -14
  3. metadata +3 -3
  4. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
data/lib/citrus_test.rb CHANGED
@@ -54,26 +54,30 @@ class GrammarTest < Test::Unit::TestCase
54
54
  rule(rule).parse(input).value
55
55
  end
56
56
 
57
- # Assert that rule parses str into val, returning val (actually, the return
58
- # value of parse(rule, str)) if the assertion passed. Additionally, assert
59
- # that value has every attribute specified in attributes, and that they have
60
- # the value specified.
61
- def assert_parses(rule, str, val, attributes={})
62
- msg ||= "#{@@grammar}.#{rule} failed to parse #{str.inspect} properly"
57
+ # If attributes is a Hash, assert that the return value of parse(rule, str)
58
+ # has every attribute specified in attributes, and that they have the value
59
+ # specified in attributes. Otherwise, assert that the return value is equal to
60
+ # attributes. (If you want to actually assert that the result *is* a hash, try
61
+ # using :to_hash as a key.)
62
+ def assert_parses(rule, str, attributes={})
63
+ _ = "#{@@grammar}.#{rule} failed to parse #{str.inspect} properly"
63
64
 
64
65
  ret = nil
65
- assert_nothing_raised(msg) do
66
+ assert_nothing_raised(_) do
66
67
  ret = parse(rule, str)
67
- assert_equal(ret, val, msg)
68
68
  end
69
69
 
70
- attributes.each do |attr, expected_val|
71
- assert(ret.respond_to?(attr), "#{attr} doesn't exist")
72
- _ = "An exception was raised when fetching the #{attr} attribute"
73
- assert_nothing_raised(_) do
74
- _ = "#{attr} attribute has an unexpected value"
75
- assert_equal(expected_val, ret.send(attr), _)
70
+ if attributes.is_a?(Hash)
71
+ attributes.each do |attr, expected_val|
72
+ assert(ret.respond_to?(attr), "#{attr} doesn't exist")
73
+ _ = "An exception was raised when fetching the #{attr} attribute"
74
+ assert_nothing_raised(_) do
75
+ _ = "#{attr} attribute has an unexpected value"
76
+ assert_equal(expected_val, ret.send(attr), _)
77
+ end
76
78
  end
79
+ else
80
+ assert_equal(attributes, ret, _)
77
81
  end
78
82
 
79
83
  ret
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - katmagic
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Zn3u2leVae/fJ03zYGArhuJKPgc=
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2011-08-22 00:00:00 -04:00
38
+ date: 2011-08-26 00:00:00 -04:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file