edi 0.1.2
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 +23 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/Guardfile +47 -0
- data/LICENSE.txt +22 -0
- data/README.md +129 -0
- data/Rakefile +11 -0
- data/bin/edi +12 -0
- data/edi.gemspec +40 -0
- data/features/fact_service.feature +7 -0
- data/features/giphy_service.feature +43 -0
- data/features/i_heart_quotes_service.feature +21 -0
- data/features/step_definitions/fact_service_steps.rb +7 -0
- data/features/step_definitions/giphy_steps.rb +3 -0
- data/features/step_definitions/server_steps.rb +3 -0
- data/features/step_definitions/tweet_that_steps.rb +19 -0
- data/features/step_definitions/weather_steps.rb +3 -0
- data/features/support/env.rb +37 -0
- data/features/support/hooks.rb +1 -0
- data/features/support/vcr_cassettes/Fact_Service/EDI_responds_with_a_random_fact.yml +53 -0
- data/features/support/vcr_cassettes/Fact_Service/Jarvis_responds_with_a_random_fact.yml +52 -0
- data/features/support/vcr_cassettes/Giphy_Service/Bacon.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Cat_Wording.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording_-_Case_Insensitive.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Plain_old_GIF.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Sloth.yml +58 -0
- data/features/support/vcr_cassettes/Giphy_Service/Trippy.yml +58 -0
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Random_Quote.yml +44 -0
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Simpsons_Quote.yml +44 -0
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Star_Wars_Quote.yml +44 -0
- data/features/support/vcr_cassettes/Tweet_that/Post_the_last_message_to_twitter.yml +211 -0
- data/features/support/vcr_cassettes/Weather_Service/Use_a_specified_location.yml +86 -0
- data/features/support/vcr_cassettes/Weather_Service/Use_default_location.yml +86 -0
- data/features/tweet_that_service.feature +14 -0
- data/features/weather_service.feature +21 -0
- data/lib/edi.rb +53 -0
- data/lib/edi/api/response.rb +22 -0
- data/lib/edi/application.rb +39 -0
- data/lib/edi/cli.rb +61 -0
- data/lib/edi/configuration.rb +26 -0
- data/lib/edi/core_ext.rb +1 -0
- data/lib/edi/core_ext/symbol.rb +7 -0
- data/lib/edi/exceptions.rb +8 -0
- data/lib/edi/http_utilities.rb +40 -0
- data/lib/edi/interpreter.rb +32 -0
- data/lib/edi/refinements.rb +1 -0
- data/lib/edi/refinements/zip_refinement.rb +11 -0
- data/lib/edi/scheduler.rb +21 -0
- data/lib/edi/server.rb +45 -0
- data/lib/edi/service.rb +89 -0
- data/lib/edi/services.rb +9 -0
- data/lib/edi/services/dice.rb +25 -0
- data/lib/edi/services/eightball.rb +38 -0
- data/lib/edi/services/fact.rb +7 -0
- data/lib/edi/services/giphy.rb +38 -0
- data/lib/edi/services/i_heart_quotes.rb +29 -0
- data/lib/edi/services/img_flip.rb +69 -0
- data/lib/edi/services/img_flip_memes/afraid_to_ask.rb +17 -0
- data/lib/edi/services/img_flip_memes/and_its_gone.rb +17 -0
- data/lib/edi/services/img_flip_memes/base_meme.rb +57 -0
- data/lib/edi/services/img_flip_memes/everywhere.rb +15 -0
- data/lib/edi/services/img_flip_memes/gonna_have_a_bad_time.rb +17 -0
- data/lib/edi/services/img_flip_memes/most_interesting_man.rb +13 -0
- data/lib/edi/services/img_flip_memes/not_sure_if.rb +13 -0
- data/lib/edi/services/img_flip_memes/one_does_not_simply.rb +17 -0
- data/lib/edi/services/img_flip_memes/overly_attached_girlfriend.rb +13 -0
- data/lib/edi/services/img_flip_memes/picard.rb +13 -0
- data/lib/edi/services/img_flip_memes/success_kid.rb +13 -0
- data/lib/edi/services/img_flip_memes/sudden_clarity.rb +13 -0
- data/lib/edi/services/img_flip_memes/what_if_i_told_you.rb +17 -0
- data/lib/edi/services/img_flip_memes/willy_wonka.rb +13 -0
- data/lib/edi/services/img_flip_memes/y_u_no.rb +17 -0
- data/lib/edi/services/null_service.rb +5 -0
- data/lib/edi/services/tweet_that.rb +68 -0
- data/lib/edi/services/weather.rb +42 -0
- data/lib/edi/slack.rb +1 -0
- data/lib/edi/slack/message.rb +17 -0
- data/lib/edi/test_support/cucumber.rb +1 -0
- data/lib/edi/test_support/test_support.rb +27 -0
- data/lib/edi/utilities/array_responder.rb +16 -0
- data/lib/edi/version.rb +3 -0
- data/spec/edi/edi_spec.rb +29 -0
- data/spec/edi/interpreter_spec.rb +61 -0
- data/spec/edi/server_spec.rb +20 -0
- data/spec/edi/service_spec.rb +112 -0
- data/spec/services/dice_spec.rb +22 -0
- data/spec/services/eightball_spec.rb +9 -0
- data/spec/services/fact_spec.rb +7 -0
- data/spec/services/giphy_spec.rb +46 -0
- data/spec/services/i_heart_quotes_spec.rb +50 -0
- data/spec/services/img_flip_spec.rb +89 -0
- data/spec/services/null_service_spec.rb +3 -0
- data/spec/services/tweet_that_spec.rb +18 -0
- data/spec/services/weather_spec.rb +17 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/fixtures/vcr_cassettes/fact.yml +57 -0
- data/spec/support/fixtures/vcr_cassettes/giphy.yml +513 -0
- data/spec/support/fixtures/vcr_cassettes/i_heart_quotes.yml +222 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_afraid_to_ask.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_and_its_gone.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_everywhere.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_gonna_have_a_bad_time.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_most_interesting_man.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_not_sure_if.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_one_does_not_simply.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_overly_attached_girlfriend.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_picard.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_success_kid.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_sudden_clarity.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_what_if_I_told_you.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_willy_wonka.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/img_flip_y_u_no.yml +54 -0
- data/spec/support/fixtures/vcr_cassettes/tweet_that.yml +189 -0
- data/spec/support/fixtures/vcr_cassettes/weather.yml +346 -0
- data/spec/support/shared_contexts/server.rb +9 -0
- data/spec/support/shared_contexts/service.rb +10 -0
- data/templates/project/Gemfile +7 -0
- data/templates/project/bot/server.rb +6 -0
- data/templates/project/bot/services/.gitkeep +0 -0
- data/templates/project/config.ru +2 -0
- data/templates/project/config/.gitkeep +0 -0
- data/templates/project/config/environment.rb +12 -0
- data/templates/project/config/initializers/.gitkeep +0 -0
- data/templates/services/%name%.rb.tt +5 -0
- metadata +514 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5dec39d30abdd3e6d06e0cf83760054aec0c9c4a
|
4
|
+
data.tar.gz: fd798a1b99fa7fd35a4957be70363c5aca7cf96f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c64a98478aff5c70c7a62ca81822dd8e72d3857777ef7763a373a5e90c89288d7b6ee51e257712047ed18da53de42c6770ab626111d5693fe95014a6edbc3a5b
|
7
|
+
data.tar.gz: dd6b9aa22bb635e9a954caa9b67382d9645b48cbefb6efe6a713139dd22b11245d3fcf1fe397f3602a82a361c0fdfb43a8b4c5d68170b446815076bb86c7cc56
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
variables.sh
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.4
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: 'rspec' do
|
36
|
+
watch(%r{^spec/.+_spec\.rb$})
|
37
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
38
|
+
watch('spec/spec_helper.rb') { "spec" }
|
39
|
+
end
|
40
|
+
|
41
|
+
guard "cucumber" do
|
42
|
+
watch(%r{^features/.+\.feature$})
|
43
|
+
watch(%r{^features/support/.+$}) { "features" }
|
44
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
45
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "features"
|
46
|
+
end
|
47
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 DVG
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# EDI [](https://travis-ci.org/DVG/EDI)
|
2
|
+
|
3
|
+
## Warning, these instructions are not true yet, but they will be!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Or install it yourself as:
|
8
|
+
|
9
|
+
$ gem install edi
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
edi is an application framework for building Chat bots to integrate with your Slack chat room. It ships with a number of useful and funny built-in services, but it also provides and easy DSL for creating your own services.
|
14
|
+
|
15
|
+
### Generating a new chat bot
|
16
|
+
|
17
|
+
Creating a chatbot is as easy as:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ edi new my-bot
|
21
|
+
```
|
22
|
+
|
23
|
+
### Registering Services
|
24
|
+
|
25
|
+
`/bot/server.rb` is the main brain of your edi bot. Here you can register which services you want to be available on your chatbot.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
class Server < EDI::Server
|
29
|
+
register_services :tweet_that, :img_flip, :urban_dictionary, :weather
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
These are the services that will be enabled when edi interprets a message from Slack.
|
34
|
+
|
35
|
+
### Required Environment Variables
|
36
|
+
|
37
|
+
If a Service integrates with an authenticated, third party API, you may need to set up environment variables for API Tokens, Secrets, Usernames and Passwords, etc. To ensure that services are not run in environments that aren't set up to support them, services can require certain variables be set up.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
class MyService < EDI::Service
|
41
|
+
environment :service_token, :service_secret
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
If a service is Registered in `app/server.rb` but does not have it's expected environment, edi will throw an exception and respond with a polite refusal to execute the service. This message can be set in your EDI configuration. The enviornment method will also create a getter method for each environment variable.
|
46
|
+
|
47
|
+
### Service Routing
|
48
|
+
|
49
|
+
There are two ways to tell edi to send a given message to a particular service.`interpreter_pattern` and `phrases`
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
class ImgFlip < EDI::Service
|
53
|
+
phrases "success kid", "overly attached girlfriend"
|
54
|
+
# will converted to a pattern that looks like /success kid|overly attached girlfriend/i
|
55
|
+
end
|
56
|
+
class SortingHat < EDI::Service
|
57
|
+
interpreter_pattern /sorting hat|where do I belong/i
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Setting interpreter pattern directly will take precendence over phrases if you include both.
|
62
|
+
|
63
|
+
### Running the Service
|
64
|
+
|
65
|
+
Services should expose a `run` method. This method will perform whatever actions necessary to fulfill the service and should ultimately return the string that edi will send back to the channel in slack.
|
66
|
+
|
67
|
+
A very simple service might look like:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
class SortingHat < EDI::Service
|
71
|
+
def run
|
72
|
+
[
|
73
|
+
"Gryphondor, where dwell the brave of heart!",
|
74
|
+
"Slytherine, because you are kind of a jerk"
|
75
|
+
].sample
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
If you want to use a more semantic name for your service, you can override the method using `invoke_with`
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
class IJustMetYou < EDI::Service
|
84
|
+
invoke_with :call_me_maybe
|
85
|
+
|
86
|
+
def call_me_maybe
|
87
|
+
"This is crazy, but here's my number, so call me maybe"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
### Callbacks
|
93
|
+
|
94
|
+
You can do actions before or after the service is run, but before edi responds. For instance:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
class Joke < EDI::Service
|
98
|
+
before_invoke :setup
|
99
|
+
invoke_with :punch
|
100
|
+
|
101
|
+
def setup
|
102
|
+
Slack::Post.new(channel_id, "What do you call a fish with no eyes?").send_message
|
103
|
+
sleep 1
|
104
|
+
end
|
105
|
+
|
106
|
+
def punch
|
107
|
+
"A FSH!"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
```
|
111
|
+
## Ship List
|
112
|
+
|
113
|
+
When these things are done, we'll be ready for 1.0
|
114
|
+
|
115
|
+
- [x] Finish Porting The Services from the original bot to the framework
|
116
|
+
- [ ] Ability for edi to Post Back into the Slack Chatroom
|
117
|
+
- [ ] EDI::Schedule
|
118
|
+
- [ ] Add Test Framework to the Project Generator
|
119
|
+
- [x] Service Generator
|
120
|
+
- [x] Configure All The Things
|
121
|
+
- [x] Boot Process for the Generated App
|
122
|
+
|
123
|
+
## Contributing
|
124
|
+
|
125
|
+
1. Fork it ( https://github.com/DVG/EDI/fork )
|
126
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
127
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
128
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
129
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/edi
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'edi'
|
4
|
+
|
5
|
+
require "pathname"
|
6
|
+
bin_file = Pathname.new(__FILE__).realpath
|
7
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
8
|
+
|
9
|
+
require 'edi/cli'
|
10
|
+
|
11
|
+
EDI::CLI.source_root(File.expand_path('../../templates', bin_file))
|
12
|
+
EDI::CLI.start(ARGV)
|
data/edi.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'edi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "edi"
|
8
|
+
spec.version = EDI::VERSION
|
9
|
+
spec.authors = ["DVG"]
|
10
|
+
spec.email = ["bradley.temple@gmail.com"]
|
11
|
+
spec.summary = %q{Chatbot Application Framework for Slack Chat Rooms}
|
12
|
+
spec.homepage = "https://github.com/DVG/edi.git"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "byebug"
|
24
|
+
spec.add_development_dependency "vcr"
|
25
|
+
spec.add_development_dependency "webmock"
|
26
|
+
spec.add_development_dependency "cucumber"
|
27
|
+
spec.add_development_dependency "capybara"
|
28
|
+
spec.add_development_dependency "guard"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_development_dependency "guard-cucumber"
|
31
|
+
spec.add_development_dependency "terminal-notifier-guard"
|
32
|
+
spec.add_dependency "sinatra"
|
33
|
+
spec.add_dependency "sinatra-contrib"
|
34
|
+
spec.add_dependency "httparty"
|
35
|
+
spec.add_dependency "thor"
|
36
|
+
spec.add_dependency "activesupport"
|
37
|
+
spec.add_dependency "hooks"
|
38
|
+
spec.add_dependency "twitter"
|
39
|
+
spec.add_dependency "rufus-scheduler"
|
40
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
@vcr
|
2
|
+
Feature: Fact Service
|
3
|
+
|
4
|
+
Scenario: EDI responds with a random fact
|
5
|
+
Given a server is running with the fact service enabled
|
6
|
+
When EDI recieves the message "EDI. fact"
|
7
|
+
Then EDI will respond with "38 is the number of minutes in the shortest war in history in which Zanzibar surrendered to England in 1896."
|
@@ -0,0 +1,43 @@
|
|
1
|
+
@vcr
|
2
|
+
Feature: Giphy Service
|
3
|
+
In order to amuse my team
|
4
|
+
As a lover of GIFs
|
5
|
+
I want EDI to return random GIFs from a variety of categories
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given the environment is configured for Giphy
|
9
|
+
|
10
|
+
Scenario: Plain old GIF
|
11
|
+
Given a server is running with the giphy service enabled
|
12
|
+
When EDI recieves the message "EDI a gif please"
|
13
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/10eqhIldgc59za/giphy.gif"
|
14
|
+
|
15
|
+
Scenario: Cat GIF - Cat Wording
|
16
|
+
Given a server is running with the giphy service enabled
|
17
|
+
When EDI recieves the message "EDI a cat gif please"
|
18
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/ucEr1xRMsj6Fi/giphy.gif"
|
19
|
+
|
20
|
+
Scenario: Cat GIF - Kitty Wording
|
21
|
+
Given a server is running with the giphy service enabled
|
22
|
+
When EDI recieves the message "EDI a Kitty gif please"
|
23
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/xA88mlhRVZ3lm/giphy.gif"
|
24
|
+
|
25
|
+
Scenario: Cat GIF - Kitty Wording - Case Insensitive
|
26
|
+
Given a server is running with the giphy service enabled
|
27
|
+
When EDI recieves the message "EDI a KiTty gif please"
|
28
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/paYyHCsUUXQPK/giphy.gif"
|
29
|
+
|
30
|
+
Scenario: Sloth
|
31
|
+
Given a server is running with the giphy service enabled
|
32
|
+
When EDI recieves the message "EDI a sloth gif please"
|
33
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/QoxeDUyerqIrC/giphy.gif"
|
34
|
+
|
35
|
+
Scenario: Bacon
|
36
|
+
Given a server is running with the giphy service enabled
|
37
|
+
When EDI recieves the message "EDI a bacon gif please"
|
38
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/PJ3wMa5ImiVY4/giphy.gif"
|
39
|
+
|
40
|
+
Scenario: Trippy
|
41
|
+
Given a server is running with the giphy service enabled
|
42
|
+
When EDI recieves the message "EDI a sloth gif please"
|
43
|
+
Then EDI will respond with "http://s3.amazonaws.com/giphymedia/media/upNoNLqei1FVS/giphy.gif"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
@vcr
|
2
|
+
Feature: I Heart Quotes
|
3
|
+
|
4
|
+
Because quotes are awesome
|
5
|
+
As a consumer of popular culture
|
6
|
+
I want EDI to return random quotes
|
7
|
+
|
8
|
+
Scenario: A Random Quote
|
9
|
+
Given a server is running with the i heart quotes service enabled
|
10
|
+
When EDI recieves the message "EDI know any good quotes?"
|
11
|
+
Then EDI will respond with "A random quote goes here"
|
12
|
+
|
13
|
+
Scenario: A Simpsons Quote
|
14
|
+
Given a server is running with the i heart quotes service enabled
|
15
|
+
When EDI recieves the message "EDI know any good simpsons quotes?"
|
16
|
+
Then EDI will respond with "Marge: I would love you if you weighed 1,000 pounds but ..."
|
17
|
+
|
18
|
+
Scenario: A Star Wars Quote
|
19
|
+
Given a server is running with the i heart quotes service enabled
|
20
|
+
When EDI recieves the message "EDI know any good star wars quotes?"
|
21
|
+
Then EDI will respond with "Emperor Palpatine Strike me down with all of your hatred and your journey towards the dark side will be complete!"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
Given(/^the Tweet That is configured$/) do
|
5
|
+
stub_env "SLACK_TOKEN" => "slack_token",
|
6
|
+
"TWITTER_ACCESS_TOKEN" => "twitter_access_token",
|
7
|
+
"TWITTER_CONSUMER_KEY" => "twitter_consumer_key",
|
8
|
+
"TWITTER_CONSUMER_SECRET" => "twitter_consumer_secret",
|
9
|
+
"TWITTER_HANDLE" => "twitter_handle",
|
10
|
+
"TWITTER_TOKEN_SECRET" => "twitter_token_secret"
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^the user (.+) post a message to the general channel saying "(.*?)"$/) do |user_name, message|
|
14
|
+
@response = post("/edi", slack_outgoing_message(text: message, channel_id: general_channel_id, user_name: user_name))
|
15
|
+
end
|
16
|
+
|
17
|
+
def general_channel_id
|
18
|
+
"C0000001"
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'cucumber'
|
2
|
+
require 'edi'
|
3
|
+
require 'rack/test'
|
4
|
+
require 'byebug'
|
5
|
+
require 'json'
|
6
|
+
require 'capybara/cucumber'
|
7
|
+
require 'vcr'
|
8
|
+
require 'webmock'
|
9
|
+
require 'edi/test_support/test_support'
|
10
|
+
require 'edi/test_support/cucumber'
|
11
|
+
|
12
|
+
|
13
|
+
include Rack::Test::Methods
|
14
|
+
include EDI::TestSupport
|
15
|
+
|
16
|
+
Before do
|
17
|
+
class Server < EDI::Server
|
18
|
+
end
|
19
|
+
Capybara.app = Server
|
20
|
+
end
|
21
|
+
|
22
|
+
After do
|
23
|
+
Object.send :remove_const, :Server
|
24
|
+
end
|
25
|
+
|
26
|
+
VCR.configure do |config|
|
27
|
+
config.cassette_library_dir = "features/support/vcr_cassettes"
|
28
|
+
config.hook_into :webmock
|
29
|
+
end
|
30
|
+
|
31
|
+
VCR.cucumber_tags do |t|
|
32
|
+
t.tag '@vcr', :use_scenario_name => true
|
33
|
+
end
|
34
|
+
|
35
|
+
def app
|
36
|
+
Server
|
37
|
+
end
|