Permalink
Browse files

Move to rspec.

  • Loading branch information...
1 parent 6422d01 commit c71d91e5806d5b6275b80183fc24e173b691f262 @farnoux farnoux committed Apr 16, 2012
View
3 .rspec
@@ -0,0 +1,3 @@
+--colour
+--format progress
+-fs
View
@@ -34,13 +34,14 @@ gem 'jquery-rails'
# gem 'ruby-debug19', :require => 'ruby-debug'
group :development, :test do
- # Required for Test::Unit support in Rake with ruby 1.9.x
- gem 'test-unit', :platforms => [:ruby_19]
+ gem 'rspec-rails'
+ #gem 'watchr'
end
group :test do
# Pretty printed test output
gem 'turn', '0.8.2', :require => false
+ gem 'database_cleaner'
end
group :production do
View
@@ -47,6 +47,8 @@ GEM
fssm (>= 0.2.7)
sass (~> 3.1)
daemons (1.1.8)
+ database_cleaner (0.7.2)
+ diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.3.0)
@@ -101,6 +103,19 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ rspec (2.9.0)
+ rspec-core (~> 2.9.0)
+ rspec-expectations (~> 2.9.0)
+ rspec-mocks (~> 2.9.0)
+ rspec-core (2.9.0)
+ rspec-expectations (2.9.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.9.0)
+ rspec-rails (2.9.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.9.0)
sass (3.1.15)
sass-rails (3.2.5)
railties (~> 3.2.0)
@@ -110,7 +125,6 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- test-unit (2.4.8)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
@@ -134,12 +148,13 @@ DEPENDENCIES
bson_ext (~> 1.6)
coffee-rails (~> 3.2.2)
compass (~> 0.12.alpha)
+ database_cleaner
httparty
jquery-rails
mongoid (~> 2.4)
rails (= 3.2.2)
+ rspec-rails
sass-rails (~> 3.2.4)
- test-unit
thin
turn (= 0.8.2)
uglifier (>= 1.2.3)
View
@@ -3,7 +3,7 @@
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
-require "rails/test_unit/railtie"
+#require "rails/test_unit/railtie"
require "sprockets/railtie"
if defined?(Bundler)
@@ -0,0 +1,19 @@
+require 'spec_helper'
+require 'dailymotion_api'
+
+describe DailymotionApi do
+
+ it "can retrieve an access token" do
+ response = DailymotionApi.get_token
+ response.code.should == 200
+
+ refresh_token = response["refresh_token"]
+ refresh_token.should_not be_empty
+
+ response = DailymotionApi.get_token(refresh_token)
+ response.code.should == 200
+
+ refresh_token.should == response["refresh_token"]
+ end
+
+end
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe Dailymotion do
+
+ it "can be instantiated only once" do
+ instance = Dailymotion.new
+
+ instance.should be_an_instance_of(Dailymotion)
+ instance.should == Dailymotion.new
+ instance.should == Dailymotion.get_instance
+
+ Dailymotion.count.should == 1
+ end
+
+ it "can be saved successfully" do
+ instance = Dailymotion.get_instance
+ instance.refresh_token = "blablabla"
+ instance.save.should == true
+
+ Dailymotion.new.refresh_token.should == "blablabla"
+ end
+
+ it "can store the refresh_token" do
+ refresh_token = Dailymotion.get_refresh_token
+ refresh_token.should be_nil
+
+ refresh_token = "hellotoken"
+ Dailymotion.save_refresh_token refresh_token
+
+ refresh_token = Dailymotion.get_refresh_token
+ refresh_token.should == "hellotoken"
+ end
+
+end
View
@@ -0,0 +1,44 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # ## Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ # config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+
+ # Clean up the database
+ require 'database_cleaner'
+ config.before(:suite) do
+ DatabaseCleaner.strategy = :truncation
+ DatabaseCleaner.orm = "mongoid"
+ end
+
+ config.before(:each) do
+ DatabaseCleaner.clean
+ end
+
+end
View
No changes.
View
No changes.
@@ -1,9 +0,0 @@
-require 'test_helper'
-
-class HomeControllerTest < ActionController::TestCase
- test "should get index" do
- get :index
- assert_response :success
- end
-
-end
No changes.
@@ -1,12 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-class BrowsingTest < ActionDispatch::PerformanceTest
- # Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
- # :output => 'tmp/performance', :formats => [:flat] }
-
- def test_homepage
- get '/'
- end
-end
View
@@ -1,14 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
-
- #fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
@@ -1,30 +0,0 @@
-require 'test_helper'
-
-class DailymotionApiTest < ActiveSupport::TestCase
-
- test "get_token" do
- Dailymotion.delete_all
-
- refresh_token = Dailymotion.get_refresh_token
- assert refresh_token == nil
-
- response = DailymotionApi.get_token(refresh_token)
- puts "body: #{response.body}"
-
- refresh_token = response["refresh_token"]
- Dailymotion.save_refresh_token refresh_token
-
- assert Dailymotion.get_refresh_token == refresh_token
-
- response = DailymotionApi.get_token(refresh_token)
- puts "body: #{response.body}"
-
- assert response["refresh_token"] == refresh_token
- end
-
-
- test "get_videos" do
- response = DailymotionApi.get_videos
- puts response.body
- end
-end
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class DailymotionTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
-end
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class HomeHelperTest < ActionView::TestCase
-end

0 comments on commit c71d91e

Please sign in to comment.