Permalink
Browse files

Testing in good shape

  • Loading branch information...
1 parent d00b4dc commit c0082ea269a0a6c22d9416cf3a1ee86a5c64ca3e @victorcoder victorcoder committed Jul 17, 2011
Showing with 46 additions and 13 deletions.
  1. +2 −2 Rakefile
  2. +18 −5 test/middleware_test.rb
  3. +8 −0 test/test_helper.rb
  4. +18 −6 test/view_helpers/facebook_helpers_test.rb
View
@@ -3,11 +3,11 @@ Bundler::GemHelper.install_tasks
require 'rubygems'
require 'rake/testtask'
-require 'rake/rdoctask'
+#require 'rdoc/task'
task :default => :test
-desc 'Test the typus plugin.'
+desc 'Test the gem.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
View
@@ -4,15 +4,28 @@ class TestEukaliptus < MiniTest::Unit::TestCase
include Rack::Test::Methods
def app
- Eukaliptus::Middleware.new
+ Eukaliptus::Middleware.new(lambda { |env| [200, {}, "Coolness"] })
end
- def test_eukaliptus_headers
- skip "Test P3p header"
+ def test_respond_p3p_headers
+ get '/cookie_fix'
+ assert_equal last_response["P3P"], 'CP="HONK HONK! http://graeme.per.ly/p3p-policies-are-a-joke"'
end
- def test_rack_request_params
+ def test_should_redirect
get '/cookie_fix'
- assert_equal "http://example.org/cookie_fix", last_request.url
+ assert last_response.redirect?
+ end
+
+ def test_should_redirect_to_param
+ get '/cookie_fix', :redirect_to => '/somewhere'
+ assert_equal last_response['Location'], '/somewhere'
+ end
+
+ def test_should_respond_with_cookie
+ get '/cookie_fix', :redirect_to => '/'
+
+ assert_instance_of String, last_response.body
+ assert_equal 'Cookie Setted', last_response.body
end
end
View
@@ -1,13 +1,21 @@
ENV["RAILS_ENV"] = "test"
+gem 'minitest'
+require 'minitest/autorun'
require 'minitest/unit'
require 'minitest/spec'
+require 'minitest/pride'
require 'rack/test'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rails'
require 'eukaliptus'
+require 'eukaliptus/view_helpers/facebook_helpers'
+
+module ::Facebook
+ APP_ID = '123456'
+end
MiniTest::Unit.autorun
@@ -1,10 +1,22 @@
require 'test_helper'
-describe "Eukaliptus::FacebookHelpersTest" do
- describe "when asked about a helper" do
- it "must respond positively" do
- skip "Possitive"
- end
- end
+class FacebookHelpersTest < MiniTest::Spec
+
+ include Eukaliptus::FacebookHelpers
+
+ before do
+ require 'erubis'
+ require 'active_support/core_ext/string/output_safety'
+ end
+
+ it "should_raise_exception_with_fb_login" do
+ assert_raises RuntimeError do
+ fb_login
+ end
+ end
+
+ it "should_return_fb_init_js" do
+ assert_instance_of ActiveSupport::SafeBuffer, fb_init
+ end
end

0 comments on commit c0082ea

Please sign in to comment.