From 490c6b5b1a77a6824fb01ffe5d141a5713a4dc74 Mon Sep 17 00:00:00 2001 From: guilherme silveira Date: Mon, 30 Aug 2010 12:46:31 -0300 Subject: [PATCH] twitter specs up and running --- spec/integration/twitter/spec_helper.rb | 11 ----------- tests/Gemfile | 1 + tests/Gemfile.lock | 2 ++ .../integration/projects_controller_spec.rb | 2 +- tests/spec/integration/spec_helper.rb | 6 ++++++ .../responses => tests/spec/integration}/twitter.rb | 0 .../spec/integration}/twitter_spec.rb | 9 ++++++++- 7 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 spec/integration/twitter/spec_helper.rb create mode 100644 tests/spec/integration/spec_helper.rb rename {spec/integration/fixtures/responses => tests/spec/integration}/twitter.rb (100%) rename {spec/integration/twitter => tests/spec/integration}/twitter_spec.rb (65%) diff --git a/spec/integration/twitter/spec_helper.rb b/spec/integration/twitter/spec_helper.rb deleted file mode 100644 index 96beec31..00000000 --- a/spec/integration/twitter/spec_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) - -require 'rubygems' -require 'spec' -require 'restfulie' -require 'restfulie/client' -require 'fakeweb' - -require File.dirname(__FILE__) + '/../fixtures/responses/twitter' - -FakeWeb.allow_net_connect = false \ No newline at end of file diff --git a/tests/Gemfile b/tests/Gemfile index 327b4670..41bf287d 100644 --- a/tests/Gemfile +++ b/tests/Gemfile @@ -25,6 +25,7 @@ gem 'sqlite3-ruby', :require => 'sqlite3' gem 'restfulie', '1.0.0.beta.1' group :test, :development do + gem "fakeweb" gem "sinatra" gem "rack-conneg" gem "rspec-rails", ">= 2.0.0.beta.19" diff --git a/tests/Gemfile.lock b/tests/Gemfile.lock index bd193108..2dc3c915 100644 --- a/tests/Gemfile.lock +++ b/tests/Gemfile.lock @@ -34,6 +34,7 @@ GEM diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) + fakeweb (1.2.8) i18n (0.4.1) json_pure (1.4.6) mail (2.2.5) @@ -98,6 +99,7 @@ PLATFORMS ruby DEPENDENCIES + fakeweb rack-conneg rails (= 3.0.0) restfulie (= 1.0.0.beta.1) diff --git a/tests/spec/controllers/integration/projects_controller_spec.rb b/tests/spec/controllers/integration/projects_controller_spec.rb index 8950e95a..c6c904f7 100644 --- a/tests/spec/controllers/integration/projects_controller_spec.rb +++ b/tests/spec/controllers/integration/projects_controller_spec.rb @@ -6,7 +6,7 @@ before do request.accept = "application/atom+xml" - response.stub (:content_type) { "application/atom+xml" } + response.stub(:content_type) { "application/atom+xml" } end it "renders view files with tokamak extension" do diff --git a/tests/spec/integration/spec_helper.rb b/tests/spec/integration/spec_helper.rb new file mode 100644 index 00000000..9aaeb720 --- /dev/null +++ b/tests/spec/integration/spec_helper.rb @@ -0,0 +1,6 @@ +# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) + +require 'spec_helper' +require 'fakeweb' + +require File.dirname(__FILE__) + '/twitter' diff --git a/spec/integration/fixtures/responses/twitter.rb b/tests/spec/integration/twitter.rb similarity index 100% rename from spec/integration/fixtures/responses/twitter.rb rename to tests/spec/integration/twitter.rb diff --git a/spec/integration/twitter/twitter_spec.rb b/tests/spec/integration/twitter_spec.rb similarity index 65% rename from spec/integration/twitter/twitter_spec.rb rename to tests/spec/integration/twitter_spec.rb index c8a73283..41231704 100644 --- a/spec/integration/twitter/twitter_spec.rb +++ b/tests/spec/integration/twitter_spec.rb @@ -4,7 +4,10 @@ TWITTER_ENTRY_POINT = "http://twitter.com/statuses/public_timeline.xml" - before { FakeWeb.register_uri(:get, TWITTER_ENTRY_POINT, :response => Responses::Twitter.public_timeline) } + before do + FakeWeb.allow_net_connect = false + FakeWeb.register_uri(:get, TWITTER_ENTRY_POINT, :response => Responses::Twitter.public_timeline) + end it "should work with twitter" do statuses = Restfulie.at("http://twitter.com/statuses/public_timeline.xml").get @@ -12,5 +15,9 @@ puts "#{status.user.screen_name}: #{status.text}, #{status.created_at}" end end + + after do + FakeWeb.allow_net_connect = true + end end \ No newline at end of file