starscope 1.5.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/unit/db_test.rb CHANGED
@@ -7,14 +7,14 @@ describe Starscope::DB do
7
7
  end
8
8
 
9
9
  it 'must raise on invalid tables' do
10
- proc { @db.records(:foo) }.must_raise Starscope::DB::NoTableError
10
+ _(proc { @db.records(:foo) }).must_raise Starscope::DB::NoTableError
11
11
  end
12
12
 
13
13
  it 'must add paths' do
14
14
  paths = [GOLANG_SAMPLE, "#{FIXTURES}/**/*"]
15
15
  @db.add_paths(paths)
16
16
 
17
- @db.metadata(:paths).must_equal paths
17
+ _(@db.metadata(:paths)).must_equal paths
18
18
  validate(@db)
19
19
  end
20
20
 
@@ -24,10 +24,10 @@ describe Starscope::DB do
24
24
  @db.add_excludes(["#{FIXTURES}/**"])
25
25
 
26
26
  files = @db.metadata(:files).keys
27
- files.wont_include RUBY_SAMPLE
28
- files.wont_include GOLANG_SAMPLE
29
- @db.records(:defs).must_be_empty
30
- @db.records(:end).must_be_empty
27
+ _(files).wont_include RUBY_SAMPLE
28
+ _(files).wont_include GOLANG_SAMPLE
29
+ _(@db.records(:defs)).must_be_empty
30
+ _(@db.records(:end)).must_be_empty
31
31
  end
32
32
 
33
33
  it 'must pick up new files in old paths' do
@@ -40,23 +40,23 @@ describe Starscope::DB do
40
40
  it 'must remove old files in existing paths' do
41
41
  @db.load("#{FIXTURES}/db_removed_files.json")
42
42
  @db.update
43
- @db.metadata(:files).keys.wont_include "#{FIXTURES}/foo"
43
+ _(@db.metadata(:files).keys).wont_include "#{FIXTURES}/foo"
44
44
  end
45
45
 
46
46
  it "must update stale existing files when extractor hasn't changed" do
47
47
  @db.load("#{FIXTURES}/db_out_of_date.json")
48
- @db.metadata(:langs)[:Golang].must_be :>=, Starscope::DB::LANGS[:Golang]
48
+ _(@db.metadata(:langs)[:Golang]).must_be :>=, Starscope::DB::LANGS[:Golang]
49
49
 
50
50
  cur_mtime = @db.metadata(:files)[GOLANG_SAMPLE][:last_updated]
51
51
  File.expects(:mtime).twice.returns(cur_mtime + 1)
52
52
  @db.update
53
53
 
54
54
  file = @db.metadata(:files)[GOLANG_SAMPLE]
55
- file[:last_updated].must_equal cur_mtime + 1
56
- file[:lang].must_equal :Golang
57
- file[:lines].wont_be_empty
58
- @db.records(:defs).wont_be_empty
59
- @db.records(:calls).wont_be_empty
55
+ _(file[:last_updated]).must_equal cur_mtime + 1
56
+ _(file[:lang]).must_equal :Golang
57
+ _(file[:lines]).wont_be_empty
58
+ _(@db.records(:defs)).wont_be_empty
59
+ _(@db.records(:calls)).wont_be_empty
60
60
  end
61
61
 
62
62
  it 'must update unchanged existing files with old extractor versions' do
@@ -67,11 +67,11 @@ describe Starscope::DB do
67
67
  @db.update
68
68
 
69
69
  file = @db.metadata(:files)[GOLANG_SAMPLE]
70
- file[:last_updated].must_equal cur_mtime
71
- file[:lang].must_equal :Golang
72
- file[:lines].wont_be_empty
73
- @db.records(:defs).wont_be_empty
74
- @db.records(:calls).wont_be_empty
70
+ _(file[:last_updated]).must_equal cur_mtime
71
+ _(file[:lang]).must_equal :Golang
72
+ _(file[:lines]).wont_be_empty
73
+ _(@db.records(:defs)).wont_be_empty
74
+ _(@db.records(:calls)).wont_be_empty
75
75
  end
76
76
 
77
77
  it 'must update unchanged existing files with old sublang extractor versions' do
@@ -82,12 +82,12 @@ describe Starscope::DB do
82
82
  @db.update
83
83
 
84
84
  file = @db.metadata(:files)[GOLANG_SAMPLE]
85
- file[:last_updated].must_equal cur_mtime
86
- file[:lang].must_equal :Golang
87
- file[:sublangs].must_be_empty
88
- file[:lines].wont_be_empty
89
- @db.records(:defs).wont_be_empty
90
- @db.records(:calls).wont_be_empty
85
+ _(file[:last_updated]).must_equal cur_mtime
86
+ _(file[:lang]).must_equal :Golang
87
+ _(file[:sublangs]).must_be_empty
88
+ _(file[:lines]).wont_be_empty
89
+ _(@db.records(:defs)).wont_be_empty
90
+ _(@db.records(:calls)).wont_be_empty
91
91
  end
92
92
 
93
93
  it 'must update unchanged existing files when the extractor has been removed' do
@@ -98,11 +98,11 @@ describe Starscope::DB do
98
98
  @db.update
99
99
 
100
100
  file = @db.metadata(:files)[GOLANG_SAMPLE]
101
- file[:last_updated].must_equal cur_mtime
102
- file[:lang].must_equal :Golang
103
- file[:lines].wont_be_empty
104
- @db.records(:defs).wont_be_empty
105
- @db.records(:calls).wont_be_empty
101
+ _(file[:last_updated]).must_equal cur_mtime
102
+ _(file[:lang]).must_equal :Golang
103
+ _(file[:lines]).wont_be_empty
104
+ _(@db.records(:defs)).wont_be_empty
105
+ _(@db.records(:calls)).wont_be_empty
106
106
  end
107
107
 
108
108
  it 'must not update file with up-to-date time and extractor' do
@@ -110,13 +110,13 @@ describe Starscope::DB do
110
110
  @db.update
111
111
 
112
112
  file = @db.metadata(:files)[GOLANG_SAMPLE]
113
- file[:last_updated].must_equal 10_000_000_000
114
- @db.tables.must_be_empty
113
+ _(file[:last_updated]).must_equal 10_000_000_000
114
+ _(@db.tables).must_be_empty
115
115
  end
116
116
 
117
117
  it 'must load an old DB file' do
118
118
  @db.load("#{FIXTURES}/db_old.json.gz")
119
- @db.metadata(:paths).must_equal ["#{FIXTURES}/**/*"]
119
+ _(@db.metadata(:paths)).must_equal ["#{FIXTURES}/**/*"]
120
120
  validate(@db)
121
121
  end
122
122
 
@@ -136,26 +136,26 @@ describe Starscope::DB do
136
136
 
137
137
  it 'must run queries' do
138
138
  @db.add_paths([FIXTURES])
139
- @db.query(:calls, 'abc').must_equal []
140
- @db.query(:defs, 'xyz').must_equal []
141
- @db.query(:calls, 'add_file').length.must_equal 3
139
+ _(@db.query(:calls, 'abc')).must_equal []
140
+ _(@db.query(:defs, 'xyz')).must_equal []
141
+ _(@db.query(:calls, 'add_file').length).must_equal 3
142
142
  end
143
143
 
144
144
  it 'must run queries on multiple tables' do
145
145
  @db.add_paths([FIXTURES])
146
- ret = @db.query([:calls, :defs], 'foo')
147
- ret.length.must_equal 4
148
- ret.first[:name].last.must_equal :foo
146
+ ret = @db.query(%i[calls defs], 'foo')
147
+ _(ret.length).must_equal 4
148
+ _(ret.first[:name].last).must_equal :foo
149
149
  end
150
150
 
151
151
  it 'must symbolize compound name' do
152
152
  rec = Starscope::DB.normalize_record(:foo, ['a', :b], {})
153
- rec[:name].must_equal [:a, :b]
153
+ _(rec[:name]).must_equal %i[a b]
154
154
  end
155
155
 
156
156
  it 'must symbolize and array-wrap simple name' do
157
157
  rec = Starscope::DB.normalize_record(:foo, 'a', {})
158
- rec[:name].must_equal [:a]
158
+ _(rec[:name]).must_equal [:a]
159
159
  end
160
160
 
161
161
  it 'must store extractor metadata returned from the `extract` call' do
@@ -167,21 +167,21 @@ describe Starscope::DB do
167
167
 
168
168
  @db.add_paths([GOLANG_SAMPLE])
169
169
 
170
- @db.metadata(:files)[GOLANG_SAMPLE][:a].must_equal 1
170
+ _(@db.metadata(:files)[GOLANG_SAMPLE][:a]).must_equal 1
171
171
  end
172
172
 
173
173
  private
174
174
 
175
175
  def validate(db)
176
176
  files = db.metadata(:files)
177
- files.keys.must_include GOLANG_SAMPLE
178
- files.keys.must_include RUBY_SAMPLE
179
- files[GOLANG_SAMPLE][:last_updated].must_equal File.mtime(GOLANG_SAMPLE).to_i
180
- files[RUBY_SAMPLE][:last_updated].must_equal File.mtime(RUBY_SAMPLE).to_i
181
-
182
- db.records(:defs).wont_be_empty
183
- db.records(:calls).wont_be_empty
184
- db.records(:imports).wont_be_empty
185
- db.records(:requires).wont_be_empty
177
+ _(files.keys).must_include GOLANG_SAMPLE
178
+ _(files.keys).must_include RUBY_SAMPLE
179
+ _(files[GOLANG_SAMPLE][:last_updated]).must_equal File.mtime(GOLANG_SAMPLE).to_i
180
+ _(files[RUBY_SAMPLE][:last_updated]).must_equal File.mtime(RUBY_SAMPLE).to_i
181
+
182
+ _(db.records(:defs)).wont_be_empty
183
+ _(db.records(:calls)).wont_be_empty
184
+ _(db.records(:imports)).wont_be_empty
185
+ _(db.records(:requires)).wont_be_empty
186
186
  end
187
187
  end
@@ -11,7 +11,7 @@ describe Starscope::Exportable do
11
11
  @db.export_to(:ctags, @buf, '.')
12
12
  @buf.rewind
13
13
  lines = @buf.each_line.to_a
14
- lines.must_include(
14
+ _(lines).must_include(
15
15
  "NoTableError\t" \
16
16
  "./#{FIXTURES}/sample_ruby.rb\t" \
17
17
  "/^ class NoTableError < StandardError; end$/;\"\t" \
@@ -24,7 +24,7 @@ describe Starscope::Exportable do
24
24
  @db.export_to(:ctags, @buf, '../foo')
25
25
  @buf.rewind
26
26
  lines = @buf.each_line.to_a
27
- lines.must_include(
27
+ _(lines).must_include(
28
28
  "NoTableError\t" \
29
29
  "../foo/#{FIXTURES}/sample_ruby.rb\t" \
30
30
  "/^ class NoTableError < StandardError; end$/;\"\t" \
@@ -38,14 +38,16 @@ describe Starscope::Exportable do
38
38
  @buf.rewind
39
39
  lines = @buf.each_line.to_a
40
40
 
41
- lines.must_include "\t@#{FIXTURES}/sample_golang.go\n"
42
- lines.must_include "\tgSunday\n"
43
- lines.must_include "\t`add_file\n"
44
- lines.must_include "\t}}\n"
45
- lines.must_include "13 class \n"
41
+ _(lines).must_include "\t@#{FIXTURES}/sample_golang.go\n"
42
+ _(lines).must_include "\tgSunday\n"
43
+ _(lines).must_include "\t`add_file\n"
44
+ _(lines).must_include "\t}}\n"
45
+ _(lines).must_include "13 class \n"
46
+ _(lines).must_include "\tgsingle_var_unicode\n"
46
47
 
47
- lines.wont_include "= [\n"
48
- lines.wont_include "4 LANGS = [\n"
49
- lines.wont_include "116 tmpdb[entry[:file]][entry[:line_no]] ||= []\n"
48
+ _(lines).wont_include "\tgsingle_var_Äunicode\n"
49
+ _(lines).wont_include "= [\n"
50
+ _(lines).wont_include "4 LANGS = [\n"
51
+ _(lines).wont_include "116 tmpdb[entry[:file]][entry[:line_no]] ||= []\n"
50
52
  end
51
53
  end
@@ -1,13 +1,13 @@
1
1
  require_relative '../test_helper'
2
2
 
3
- describe Starscope::FragmentExtractor do
4
- module Starscope
5
- module Lang
6
- module Dummy
7
- end
3
+ module Starscope
4
+ module Lang
5
+ module Dummy
8
6
  end
9
7
  end
8
+ end
10
9
 
10
+ describe Starscope::FragmentExtractor do
11
11
  before do
12
12
  @extractor = Starscope::FragmentExtractor.new(
13
13
  :Dummy,
@@ -15,7 +15,8 @@ describe Starscope::FragmentExtractor do
15
15
  { frag: "def foo; end\n", line_no: 12 },
16
16
  { frag: "def bar\n", line_no: 15 },
17
17
  { frag: "end\n", line_no: 29 }
18
- ])
18
+ ]
19
+ )
19
20
  @reconstructed = "def foo; end\ndef bar\nend"
20
21
  end
21
22
 
@@ -26,20 +27,20 @@ describe Starscope::FragmentExtractor do
26
27
 
27
28
  it 'must pass along extractor metadata from the child' do
28
29
  ::Starscope::Lang::Dummy.expects(:extract).returns a: 1, b: 3
29
- @extractor.extract(:foo, '---').must_equal a: 1, b: 3
30
+ _(@extractor.extract(:foo, '---')).must_equal a: 1, b: 3
30
31
  end
31
32
 
32
33
  it 'must pass along the name from the child' do
33
- @extractor.name.must_equal ::Starscope::Lang::Dummy.name
34
+ _(@extractor.name).must_equal ::Starscope::Lang::Dummy.name
34
35
  end
35
36
 
36
37
  it 'must override-merge yielded args based on line number' do
37
38
  ::Starscope::Lang::Dummy.expects(:extract).yields(:foo, :bar, line_no: 2, foo: :bar)
38
39
 
39
40
  @extractor.extract(:foo, '---') do |tbl, name, args|
40
- tbl.must_equal :foo
41
- name.must_equal :bar
42
- args.must_equal line_no: 15, foo: :bar
41
+ _(tbl).must_equal :foo
42
+ _(name).must_equal :bar
43
+ _(args).must_equal line_no: 15, foo: :bar
43
44
  end
44
45
  end
45
46
  end
@@ -4,33 +4,33 @@ describe Starscope::Lang::ERB do
4
4
  before do
5
5
  @frags = []
6
6
  Starscope::Lang::ERB.extract(ERB_SAMPLE, File.read(ERB_SAMPLE)) do |tbl, name, args|
7
- tbl.must_equal Starscope::DB::FRAGMENT
8
- name.must_equal :Ruby
7
+ _(tbl).must_equal Starscope::DB::FRAGMENT
8
+ _(name).must_equal :Ruby
9
9
  @frags << args
10
10
  end
11
11
  end
12
12
 
13
13
  it 'must match erb files' do
14
- Starscope::Lang::ERB.match_file(ERB_SAMPLE).must_equal true
14
+ _(Starscope::Lang::ERB.match_file(ERB_SAMPLE)).must_equal true
15
15
  end
16
16
 
17
17
  it 'must not match non-erb files' do
18
- Starscope::Lang::ERB.match_file(GOLANG_SAMPLE).must_equal false
19
- Starscope::Lang::ERB.match_file(EMPTY_FILE).must_equal false
18
+ _(Starscope::Lang::ERB.match_file(GOLANG_SAMPLE)).must_equal false
19
+ _(Starscope::Lang::ERB.match_file(EMPTY_FILE)).must_equal false
20
20
  end
21
21
 
22
22
  it 'must identify all fragments' do
23
- @frags.must_equal [{ frag: ' if foo ', line_no: 1 },
24
- { frag: ' elsif bar ', line_no: 3 },
25
- { frag: ' end ', line_no: 5 },
26
- { frag: ' case x', line_no: 8 },
27
- { frag: 'when :bar ', line_no: 9 },
28
- { frag: ' magic ', line_no: 9 },
29
- { frag: ' when :baz', line_no: 9 },
30
- { frag: 'when :foo ', line_no: 10 },
31
- { frag: ' end ', line_no: 12 },
32
- { frag: ' foo ', line_no: 14 },
33
- { frag: ' bar ', line_no: 14 },
34
- { frag: ' baz ', line_no: 14 }]
23
+ _(@frags).must_equal [{ frag: ' if foo ', line_no: 1 },
24
+ { frag: ' elsif bar ', line_no: 3 },
25
+ { frag: ' end ', line_no: 5 },
26
+ { frag: ' case x', line_no: 8 },
27
+ { frag: 'when :bar ', line_no: 9 },
28
+ { frag: ' magic ', line_no: 9 },
29
+ { frag: ' when :baz', line_no: 9 },
30
+ { frag: 'when :foo ', line_no: 10 },
31
+ { frag: ' end ', line_no: 12 },
32
+ { frag: ' foo ', line_no: 14 },
33
+ { frag: ' bar ', line_no: 14 },
34
+ { frag: ' baz ', line_no: 14 }]
35
35
  end
36
36
  end
@@ -10,89 +10,89 @@ describe Starscope::Lang::Golang do
10
10
  end
11
11
 
12
12
  it 'must match golang files' do
13
- Starscope::Lang::Golang.match_file(GOLANG_SAMPLE).must_equal true
13
+ _(Starscope::Lang::Golang.match_file(GOLANG_SAMPLE)).must_equal true
14
14
  end
15
15
 
16
16
  it 'must not match non-golang files' do
17
- Starscope::Lang::Golang.match_file(RUBY_SAMPLE).must_equal false
18
- Starscope::Lang::Golang.match_file(EMPTY_FILE).must_equal false
17
+ _(Starscope::Lang::Golang.match_file(RUBY_SAMPLE)).must_equal false
18
+ _(Starscope::Lang::Golang.match_file(EMPTY_FILE)).must_equal false
19
19
  end
20
20
 
21
21
  it 'must identify definitions' do
22
- @db.keys.must_include :defs
22
+ _(@db.keys).must_include :defs
23
23
  defs = @db[:defs].map { |x| x[:name][-1] }
24
24
 
25
- defs.must_include :a
26
- defs.must_include :b
27
- defs.must_include :c
28
- defs.must_include :ttt
29
- defs.must_include :main
30
- defs.must_include :v1
31
- defs.must_include :v2
32
- defs.must_include :Sunday
33
- defs.must_include :Monday
34
- defs.must_include :single_var
35
- defs.must_include :single_const
36
-
37
- defs.wont_include :"0x00"
38
- defs.wont_include :"0x01"
39
- defs.wont_include :"0x02"
40
- defs.wont_include :"0x03"
25
+ _(defs).must_include :a
26
+ _(defs).must_include :b
27
+ _(defs).must_include :c
28
+ _(defs).must_include :ttt
29
+ _(defs).must_include :main
30
+ _(defs).must_include :v1
31
+ _(defs).must_include :v2
32
+ _(defs).must_include :Sunday
33
+ _(defs).must_include :Monday
34
+ _(defs).must_include :single_var_Äunicode
35
+ _(defs).must_include :single_const
36
+
37
+ _(defs).wont_include :'0x00'
38
+ _(defs).wont_include :'0x01'
39
+ _(defs).wont_include :'0x02'
40
+ _(defs).wont_include :'0x03'
41
41
  end
42
42
 
43
43
  it 'must identify endings' do
44
- @db.keys.must_include :end
45
- @db[:end].count.must_equal 7
44
+ _(@db.keys).must_include :end
45
+ _(@db[:end].count).must_equal 7
46
46
  end
47
47
 
48
48
  it 'must identify function calls' do
49
- @db.keys.must_include :calls
49
+ _(@db.keys).must_include :calls
50
50
  calls = @db[:calls].group_by { |x| x[:name][-1] }
51
51
 
52
- calls.keys.must_include :a
53
- calls.keys.must_include :b
54
- calls.keys.must_include :c
55
- calls.keys.must_include :ttt
56
- calls.keys.must_include :Errorf
57
-
58
- calls[:a].count.must_equal 3
59
- calls[:b].count.must_equal 4
60
- calls[:c].count.must_equal 4
61
- calls[:ttt].count.must_equal 2
62
- calls[:Errorf].count.must_equal 1
52
+ _(calls.keys).must_include :a
53
+ _(calls.keys).must_include :b
54
+ _(calls.keys).must_include :c
55
+ _(calls.keys).must_include :ttt
56
+ _(calls.keys).must_include :Errorf
57
+
58
+ _(calls[:a].count).must_equal 3
59
+ _(calls[:b].count).must_equal 4
60
+ _(calls[:c].count).must_equal 4
61
+ _(calls[:ttt].count).must_equal 2
62
+ _(calls[:Errorf].count).must_equal 1
63
63
  end
64
64
 
65
65
  it 'must identify variable assignments' do
66
- @db.keys.must_include :assigns
66
+ _(@db.keys).must_include :assigns
67
67
  assigns = @db[:assigns].group_by { |x| x[:name][-1] }
68
68
 
69
- assigns.keys.must_include :x
70
- assigns.keys.must_include :y
71
- assigns.keys.must_include :z
72
- assigns.keys.must_include :n
73
- assigns.keys.must_include :m
74
- assigns.keys.must_include :msg
75
-
76
- assigns[:x].count.must_equal 2
77
- assigns[:y].count.must_equal 1
78
- assigns[:z].count.must_equal 1
79
- assigns[:n].count.must_equal 1
80
- assigns[:m].count.must_equal 2
69
+ _(assigns.keys).must_include :x
70
+ _(assigns.keys).must_include :y
71
+ _(assigns.keys).must_include :z
72
+ _(assigns.keys).must_include :n
73
+ _(assigns.keys).must_include :m
74
+ _(assigns.keys).must_include :msg
75
+
76
+ _(assigns[:x].count).must_equal 2
77
+ _(assigns[:y].count).must_equal 1
78
+ _(assigns[:z].count).must_equal 1
79
+ _(assigns[:n].count).must_equal 1
80
+ _(assigns[:m].count).must_equal 2
81
81
  end
82
82
 
83
83
  it 'must identify imports' do
84
- @db.keys.must_include :imports
84
+ _(@db.keys).must_include :imports
85
85
  imports = @db[:imports].group_by { |x| x[:name][-1] }
86
86
 
87
- imports.keys.must_include :fmt
87
+ _(imports.keys).must_include :fmt
88
88
  end
89
89
 
90
90
  it 'must correctly find the end of string constants' do
91
- Starscope::Lang::Golang.find_end_of_string('"123"foo', 0).must_equal 4
92
- Starscope::Lang::Golang.find_end_of_string('a"123"foo', 0).must_equal 1
93
- Starscope::Lang::Golang.find_end_of_string('a"123"foo', 1).must_equal 5
94
- Starscope::Lang::Golang.find_end_of_string('"1\""foo', 0).must_equal 4
95
- Starscope::Lang::Golang.find_end_of_string('"1\\""foo', 0).must_equal 4
96
- Starscope::Lang::Golang.find_end_of_string('"1\\\\\"foo', 0).must_equal 9
91
+ _(Starscope::Lang::Golang.find_end_of_string('"123"foo', 0)).must_equal 4
92
+ _(Starscope::Lang::Golang.find_end_of_string('a"123"foo', 0)).must_equal 1
93
+ _(Starscope::Lang::Golang.find_end_of_string('a"123"foo', 1)).must_equal 5
94
+ _(Starscope::Lang::Golang.find_end_of_string('"1\""foo', 0)).must_equal 4
95
+ _(Starscope::Lang::Golang.find_end_of_string('"1\\""foo', 0)).must_equal 4
96
+ _(Starscope::Lang::Golang.find_end_of_string('"1\\\\\"foo', 0)).must_equal 9
97
97
  end
98
98
  end
@@ -10,78 +10,78 @@ describe Starscope::Lang::Javascript do
10
10
  end
11
11
 
12
12
  it 'must match js files' do
13
- Starscope::Lang::Javascript.match_file(JAVASCRIPT_EXAMPLE).must_equal true
13
+ _(Starscope::Lang::Javascript.match_file(JAVASCRIPT_EXAMPLE)).must_equal true
14
14
  end
15
15
 
16
16
  it 'must not match non-js files' do
17
- Starscope::Lang::Javascript.match_file(RUBY_SAMPLE).must_equal false
18
- Starscope::Lang::Javascript.match_file(EMPTY_FILE).must_equal false
17
+ _(Starscope::Lang::Javascript.match_file(RUBY_SAMPLE)).must_equal false
18
+ _(Starscope::Lang::Javascript.match_file(EMPTY_FILE)).must_equal false
19
19
  end
20
20
 
21
21
  it 'must identify definitions' do
22
- @db.keys.must_include :defs
22
+ _(@db.keys).must_include :defs
23
23
  defs = @db[:defs].map { |x| x[:name][-1] }
24
24
 
25
- defs.must_include :Component
26
- defs.must_include :StyleSheet
27
- defs.must_include :styles
28
- defs.must_include :NavigatorRouteMapper
29
- defs.must_include :LeftButton
30
- defs.must_include :RightButton
31
- defs.must_include :_tabItem
32
- defs.must_include :render
33
- defs.must_include :setRef
34
- defs.must_include :route
35
- defs.must_include :foo
36
- defs.must_include :MyStat
37
- defs.must_include :myStatFunc
38
- defs.must_include :bracelessMethod
25
+ _(defs).must_include :Component
26
+ _(defs).must_include :StyleSheet
27
+ _(defs).must_include :styles
28
+ _(defs).must_include :NavigatorRouteMapper
29
+ _(defs).must_include :LeftButton
30
+ _(defs).must_include :RightButton
31
+ _(defs).must_include :_tabItem
32
+ _(defs).must_include :render
33
+ _(defs).must_include :setRef
34
+ _(defs).must_include :route
35
+ _(defs).must_include :foo
36
+ _(defs).must_include :MyStat
37
+ _(defs).must_include :myStatFunc
38
+ _(defs).must_include :bracelessMethod
39
39
 
40
- defs.wont_include :setStyle
41
- defs.wont_include :setState
42
- defs.wont_include :fontFamily
43
- defs.wont_include :navigator
44
- defs.wont_include :madness
45
- defs.wont_include :React
40
+ _(defs).wont_include :setStyle
41
+ _(defs).wont_include :setState
42
+ _(defs).wont_include :fontFamily
43
+ _(defs).wont_include :navigator
44
+ _(defs).wont_include :madness
45
+ _(defs).wont_include :React
46
46
  end
47
47
 
48
48
  it 'must only tag static classes once' do
49
- @db[:defs].count { |x| x[:name][-1] == :MyStat }.must_equal 1
49
+ _(@db[:defs].count { |x| x[:name][-1] == :MyStat }).must_equal 1
50
50
  end
51
51
 
52
52
  it 'must identify endings' do
53
- @db.keys.must_include :end
54
- @db[:end].count.must_equal 12
53
+ _(@db.keys).must_include :end
54
+ _(@db[:end].count).must_equal 12
55
55
 
56
56
  # bracelessMethod doesn't have a taggable end token so
57
57
  # we have to do a little dancing with an empty name and a precise column
58
- @db[:end][0][:name].must_equal [:'']
59
- @db[:end][0][:col].must_equal 27
58
+ _(@db[:end][0][:name]).must_equal [:'']
59
+ _(@db[:end][0][:col]).must_equal 27
60
60
  end
61
61
 
62
62
  it 'must identify function calls' do
63
- @db.keys.must_include :calls
63
+ _(@db.keys).must_include :calls
64
64
  calls = @db[:calls].group_by { |x| x[:name][-1] }
65
65
 
66
- calls.keys.must_include :create
67
- calls.keys.must_include :setStyle
68
- calls.keys.must_include :pop
69
- calls.keys.must_include :fetchData
70
- calls.keys.must_include :setState
71
- calls.keys.must_include :func1
66
+ _(calls.keys).must_include :create
67
+ _(calls.keys).must_include :setStyle
68
+ _(calls.keys).must_include :pop
69
+ _(calls.keys).must_include :fetchData
70
+ _(calls.keys).must_include :setState
71
+ _(calls.keys).must_include :func1
72
72
 
73
- calls[:pop].count.must_equal 1
74
- calls[:_tabItem].count.must_equal 3
73
+ _(calls[:pop].count).must_equal 1
74
+ _(calls[:_tabItem].count).must_equal 3
75
75
  end
76
76
 
77
77
  it 'must identify module requires' do
78
- @db.keys.must_include :requires
78
+ _(@db.keys).must_include :requires
79
79
  requires = @db[:requires].group_by { |x| x[:name][-1] }
80
80
 
81
- requires.keys.must_include :'foo-bar'
82
- requires.keys.must_include :'react-native'
83
- requires.keys.wont_include :NOPE
84
- requires.keys.wont_include :true
85
- requires.keys.wont_include :false
81
+ _(requires.keys).must_include :'foo-bar'
82
+ _(requires.keys).must_include :'react-native'
83
+ _(requires.keys).wont_include :NOPE
84
+ _(requires.keys).wont_include true
85
+ _(requires.keys).wont_include false
86
86
  end
87
87
  end