Permalink
Browse files

Adds /octocat support with Octokit.say

  • Loading branch information...
1 parent 39c2b42 commit 1fe6e16f78077524c1ce06f5abdbfabb7d418b6d @pengwynn pengwynn committed Nov 29, 2012
Showing with 97 additions and 0 deletions.
  1. +2 −0 lib/octokit/client.rb
  2. +14 −0 lib/octokit/client/say.rb
  3. +22 −0 spec/fixtures/say.txt
  4. +22 −0 spec/fixtures/say_custom.txt
  5. +37 −0 spec/octokit/client/say_spec.rb
View
2 lib/octokit/client.rb
@@ -25,6 +25,7 @@
require 'octokit/client/markdown'
require 'octokit/client/emojis'
require 'octokit/client/statuses'
+require 'octokit/client/say'
require 'octokit/client/rate_limit'
module Octokit
@@ -63,6 +64,7 @@ def initialize(options={})
include Octokit::Client::Markdown
include Octokit::Client::Emojis
include Octokit::Client::Statuses
+ include Octokit::Client::Say
include Octokit::Client::RateLimit
end
end
View
14 lib/octokit/client/say.rb
@@ -0,0 +1,14 @@
+module Octokit
+ class Client
+ module Say
+
+ def say(text=nil)
+ options = {}
+ options[:s] = text if text
+ get "/octocat", options
+ end
+ alias :octocat :say
+
+ end
+ end
+end
View
22 spec/fixtures/say.txt
@@ -0,0 +1,22 @@
+
+ MMM. .MMM
+ MMMMMMMMMMMMMMMMMMM
+ MMMMMMMMMMMMMMMMMMM _____________________________________________
+ MMMMMMMMMMMMMMMMMMMMM | |
+ MMMMMMMMMMMMMMMMMMMMMMM | Half measures are as bad as nothing at all. |
+ MMMMMMMMMMMMMMMMMMMMMMMM |_ _________________________________________|
+ MMMM::- -:::::::- -::MMMM |/
+ MM~:~ ~:::::~ ~:~MM
+ .. MMMMM::. .:::+:::. .::MMMMM ..
+ .MM::::: ._. :::::MM.
+ MMMM;:::::;MMMM
+ -MM MMMMMMM
+ ^ M+ MMMMMMMMM
+ MMMMMMM MM MM MM
+ MM MM MM MM
+ MM MM MM MM
+ .~~MM~MM~MM~MM~~.
+ ~~~~MM:~MM~~~MM~:MM~~~~
+ ~~~~~~==~==~~~==~==~~~~~~
+ ~~~~~~==~==~==~==~~~~~~
+ :~==~==~==~==~~
View
22 spec/fixtures/say_custom.txt
@@ -0,0 +1,22 @@
+
+ MMM. .MMM
+ MMMMMMMMMMMMMMMMMMM
+ MMMMMMMMMMMMMMMMMMM ______________________________
+ MMMMMMMMMMMMMMMMMMMMM | |
+ MMMMMMMMMMMMMMMMMMMMMMM | There is no need to be upset |
+ MMMMMMMMMMMMMMMMMMMMMMMM |_ __________________________|
+ MMMM::- -:::::::- -::MMMM |/
+ MM~:~ ~:::::~ ~:~MM
+ .. MMMMM::. .:::+:::. .::MMMMM ..
+ .MM::::: ._. :::::MM.
+ MMMM;:::::;MMMM
+ -MM MMMMMMM
+ ^ M+ MMMMMMMMM
+ MMMMMMM MM MM MM
+ MM MM MM MM
+ MM MM MM MM
+ .~~MM~MM~MM~MM~~.
+ ~~~~MM:~MM~~~MM~:MM~~~~
+ ~~~~~~==~==~~~==~==~~~~~~
+ ~~~~~~==~==~==~==~~~~~~
+ :~==~==~==~==~~
View
37 spec/octokit/client/say_spec.rb
@@ -0,0 +1,37 @@
+# -*- encoding: utf-8 -*-
+require 'helper'
+
+describe Octokit::Client::Say do
+ before do
+ @client = Octokit::Client.new
+ end
+
+ describe ".say" do
+ it "returns an ASCII octocat" do
+ stub_get("/say").
+ to_return \
+ :status => 200,
+ :body => fixture("say.txt"),
+ :headers => {
+ :content_type => 'text/plain'
+ }
+
+ text = @client.say
+ expect(text).to match(/Half measures/)
+ end
+
+ it "returns an ASCII octocat with custom text" do
+ stub_get("/say").
+ to_return \
+ :status => 200,
+ :body => fixture("say_custom.txt"),
+ :headers => {
+ :content_type => 'text/plain'
+ }
+
+ text = @client.say
+ expect(text).to match(/upset/)
+ end
+ end
+
+end

0 comments on commit 1fe6e16

Please sign in to comment.