Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from michaelparenteau/hey-buddy
Bringing back the tweets - Thanks Rob!
- Loading branch information
Showing
8 changed files
with
158 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
source "http://rubygems.org" | ||
gem "i18n" | ||
gem "activesupport", "~> 3.1", :require => nil | ||
gem "rake" | ||
gem "rack" | ||
gem "sinatra", "1.1.2", :require => "sinatra" | ||
gem "haml" | ||
gem "sinatra-static-assets" | ||
gem "maruku" | ||
gem "swish" | ||
gem "twitter" | ||
gem "heroku" | ||
gem "heroku" | ||
|
||
group :test do | ||
gem "fakeweb" | ||
gem "rack-test" | ||
gem "mocha" | ||
gem "rspec" | ||
gem "guard" | ||
gem "guard-rspec" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard 'rspec', :version => 2 do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch('spec/spec_helper.rb') { "spec" } | ||
watch('app.rb') { "spec" } | ||
watch(%r{^(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | ||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | ||
watch('spec/spec_helper.rb') { "spec" } | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "rubygems" | ||
require "bundler/setup" | ||
require "rspec/core/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => [:spec] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[..]) | ||
Bundler.require(:test) | ||
ENV['RACK_ENV'] = 'test' | ||
require 'app' | ||
require 'rspec' | ||
require 'mocha' | ||
require 'rack/test' | ||
|
||
RSpec.configure do |conf| | ||
conf.include Rack::Test::Methods | ||
conf.mock_with :mocha | ||
end | ||
|
||
describe "the App" do | ||
def app | ||
Sinatra::Application | ||
end | ||
|
||
before do | ||
# Don't allow any real http requests -- we don't want Dribble or Twitter | ||
# requests happening during test runs | ||
FakeWeb.allow_net_connect = false | ||
end | ||
|
||
it "has a good response" do | ||
app.any_instance.stubs(:last_shot).returns(stub_everything("dribble shot")) | ||
app.any_instance.stubs(:last_tweet).returns("some tweet") | ||
get '/' | ||
last_response.should be_ok | ||
end | ||
|
||
it "shows friendly error message if tweets can't be loaded" do | ||
app.any_instance.stubs(:last_shot).returns(stub_everything("dribble shot")) | ||
app.any_instance.expects(:last_tweet).returns(nil) | ||
get "/" | ||
last_response.body.should include("Twitter requests are timing out") | ||
end | ||
|
||
it "shows friendly error message if twitter raises an exception" do | ||
app.any_instance.stubs(:last_shot).returns(stub_everything("dribble shot")) | ||
Twitter.expects(:user_timeline).raises(RuntimeError) | ||
get "/" | ||
last_response.body.should include("Twitter requests are timing out") | ||
end | ||
|
||
it "shows the latest tweet" do | ||
app.any_instance.stubs(:last_shot).returns(stub_everything("dribble shot")) | ||
app.any_instance.expects(:last_tweet).returns("this is a tweet!") | ||
get "/" | ||
last_response.body.should include("this is a tweet!") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters