Module: RSpecMatchRuby
- Defined in:
- lib/rspec/rspec_match_ruby.rb
Class Method Summary collapse
Class Method Details
.expand_node(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/rspec_match_ruby.rb', line 13 def (node) children = node.children if node.type == :hash children = node.children.sort_by(&:to_s) end children = children.map do |child| if child.is_a?(Parser::AST::Node) (child) else child end end [node.type, *children] end |
.match(expected, actual) ⇒ Object
8 9 10 |
# File 'lib/rspec/rspec_match_ruby.rb', line 8 def match(expected, actual) parse(expected) == parse(actual) end |
.parse(str) ⇒ Object
2 3 4 5 |
# File 'lib/rspec/rspec_match_ruby.rb', line 2 def parse(str) node = Parser::CurrentRuby.parse(str) (node) end |