rb_tags 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +103 -0
- data/Guardfile +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/bin/rb_tags +90 -0
- data/lib/rb_tags/concerns/completion.rb +24 -0
- data/lib/rb_tags/concerns/generate_tags.rb +30 -0
- data/lib/rb_tags/concerns/parser.rb +46 -0
- data/lib/rb_tags/concerns/sys_info.rb +21 -0
- data/lib/rb_tags/concerns/yaml_tasks.rb +18 -0
- data/lib/rb_tags/tags.rb +41 -0
- data/lib/rb_tags/version.rb +3 -0
- data/lib/rb_tags.rb +151 -0
- data/rb_tags.gemspec +35 -0
- data/spec/parser_helper.rb +22 -0
- data/spec/rb_tags/concerns/completion_spec.rb +8 -0
- data/spec/rb_tags/concerns/generate_tags_spec.rb +28 -0
- data/spec/rb_tags/concerns/parser_spec.rb +107 -0
- data/spec/rb_tags/concerns/sys_info_spec.rb +19 -0
- data/spec/rb_tags/concerns/yaml_tasks_spec.rb +20 -0
- data/spec/rb_tags/tags_spec.rb +90 -0
- data/spec/rb_tags_spec.rb +135 -0
- data/spec/spec_helper.rb +88 -0
- metadata +249 -0
data/rb_tags.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rb_tags/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rb_tags"
|
8
|
+
spec.version = RbTags::VERSION
|
9
|
+
spec.authors = ["LeFnord"]
|
10
|
+
spec.email = ["pscholz.le@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A wrapper around ctags.}
|
13
|
+
spec.description = %q{A wrapper around ctags, with search for tag and open file if found.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "guard-rspec"
|
24
|
+
spec.add_development_dependency "guard-bundler"
|
25
|
+
spec.add_development_dependency "rb-fsevent"
|
26
|
+
spec.add_development_dependency "terminal-notifier-guard"
|
27
|
+
spec.add_development_dependency "awesome_print"
|
28
|
+
|
29
|
+
spec.add_runtime_dependency "bundler"
|
30
|
+
spec.add_runtime_dependency "colorize"
|
31
|
+
spec.add_runtime_dependency "rake"
|
32
|
+
spec.add_runtime_dependency "parslet"
|
33
|
+
spec.add_runtime_dependency "parallel"
|
34
|
+
spec.add_runtime_dependency "gli"
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
def samples
|
2
|
+
[
|
3
|
+
"RbTags module 1 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/version.rb module RbTags",
|
4
|
+
"ctags_expression method 18 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/gem_tags.rb def ctags_expression",
|
5
|
+
"generate method 11 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/gem_tags.rb def generate",
|
6
|
+
"Parser class 1 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/parser.rb class Parser < Parslet::Parser",
|
7
|
+
"add_to_hash method 23 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/json.rb def add_to_hash(tag)",
|
8
|
+
"find_expressions method 2 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/generate_tags.rb def find_expressions(dir,mask)",
|
9
|
+
"generate method 12 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags.rb def generate(format: 'vim', gems: false)",
|
10
|
+
"initialize method 5 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/gem_tags.rb def initialize(filename: \".gem_tags\", mask: '*.rb', format: 'vim')",
|
11
|
+
"initialize method 6 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/tags.rb def initialize(dir: Dir.getwd, filename: \".tags\", mask: '*.rb', format: 'vim')",
|
12
|
+
"initialize method 11 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/json.rb def initialize(tags)",
|
13
|
+
"parse singleton method 3 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/json.rb def self.parse(tags)",
|
14
|
+
|
15
|
+
"* method 189 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/file_list.rb def *(other)",
|
16
|
+
"<< method 199 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/file_list.rb def <<(obj)",
|
17
|
+
"<=> method 7 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/late_time.rb def <=>(other)",
|
18
|
+
"application= method 12 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_module.rb def application=(app)",
|
19
|
+
"L_darwin64_struct_ret_by_value_p$stub label 542 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/ffi-1.9.8/ext/ffi_c/libffi/src/powerpc/darwin_closure.S L_darwin64_struct_ret_by_value_p$stub:",
|
20
|
+
"$retint label 103 /usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/ffi-1.9.8/ext/ffi_c/libffi/src/alpha/osf.S $retint:",
|
21
|
+
]
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
describe GenerateTags do
|
2
|
+
subject { described_class }
|
3
|
+
|
4
|
+
it { expect(subject.name).to eq 'GenerateTags' }
|
5
|
+
|
6
|
+
let(:valid) { ["RbTags module 1 /Users/le_fnord/sandbox/github/rb_tags/lib/rb_tags/version.rb module RbTags"] }
|
7
|
+
let(:invalid) { ["Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."] }
|
8
|
+
|
9
|
+
describe '#parse_expression_line' do
|
10
|
+
subject { Class.include described_class }
|
11
|
+
let(:tags) { subject.parse_expression_line(valid) }
|
12
|
+
let(:no_tags) { subject.parse_expression_line(invalid) }
|
13
|
+
|
14
|
+
describe 'valid example' do
|
15
|
+
it { expect {tags}.not_to raise_error }
|
16
|
+
it { expect(tags).to be_a Array }
|
17
|
+
it { expect(tags.first).to be_a Hash }
|
18
|
+
it { expect(tags.first).to include(:name, :type, :line, :path, :definition) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'invalid example' do
|
22
|
+
it { expect(no_tags).to be_a Array }
|
23
|
+
it { expect(no_tags.first).to be_a String }
|
24
|
+
it { expect(no_tags.first).to include('[RbTags] Error') }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
describe Parser do
|
2
|
+
it { expect(described_class).to eq(Parser) }
|
3
|
+
|
4
|
+
let(:parser) { described_class.new }
|
5
|
+
|
6
|
+
describe 'atoms' do
|
7
|
+
describe '#space' do
|
8
|
+
it { expect(parser.space).to parse(' ') }
|
9
|
+
it { expect(parser.space).to parse("\t") }
|
10
|
+
|
11
|
+
it { expect(parser.space).not_to parse(' ') }
|
12
|
+
it { expect(parser.space).not_to parse('') }
|
13
|
+
it { expect(parser.space).not_to parse('1') }
|
14
|
+
it { expect(parser.space).not_to parse('a') }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#spaces' do
|
18
|
+
it { expect(parser.spaces).to parse(' ') }
|
19
|
+
it { expect(parser.spaces).to parse("\t") }
|
20
|
+
it { expect(parser.spaces).to parse(' ') }
|
21
|
+
it { expect(parser.spaces).to parse(" \t") }
|
22
|
+
it { expect(parser.spaces).not_to parse('1') }
|
23
|
+
it { expect(parser.spaces).not_to parse('a') }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#word' do
|
27
|
+
it { expect(parser.word).to parse('tags') }
|
28
|
+
it { expect(parser.word).to parse('RbTags') }
|
29
|
+
it { expect(parser.word).to parse('rb_tags') }
|
30
|
+
|
31
|
+
it { expect(parser.word).not_to parse(' ') }
|
32
|
+
it { expect(parser.word).not_to parse("\t") }
|
33
|
+
it { expect(parser.word).not_to parse('rb_tags/foo') }
|
34
|
+
it { expect(parser.word).not_to parse('RbTags::Foo') }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#line' do
|
38
|
+
it { expect(parser.line).to parse('1') }
|
39
|
+
it { expect(parser.line).to parse('23') }
|
40
|
+
|
41
|
+
it { expect(parser.line).not_to parse(' ') }
|
42
|
+
it { expect(parser.line).not_to parse("\t") }
|
43
|
+
it { expect(parser.line).not_to parse("word") }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#separator' do
|
47
|
+
it { expect(parser.separator).to parse('/') }
|
48
|
+
|
49
|
+
it { expect(parser.separator).not_to parse('1') }
|
50
|
+
it { expect(parser.separator).not_to parse('23') }
|
51
|
+
it { expect(parser.separator).not_to parse(' ') }
|
52
|
+
it { expect(parser.separator).not_to parse("\t") }
|
53
|
+
it { expect(parser.separator).not_to parse("word") }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'composite' do
|
58
|
+
describe '#name' do
|
59
|
+
it { expect(parser.name).to parse('tags') }
|
60
|
+
it { expect(parser.name).to parse('RbTags') }
|
61
|
+
it { expect(parser.name).to parse('rb_tags') }
|
62
|
+
it { expect(parser.name).to parse('rb_tags_foo') }
|
63
|
+
it { expect(parser.name).to parse('rb-tags') }
|
64
|
+
it { expect(parser.name).to parse('rb-tags_foo') }
|
65
|
+
it { expect(parser.name).to parse('<<') }
|
66
|
+
it { expect(parser.name).to parse('$retint') }
|
67
|
+
it { expect(parser.name).to parse('L_darwin64_struct_ret_by_value_p$stub') }
|
68
|
+
|
69
|
+
it { expect(parser.name).not_to parse('RbTags::Foo') }
|
70
|
+
it { expect(parser.name).not_to parse('RbTags::Foo::Bar') }
|
71
|
+
it { expect(parser.name).not_to parse('rb_tags/foo') }
|
72
|
+
it { expect(parser.name).not_to parse('rb_tags.foo') }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#path' do
|
76
|
+
it { expect(parser.path).to parse('/tags.rb') }
|
77
|
+
it { expect(parser.path).to parse('/RbTags.rb') }
|
78
|
+
it { expect(parser.path).to parse('/rb_tags.rb') }
|
79
|
+
it { expect(parser.path).to parse('/rb_tags_foo.rb') }
|
80
|
+
|
81
|
+
it { expect(parser.path).to parse('/foo/tags.rb') }
|
82
|
+
it { expect(parser.path).to parse('/foo/RbTags.rb') }
|
83
|
+
it { expect(parser.path).to parse('/foo/rb_tags.rb') }
|
84
|
+
it { expect(parser.path).to parse('/foo/rb_tags_foo.rb') }
|
85
|
+
|
86
|
+
it { expect(parser.path).to parse('/bar/foo/tags.rb') }
|
87
|
+
it { expect(parser.path).to parse('/bar/foo/RbTags.rb') }
|
88
|
+
it { expect(parser.path).to parse('/bar/foo/rb_tags.rb') }
|
89
|
+
it { expect(parser.path).to parse('/bar/foo/rb_tags_foo.rb') }
|
90
|
+
|
91
|
+
it { expect(parser.path).to parse('/barFoo/bar/foo_bar-foo/tags.rb') }
|
92
|
+
it { expect(parser.path).to parse('/barFoo/bar/foo_bar-foo/RbTags.rb') }
|
93
|
+
it { expect(parser.path).to parse('/barFoo/bar/foo_bar-foo/rb_tags.rb') }
|
94
|
+
it { expect(parser.path).to parse('/barFoo/bar/foo_bar-foo/rb_tags_foo.rb') }
|
95
|
+
|
96
|
+
it { expect(parser.path).to parse('/usr/local/var/rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/file_list.rb') }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'whole line' do
|
101
|
+
samples.each do |line|
|
102
|
+
it { expect(parser).to parse(line) }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SysInfo do
|
4
|
+
subject { described_class }
|
5
|
+
|
6
|
+
it { expect(subject.name).to eq 'SysInfo' }
|
7
|
+
|
8
|
+
describe '#number_of_processors' do
|
9
|
+
let(:number) { subject.number_of_processors }
|
10
|
+
|
11
|
+
it 'does something' do
|
12
|
+
expect(subject).to receive(:number_of_processors).and_return(Fixnum)
|
13
|
+
subject.number_of_processors
|
14
|
+
end
|
15
|
+
|
16
|
+
it { expect(number).to be_a Fixnum }
|
17
|
+
it { expect(number).to be >= 2 }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe YamlTasks do
|
2
|
+
subject { described_class }
|
3
|
+
|
4
|
+
it { expect(subject.name).to eq 'YamlTasks' }
|
5
|
+
|
6
|
+
describe '#store' do
|
7
|
+
subject { Class.include described_class }
|
8
|
+
describe 'default dir' do
|
9
|
+
let(:store) { subject.send(:store) }
|
10
|
+
|
11
|
+
it { expect(store).to eq File.join(Dir.getwd,'.tags') }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'dir given' do
|
15
|
+
let(:store) { subject.send(:store, '/somewhere') }
|
16
|
+
|
17
|
+
it { expect(store).to eq File.join('/somewhere',".tags") }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
describe Tags do
|
2
|
+
before(:each) do
|
3
|
+
# tag_file = File.join(Dir.getwd,'.tags')
|
4
|
+
# FileUtils.rm(tag_file) if File.exist?(tag_file)
|
5
|
+
end
|
6
|
+
|
7
|
+
it { expect(described_class).to eq(Tags) }
|
8
|
+
|
9
|
+
subject { Tags.new }
|
10
|
+
|
11
|
+
it { expect(subject).to respond_to(:dir) }
|
12
|
+
it { expect(subject).to respond_to(:tags) }
|
13
|
+
it { expect(subject).to respond_to(:names) }
|
14
|
+
|
15
|
+
describe 'defaults' do
|
16
|
+
it { expect(subject.dir).to eq Dir.getwd }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'with params' do
|
20
|
+
subject { Tags.new('.')}
|
21
|
+
it { expect(subject.dir).to eq '.' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#tag' do
|
25
|
+
it { expect(subject).to respond_to(:tag) }
|
26
|
+
|
27
|
+
it 'tags default directory' do
|
28
|
+
subject.tag
|
29
|
+
expect(subject.tags.length).to be > 1
|
30
|
+
expect(subject.tags).to be_a Hash
|
31
|
+
expect(subject.tags.values.first.first).to include(:type, :line, :path, :definition)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'tags specified directory' do
|
35
|
+
subject = Tags.new(FileUtils.pwd)
|
36
|
+
subject.tag
|
37
|
+
expect(subject.tags.length).to be > 1
|
38
|
+
expect(subject.tags).to be_a Hash
|
39
|
+
expect(subject.tags.values.first.first).to include(:type, :line, :path, :definition)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#save' do
|
44
|
+
it { expect { subject.save }.not_to raise_error }
|
45
|
+
it 'do it' do
|
46
|
+
subject.save
|
47
|
+
foo = File.join(subject.dir, '.tags')
|
48
|
+
expect(File.exist?(foo)).to eq true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#read' do
|
53
|
+
it { expect { subject.read }.not_to raise_error }
|
54
|
+
it 'do it' do
|
55
|
+
subject.tag
|
56
|
+
subject.save
|
57
|
+
tag_file = File.join(subject.dir, '.tags')
|
58
|
+
expect(File.exist?(tag_file)).to eq true
|
59
|
+
object = Tags.new
|
60
|
+
object.read
|
61
|
+
expect(object.tags).to eq subject.tags
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#add' do
|
66
|
+
subject { Tags.new }
|
67
|
+
|
68
|
+
it 'has same length, if both are equal' do
|
69
|
+
subject.tag
|
70
|
+
tags_1 = subject.tags
|
71
|
+
expect { subject.add(tags_1) }.not_to raise_error
|
72
|
+
expect(subject.tags.length).to eq tags_1.length
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'has greater length, if not equal' do
|
76
|
+
dir = Bundler.load.specs.map(&:full_gem_path).last
|
77
|
+
compare = Tags.new(dir)
|
78
|
+
subject.tag
|
79
|
+
compare.tag
|
80
|
+
subject.add(compare.tags)
|
81
|
+
expect(subject.tags.length).to be > compare.tags.length
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#names' do
|
86
|
+
before { subject.tag }
|
87
|
+
it { expect(subject.names).to be_a Array }
|
88
|
+
it { expect(subject.names.first).to be_a String }
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
class Foo
|
2
|
+
include RbTags
|
3
|
+
end
|
4
|
+
|
5
|
+
describe RbTags do
|
6
|
+
it 'has a version number' do
|
7
|
+
expect(RbTags::VERSION).not_to be nil
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { Class.include RbTags }
|
11
|
+
|
12
|
+
it { expect(described_class).to eq(RbTags) }
|
13
|
+
it { expect(subject).to respond_to(:generate) }
|
14
|
+
it { expect(subject).to have_attributes(options: nil, gem_list: nil) }
|
15
|
+
|
16
|
+
context Foo do
|
17
|
+
let(:foo) { Foo.new }
|
18
|
+
|
19
|
+
describe '#generate' do
|
20
|
+
describe 'in work dir' do
|
21
|
+
it { expect { foo.generate }.to_not raise_error }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'in gems' do
|
25
|
+
it { expect { foo.generate(gems: true) }.to_not raise_error }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#say_tagging' do
|
30
|
+
let(:dir) { '/something' }
|
31
|
+
let(:message) { "tag gem: #{dir} first time\n"}
|
32
|
+
|
33
|
+
it 'does something' do
|
34
|
+
expect(foo).to receive(:say_tagging).with(dir).and_return(message)
|
35
|
+
foo.say_tagging(dir)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#tags' do
|
40
|
+
let(:tag_tags) { Tags.new(read: true).names}
|
41
|
+
|
42
|
+
it 'has tags' do
|
43
|
+
expect(foo.tags).to eq tag_tags
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#find' do
|
48
|
+
let(:tag) { Tags.new(read: true).tags}
|
49
|
+
let(:arg) { tag.first.first }
|
50
|
+
|
51
|
+
before do
|
52
|
+
foo.send(:get_existend_tags)
|
53
|
+
allow(foo).to receive(:complete).and_return(tag[arg])
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does something' do
|
57
|
+
expect(foo.found(arg)).to eq tag[arg]
|
58
|
+
foo.find
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#found' do
|
63
|
+
let(:tag) { Tags.new(read: true).tags.first}
|
64
|
+
let(:key) { tag.first }
|
65
|
+
|
66
|
+
it 'does something' do
|
67
|
+
foo.send(:get_existend_tags)
|
68
|
+
expect(foo.found(key)).to eq tag.last
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#open' do
|
73
|
+
describe 'what is valid' do
|
74
|
+
let(:what) { 0 }
|
75
|
+
|
76
|
+
it 'call open' do
|
77
|
+
expect(foo).to receive(:open).with(what)
|
78
|
+
foo.open(what)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'what is invalid' do
|
83
|
+
let(:what) { 'a' }
|
84
|
+
|
85
|
+
it { expect{ foo.open(what) }.to output.to_stdout }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'private methods' do
|
90
|
+
describe '#default_options' do
|
91
|
+
describe 'defaults' do
|
92
|
+
let(:tags) { foo.send(:default_options, {})}
|
93
|
+
let(:defaults) { foo.send(:defaults) }
|
94
|
+
let(:default) { {gems: false} }
|
95
|
+
|
96
|
+
it { expect { tags }.to_not raise_error }
|
97
|
+
it { expect(tags).to eq defaults }
|
98
|
+
it 'has defaults' do
|
99
|
+
defs = foo.send(:default_options, {})
|
100
|
+
expect(defs).to eq default
|
101
|
+
expect(foo.options).to eq default
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'set gems' do
|
106
|
+
let(:options) { {gems: true} }
|
107
|
+
let(:tag_w_options) { foo.send(:default_options, options)}
|
108
|
+
it { expect(tag_w_options).to eq options }
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'from gli' do
|
112
|
+
let(:income) { { "dir" => "..", :dir => "..", "save" => true, :save => true, "gems" => true, :read => false } }
|
113
|
+
let(:options) { foo.send(:default_options, income)}
|
114
|
+
let(:expected) { { :dir => "..", :save => true, :gems => true, :read => false } }
|
115
|
+
|
116
|
+
it { expect(options).to eq expected }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#gem_list' do
|
121
|
+
let(:bar) { foo.send(:build_gem_list) }
|
122
|
+
|
123
|
+
it { expect(bar).to be_a Array }
|
124
|
+
it { expect(bar).to_not include(foo.send(:default_dir))}
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#get_existend_tags' do
|
128
|
+
let(:tags) { foo.send(:get_existend_tags) }
|
129
|
+
|
130
|
+
it { expect(tags).to be_a Tags }
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter "/spec/"
|
4
|
+
end
|
5
|
+
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
require 'rspec/mocks'
|
9
|
+
require 'parslet/rig/rspec'
|
10
|
+
|
11
|
+
require 'parser_helper'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
14
|
+
require 'rb_tags'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# These two settings work together to allow you to limit a spec run
|
41
|
+
# to individual examples or groups you care about by tagging them with
|
42
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
43
|
+
# get run.
|
44
|
+
config.filter_run :focus
|
45
|
+
config.run_all_when_everything_filtered = true
|
46
|
+
|
47
|
+
# Run specs in random order to surface order dependencies. If you find an
|
48
|
+
# order dependency and want to debug it, you can fix the order by providing
|
49
|
+
# the seed, which is printed after each run.
|
50
|
+
# --seed 1234
|
51
|
+
config.order = :random
|
52
|
+
|
53
|
+
# The settings below are suggested to provide a good initial experience
|
54
|
+
# with RSpec, but feel free to customize to your heart's content.
|
55
|
+
=begin
|
56
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
57
|
+
# recommended. For more details, see:
|
58
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
59
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
60
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
61
|
+
config.disable_monkey_patching!
|
62
|
+
|
63
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
64
|
+
# be too noisy due to issues in dependencies.
|
65
|
+
config.warnings = true
|
66
|
+
|
67
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
68
|
+
# file, and it's useful to allow more verbose output when running an
|
69
|
+
# individual spec file.
|
70
|
+
if config.files_to_run.one?
|
71
|
+
# Use the documentation formatter for detailed output,
|
72
|
+
# unless a formatter has already been configured
|
73
|
+
# (e.g. via a command-line flag).
|
74
|
+
config.default_formatter = 'doc'
|
75
|
+
end
|
76
|
+
|
77
|
+
# Print the 10 slowest examples and example groups at the
|
78
|
+
# end of the spec run, to help surface which specs are running
|
79
|
+
# particularly slow.
|
80
|
+
config.profile_examples = 10
|
81
|
+
|
82
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
83
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
84
|
+
# test failures related to randomization by passing the same `--seed` value
|
85
|
+
# as the one that triggered the failure.
|
86
|
+
Kernel.srand config.seed
|
87
|
+
=end
|
88
|
+
end
|