boty 0.0.16 → 0.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc63f6f21fe9a8ed94ed24c71baa71892838561e
4
- data.tar.gz: 99fd5f633a9d371c8f44655a8c7f5d521c5219a4
3
+ metadata.gz: d60d83658211dd0b17fdfeb269033ce2c73ee291
4
+ data.tar.gz: 29148f8ba9a8d4dfa83d36f612c2a97959f5e5ef
5
5
  SHA512:
6
- metadata.gz: c467c3f6c828bd8d8caeb79a51e0c89058c8d3225adbebaf2e62f7053b6d796324ed98e7b80a3fc8c6cba141e3ac40fd7e34789998dc0d95f3c4c84db097ec46
7
- data.tar.gz: 19ea126a36e6484cd3600fc9e9255b4f7a7e5e919232c894b6c7b45a1b12854aa197facd14e58c346603a3f00bb113722bf51824459691c507c85e807c295a2d
6
+ metadata.gz: 4e583ec20c26d42226cf1e52bedfebab6b184bbccca3a3ecab576fe305a0adb96ea1a6d56a1d19d0e115cb1e1c5682c81ddb15b8505956b8a6e32f2a525269b9
7
+ data.tar.gz: cef240051671e266025c744489090c199c54177305da4dd0343b131076c270ad8278c1350be895e8d9b726c5af8224658cac95fc774fc3e8deb49f63cbfd0d91
data/.gitignore CHANGED
@@ -14,4 +14,4 @@
14
14
 
15
15
  .env.local
16
16
  pkg
17
- .rspec
17
+ /.rspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boty (0.0.16)
4
+ boty (0.0.17)
5
5
  eventmachine
6
6
  faraday
7
7
  faye-websocket
@@ -18,7 +18,7 @@ GEM
18
18
  fakefs (0.6.7)
19
19
  faraday (0.9.2)
20
20
  multipart-post (>= 1.2, < 3)
21
- faye-websocket (0.10.1)
21
+ faye-websocket (0.10.2)
22
22
  eventmachine (>= 0.12.0)
23
23
  websocket-driver (>= 0.5.1)
24
24
  i18n (0.7.0)
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Boty
2
- ![](https://travis-ci.org/ricardovaleriano/boty.svg?branch=master)
2
+ [<img src="https://travis-ci.org/ricardovaleriano/boty.svg?branch=master" />](https://travis-ci.org/ricardovaleriano/boty)
3
3
 
4
4
  `Boty` is a utilitary to create bots (at this time, specificaly Slack bots).
5
5
 
data/lib/boty/cli.rb CHANGED
@@ -31,8 +31,6 @@ module Boty
31
31
 
32
32
  def after_create
33
33
  inside @bot_name do
34
- # for some reason the example .rspec isn't been copied
35
- create_file ".rspec", "--require=spec_helper"
36
34
  run "chmod +x bot"
37
35
  run "bundle install"
38
36
  end
data/lib/boty/rspec.rb CHANGED
@@ -1,40 +1,48 @@
1
1
  module Boty
2
2
  module RSpec
3
3
  module Bot
4
+ require File.expand_path "../../../spec/support/slack_support", __FILE__
5
+
4
6
  def self.included(base)
5
7
  base.instance_eval do
6
- let(:bot) {
7
- bot = Boty::Bot.new({"id" => "1234", "name" => "bot"},
8
- Boty::Session.new)
8
+ include SlackSupport::Users
9
9
 
10
- class << bot
11
- attr_accessor :_response
10
+ before do
11
+ @_bot = Boty::Bot.new(
12
+ {"id" => "1234", "name" => "bot"},
13
+ Boty::Session.new
14
+ )
12
15
 
13
- def say(message)
14
- @_response = message
16
+ class << Boty::Slack.chat
17
+ attr_accessor :messages
18
+
19
+ def post_message(message, options)
20
+ @messages ||= []
21
+ @messages << { message: message, options: options }
15
22
  end
16
23
  end
24
+ end
17
25
 
18
- bot
26
+ let(:bot) {
27
+ Boty::ScriptDSL.new @_bot
19
28
  }
20
29
  end
21
30
  end
22
31
 
23
32
  def event(options)
24
- bot.event({ "type" => "message" }.merge options)
33
+ @_bot.event({ "type" => "message" }.merge options)
25
34
  end
26
35
 
27
- def message_event(text)
36
+ def message(text)
28
37
  event "text" => text
29
38
  end
30
39
  end
31
40
 
32
41
  ::RSpec::Matchers.define :have_responded do |expected|
33
42
  # TODO: add proper messages for failures.
34
- match do |bot|
35
- response = bot._response
36
- bot._response = nil
37
- response == expected
43
+ match do |dsl|
44
+ last_message = Slack.chat.messages.last
45
+ expected == last_message[:message]
38
46
  end
39
47
  end
40
48
  end
data/lib/boty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Boty
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
@@ -0,0 +1 @@
1
+ --require=spec_helper
@@ -4,5 +4,6 @@ gem "boty"
4
4
  gem "dotenv"
5
5
 
6
6
  group :test do
7
+ gem "byebug"
7
8
  gem "rspec"
8
9
  end
@@ -1,6 +1,6 @@
1
1
  RSpec.describe "bot", "/ping/i", :bot do
2
2
  it "responds with pong" do
3
- message_event "<@bot>: ping"
3
+ message "<@bot>: ping"
4
4
 
5
5
  expect(bot).to have_responded("pong")
6
6
  end
@@ -1,4 +1,4 @@
1
- require "bundler"; Bundler.setup :default, :test
1
+ require "bundler"; Bundler.require :default, :test
2
2
  require "boty"
3
3
  require "boty/rspec"
4
4
 
@@ -6,4 +6,6 @@ Dir["./spec/support/**/*.rb"].each { |f| require f }
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.include Boty::RSpec::Bot, bot: true
9
+
10
+ Boty::Logger.adapter = Boty::Logger::Null.new
9
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Valeriano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -204,6 +204,7 @@ files:
204
204
  - script/remember.rb
205
205
  - template/project/%bot_name%.rb
206
206
  - template/project/.env.local.tt
207
+ - template/project/.rspec
207
208
  - template/project/Gemfile
208
209
  - template/project/Procfile.tt
209
210
  - template/project/README.md