boty 0.0.17 → 0.0.17.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ require "support/thor_support"
2
+ require "boty/cli"
3
+
4
+ module TemplateProjectSupport
5
+ include ThorSupport
6
+
7
+ def self.included(base)
8
+ def dry_run
9
+ allow(cli).to receive(:run)
10
+ end
11
+
12
+ def create_bot(name = nil, company:, api_key:)
13
+ allow(cli).to receive(:ask).and_return company, api_key
14
+ cli.new name || bot_name
15
+ end
16
+
17
+ base.instance_eval do
18
+ before(:all) do
19
+ @original_dir = FileUtils.pwd
20
+ FileUtils.mkdir_p "tpl_project_tmp" if !Dir.exists? "tpl_project_tmp"
21
+ FileUtils.chdir "tpl_project_tmp"
22
+ end
23
+
24
+ before do
25
+ FileUtils.rm_rf bot_name if Dir.exists? bot_name
26
+ end
27
+
28
+ after(:all) do
29
+ FileUtils.chdir @original_dir
30
+ FileUtils.rm_rf "tpl_project_tmp"
31
+ end
32
+
33
+ subject(:cli) { Boty::CLI.new }
34
+ let(:bot_name) { "jeeba" }
35
+ end
36
+ end
37
+ end
38
+
39
+ RSpec::Matchers.define :run do |command|
40
+ match do |bot|
41
+ expect(bot).to receive(:run).with command
42
+ end
43
+ end
44
+
@@ -0,0 +1,21 @@
1
+ module ThorSupport
2
+ # stolen from https://github.com/erikhuda/thor/blob/3241f2fbf1172b6182723b073fd4b390200660e9/spec/helper.rb#L51
3
+ def capture(stream)
4
+ begin
5
+ stream = stream.to_s
6
+ eval "$#{stream} = StringIO.new"
7
+ yield
8
+ result = eval("$#{stream}").string
9
+ ensure
10
+ eval("$#{stream} = #{stream.upcase}")
11
+ end
12
+
13
+ result
14
+ end
15
+ end
16
+
17
+ RSpec::Matchers.define :run do |command|
18
+ match do |bot|
19
+ expect(bot).to receive(:run).with command
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Valeriano
@@ -202,6 +202,32 @@ files:
202
202
  - script/knows.rb
203
203
  - script/pug.rb
204
204
  - script/remember.rb
205
+ - spec/boty/bot_spec.rb
206
+ - spec/boty/cli_spec.rb
207
+ - spec/boty/logger_spec.rb
208
+ - spec/boty/message_spec.rb
209
+ - spec/boty/rspec_spec.rb
210
+ - spec/boty/session_spec.rb
211
+ - spec/boty/slack/chat_spec.rb
212
+ - spec/boty/slack/im_spec.rb
213
+ - spec/boty/slack/rtm_spec.rb
214
+ - spec/boty/slack/url_spec.rb
215
+ - spec/boty/slack/users_spec.rb
216
+ - spec/happy_path_spec.rb
217
+ - spec/script/i18n_spec.rb
218
+ - spec/script/knows_spec.rb
219
+ - spec/script/pug_spec.rb
220
+ - spec/script/remember_spec.rb
221
+ - spec/spec_helper.rb
222
+ - spec/support/em_support.rb
223
+ - spec/support/fakefs_support.rb
224
+ - spec/support/faraday_support.rb
225
+ - spec/support/faye_support.rb
226
+ - spec/support/file_system_matchers.rb
227
+ - spec/support/session_support.rb
228
+ - spec/support/slack_support.rb
229
+ - spec/support/template_project_support.rb
230
+ - spec/support/thor_support.rb
205
231
  - template/project/%bot_name%.rb
206
232
  - template/project/.env.local.tt
207
233
  - template/project/.rspec