Module: Rspec::MatchRuby
- Defined in:
- lib/rspec/match_ruby/version.rb,
lib/rspec/match_ruby/match_ruby.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
Class Method Details
.expand_node(node) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/match_ruby/match_ruby.rb', line 14 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
9 10 11 |
# File 'lib/rspec/match_ruby/match_ruby.rb', line 9 def match(expected, actual) parse(expected) == parse(actual) end |
.parse(str) ⇒ Object
3 4 5 6 |
# File 'lib/rspec/match_ruby/match_ruby.rb', line 3 def parse(str) node = Parser::CurrentRuby.parse(str) (node) end |