README.md in diff_matcher-2.2.3 vs README.md in diff_matcher-2.3.1
- old
+ new
@@ -72,10 +72,17 @@
``` ruby
p DiffMatcher::difference(/[a-z]/, "a")
# => nil
```
+When `actual` is a fixnum that matches the `expected` range
+
+``` ruby
+p DiffMatcher::difference(1..3, 3)
+# => nil
+```
+
When `actual` is passed to an `expected` proc and it returns true
``` ruby
is_boolean = lambda { |x| [FalseClass, TrueClass].include? x.class }
p DiffMatcher::difference(is_boolean, true)
@@ -215,11 +222,11 @@
additional => "+ "
match value =>
match regexp => "~ "
match class => ": "
match matcher => "| "
- match proc => ". "
+ match range => ". "
match proc => "{ "
#### Colours
@@ -256,10 +263,11 @@
* <http://github.com/Blargel/easy_diff> (Recursive diff, merge, and unmerge for hashes and arrays)
### JSON matchers
* <http://github.com/collectiveidea/json_spec> (Easily handle JSON in RSpec and Cucumber)
* <http://github.com/lloyd/JSONSelect> (CSS-like selectors for JSON)
+ * <http://github.com/chancancode/json_expressions> (JSON matchmaking for all your API testing needs)
Why another differ?
---
@@ -274,9 +282,18 @@
DiffMatcher can match using not only regexes but classes and procs.
And the difference string that it outputs can be formatted in several ways as needed.
As for matching JSON, the matchers above work well, but don't allow for matching patterns.
+
+#### Update 2012/07/14:
+
+[json_expressions](http://github.com/chancancode/json_expressions) (as mentioned in [Ruby5 - Episode #288](http://ruby5.envylabs.com/episodes/292-episode-288-july-13th-2012)) *does*
+do pattern matching and also looks like a good alternative to diff_matcher, it has the following advantages:
+ * define capture symbols that can be used to extract values from the matched object
+ * (if a symbol is used multiple times, it will make sure all the extracted values match)
+ * can optionally match unordered arrays (diff_matcher only matches ordered arrays)
+ * because it doesn't bother generating a pretty difference string it might be faster
Use with rspec
---
To use with rspec create the following custom matcher: