howzit 1.2.15 → 1.2.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,110 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Howzit::BuildNotes do
4
- subject(:ruby_gem) { Howzit::BuildNotes.new([]) }
3
+ describe Howzit::BuildNote do
4
+ subject(:buildnote) { Howzit.buildnote }
5
5
 
6
6
  describe ".new" do
7
7
  it "makes a new instance" do
8
- expect(ruby_gem).to be_a Howzit::BuildNotes
8
+ expect(buildnote).to be_a Howzit::BuildNote
9
9
  end
10
10
  end
11
11
  end
12
12
 
13
- describe Howzit::BuildNotes do
13
+ describe Howzit::Task do
14
+ subject(:task) { Howzit::Task.new(:run, 'List Directory', 'ls') }
15
+
16
+ describe ".new" do
17
+ it "makes a new task instance" do
18
+ expect(task).to be_a Howzit::Task
19
+ end
20
+ end
21
+ end
22
+
23
+ describe Howzit::Topic do
24
+ title = 'Test Title'
25
+ content = 'Test Content'
26
+ subject(:topic) { Howzit::Topic.new(title, content) }
27
+
28
+ describe ".new" do
29
+ it "makes a new topic instance" do
30
+ expect(topic).to be_a Howzit::Topic
31
+ end
32
+ it "has the correct title" do
33
+ expect(topic.title).to eq title
34
+ end
35
+ it "has the correct content" do
36
+ expect(topic.content).to eq content
37
+ end
38
+ end
39
+ end
40
+
41
+ describe Howzit::BuildNote do
14
42
  Dir.chdir('spec')
15
- how = Howzit::BuildNotes.new(['--no-upstream', '--default'])
16
- how.create_note
17
- subject { how }
43
+ Howzit.options[:include_upstream] = false
44
+ Howzit.options[:default] = true
45
+ hz = Howzit.buildnote
46
+
47
+ hz.create_note
48
+ subject(:how) { hz }
18
49
 
19
50
  describe ".note_file" do
20
51
  it "locates a build note file" do
21
- expect(subject.note_file).not_to be_empty
52
+ expect(how.note_file).not_to be_empty
53
+ end
54
+ end
55
+
56
+ describe ".grep" do
57
+ it "finds topic containing 'editable'" do
58
+ expect(how.grep('editable').map { |topic| topic.title }).to include('File Structure')
59
+ end
60
+ it "does not return non-matching topic" do
61
+ expect(how.grep('editable').map { |topic| topic.title }).not_to include('Build')
22
62
  end
23
63
  end
24
64
 
25
- describe ".grep_topics" do
26
- it "finds editable" do
27
- expect(subject.grep_topics('editable')).to include('File Structure')
28
- expect(subject.grep_topics('editable')).not_to include('Build')
65
+ describe ".find_topic" do
66
+ it "finds the File Structure topic" do
67
+ matches = how.find_topic('file struct')
68
+ expect(matches.count).to eq 1
69
+ expect(matches[0].title).to eq 'File Structure'
70
+ end
71
+ it "fuzzy matches" do
72
+ Howzit.options[:matching] = 'fuzzy'
73
+ matches = how.find_topic('flestct')
74
+ expect(matches.count).to eq 1
75
+ expect(matches[0].title).to eq 'File Structure'
76
+ end
77
+ it "succeeds with partial match" do
78
+ Howzit.options[:matching] = 'partial'
79
+ matches = how.find_topic('structure')
80
+ expect(matches.count).to eq 1
81
+ expect(matches[0].title).to eq 'File Structure'
82
+ end
83
+ it "succeeds with beginswith match" do
84
+ Howzit.options[:matching] = 'beginswith'
85
+ matches = how.find_topic('file')
86
+ expect(matches.count).to eq 1
87
+ expect(matches[0].title).to eq 'File Structure'
88
+ end
89
+ it "succeeds with exact match" do
90
+ Howzit.options[:matching] = 'exact'
91
+ matches = how.find_topic('file structure')
92
+ expect(matches.count).to eq 1
93
+ expect(matches[0].title).to eq 'File Structure'
94
+ end
95
+ it "fails with incomplete exact match" do
96
+ Howzit.options[:matching] = 'exact'
97
+ matches = how.find_topic('file struct')
98
+ expect(matches.count).to eq 0
29
99
  end
30
100
  end
31
101
 
32
- describe ".list_topic_titles" do
33
- it "finds 4 topics" do
34
- expect(subject.topics.keys.count).to eq 4
102
+ describe ".topics" do
103
+ it "contains 4 topics" do
104
+ expect(how.list_topics.count).to eq 4
35
105
  end
36
- it "outputs a newline-separated string" do
37
- expect(subject.list_topic_titles.scan(/\n/).count).to eq 3
106
+ it "outputs a newline-separated string for completion" do
107
+ expect(how.list_completions.scan(/\n/).count).to eq 3
38
108
  end
39
109
  end
40
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: howzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.15
4
+ version: 1.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -268,10 +268,16 @@ files:
268
268
  - howzit.gemspec
269
269
  - lib/.rubocop.yml
270
270
  - lib/howzit.rb
271
+ - lib/howzit/buildnote.rb
271
272
  - lib/howzit/buildnotes.rb
272
273
  - lib/howzit/colors.rb
274
+ - lib/howzit/config.rb
275
+ - lib/howzit/hash.rb
273
276
  - lib/howzit/prompt.rb
274
277
  - lib/howzit/stringutils.rb
278
+ - lib/howzit/task.rb
279
+ - lib/howzit/topic.rb
280
+ - lib/howzit/util.rb
275
281
  - lib/howzit/version.rb
276
282
  - spec/.rubocop.yml
277
283
  - spec/ruby_gem_spec.rb