rspec-match_ruby 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e85da27fa05787a7511cfef0bdf0974bbd63a0c9
4
- data.tar.gz: f4dc6f004185cd4f916d64e56836597754457051
3
+ metadata.gz: c71175c4228078fa1f94552e4acac39a34ef4e9a
4
+ data.tar.gz: 4ca968408159dc319c0f4ce0a07407e6d4cd0256
5
5
  SHA512:
6
- metadata.gz: c2003ad30b2b52fc6f7b5a9235195504534fb959327c69c21a5e7586a0e74038d9e87fb459f31f8442964cd8fef027d9f12b36098b6a1e673c1d9e5a6fb69d44
7
- data.tar.gz: f40b310d5a57b69c2b1bfa4ea36e60fdd2a8eb1d9a11e2c4b805174130ff9cd847bff5c577adce8d109b2a6e16416a2f6b3454ababf32a22e3c19df45410e37c
6
+ metadata.gz: c4f7e2ed72e373cdaf34a3c8130a5057ca6d7a6156788fddafb003e49ffb3ded6fefe1705bea15224409672864ecf11ae8568f73339a7f6f63f12e8bcaa99cf8
7
+ data.tar.gz: f517058073453b483053f61a50825678bb37d221e4393ab4cff4f035ce35267b88fe8e92f34925e38557b87539d5c43b4637f9dc0aa25388d8624ceb80c24086
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-match_ruby (0.1.0)
4
+ rspec-match_ruby (0.1.1)
5
5
  parser
6
6
  rspec (~> 3)
7
7
 
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  It is Ruby code matcher.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/rspec-match_ruby.svg)](https://badge.fury.io/rb/rspec-match_ruby)
5
6
  [![Build Status](https://travis-ci.org/winebarrel/rspec-match_ruby.svg?branch=master)](https://travis-ci.org/winebarrel/rspec-match_ruby)
6
7
 
7
8
  ## Installation
@@ -1,8 +1,7 @@
1
1
  require 'parser/current'
2
2
  require 'rspec'
3
3
 
4
- require 'rspec/match_ruby/version'
5
- require 'rspec/match_ruby/match_ruby'
4
+ require 'rspec/rspec_match_ruby'
6
5
 
7
6
  RSpec::Matchers.define :match_ruby do |expected|
8
7
  unless expected.is_a?(String)
@@ -14,7 +13,7 @@ RSpec::Matchers.define :match_ruby do |expected|
14
13
  raise TypeError, "wrong actual type #{expected.class} (expected String)"
15
14
  end
16
15
 
17
- Rspec::MatchRuby.match(expected, actual)
16
+ RSpecMatchRuby.match(expected, actual)
18
17
  end
19
18
 
20
19
  failure_message do |actual|
@@ -25,8 +24,8 @@ RSpec::Matchers.define :match_ruby do |expected|
25
24
  actual_normalized = normalize.call(actual)
26
25
  expected_normalized = normalize.call(expected)
27
26
 
28
- actual_ast = Rspec::MatchRuby.parse(actual)
29
- expected_ast = Rspec::MatchRuby.parse(expected)
27
+ actual_ast = RSpecMatchRuby.parse(actual)
28
+ expected_ast = RSpecMatchRuby.parse(expected)
30
29
 
31
30
  message = <<-EOS.strip
32
31
  expected: #{expected_normalized.inspect}
@@ -0,0 +1,31 @@
1
+ module RSpecMatchRuby
2
+ def parse(str)
3
+ node = Parser::CurrentRuby.parse(str)
4
+ expand_node(node)
5
+ end
6
+ module_function :parse
7
+
8
+ def match(expected, actual)
9
+ parse(expected) == parse(actual)
10
+ end
11
+ module_function :match
12
+
13
+ def expand_node(node)
14
+ children = node.children
15
+
16
+ if node.type == :hash
17
+ children = node.children.sort_by(&:to_s)
18
+ end
19
+
20
+ children = children.map do |child|
21
+ if child.is_a?(Parser::AST::Node)
22
+ expand_node(child)
23
+ else
24
+ child
25
+ end
26
+ end
27
+
28
+ [node.type, *children]
29
+ end
30
+ module_function :expand_node
31
+ end
@@ -1,11 +1,10 @@
1
1
 
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rspec/match_ruby/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = 'rspec-match_ruby'
8
- spec.version = Rspec::MatchRuby::VERSION
7
+ spec.version = '0.1.1'
9
8
  spec.authors = ['winebarrel']
10
9
  spec.email = ['sugawara@winebarrel.jp']
11
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-match_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
@@ -83,8 +83,7 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/rspec/match_ruby.rb
86
- - lib/rspec/match_ruby/match_ruby.rb
87
- - lib/rspec/match_ruby/version.rb
86
+ - lib/rspec/rspec_match_ruby.rb
88
87
  - rspec-match_ruby.gemspec
89
88
  - tes.rb
90
89
  homepage: https://github.com/winebarrel/rspec-match_ruby
@@ -1,33 +0,0 @@
1
- module Rspec
2
- module MatchRuby
3
- def parse(str)
4
- node = Parser::CurrentRuby.parse(str)
5
- expand_node(node)
6
- end
7
- module_function :parse
8
-
9
- def match(expected, actual)
10
- parse(expected) == parse(actual)
11
- end
12
- module_function :match
13
-
14
- def expand_node(node)
15
- children = node.children
16
-
17
- if node.type == :hash
18
- children = node.children.sort_by(&:to_s)
19
- end
20
-
21
- children = children.map do |child|
22
- if child.is_a?(Parser::AST::Node)
23
- expand_node(child)
24
- else
25
- child
26
- end
27
- end
28
-
29
- [node.type, *children]
30
- end
31
- module_function :expand_node
32
- end
33
- end
@@ -1,5 +0,0 @@
1
- module Rspec
2
- module MatchRuby
3
- VERSION = '0.1.0'
4
- end
5
- end