Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add some tests.

  • Loading branch information...
commit 279dde338b54fb855f14394e5c34dcbc236bd682 1 parent 1b2022e
pivotal-sumuru authored
8 .gitignore
@@ -40,3 +40,11 @@ pkg
40 40 #
41 41 # For vim:
42 42 #*.swp
  43 +.idea/.name
  44 +.idea/.rakeTasks
  45 +.idea/encodings.xml
  46 +.idea/misc.xml
  47 +.idea/modules.xml
  48 +.idea/rack-facebook-method-fix.iml
  49 +.idea/vcs.xml
  50 +.idea/workspace.xml
3  Gemfile
@@ -10,4 +10,7 @@ group :development do
10 10 gem "bundler", "~> 1.0.0"
11 11 gem "jeweler", "~> 1.5.2"
12 12 gem "rcov", ">= 0"
  13 + gem "json"
  14 + gem "rspec"
  15 + gem "rack-test"
13 16 end
16 Gemfile.lock
... ... @@ -1,13 +1,26 @@
1 1 GEM
2 2 remote: http://rubygems.org/
3 3 specs:
  4 + diff-lcs (1.1.2)
4 5 git (1.2.5)
5 6 jeweler (1.5.2)
6 7 bundler (~> 1.0.0)
7 8 git (>= 1.2.5)
8 9 rake
  10 + json (1.5.3)
  11 + rack (1.3.0)
  12 + rack-test (0.6.0)
  13 + rack (>= 1.0)
9 14 rake (0.8.7)
10 15 rcov (0.9.9)
  16 + rspec (2.6.0)
  17 + rspec-core (~> 2.6.0)
  18 + rspec-expectations (~> 2.6.0)
  19 + rspec-mocks (~> 2.6.0)
  20 + rspec-core (2.6.4)
  21 + rspec-expectations (2.6.0)
  22 + diff-lcs (~> 1.1.2)
  23 + rspec-mocks (2.6.0)
11 24 shoulda (2.11.3)
12 25
13 26 PLATFORMS
@@ -16,5 +29,8 @@ PLATFORMS
16 29 DEPENDENCIES
17 30 bundler (~> 1.0.0)
18 31 jeweler (~> 1.5.2)
  32 + json
  33 + rack-test
19 34 rcov
  35 + rspec
20 36 shoulda
44 spec/rack/facebook/method_fix_spec.rb
... ... @@ -0,0 +1,44 @@
  1 +require File.expand_path('spec_helper', File.join(File.dirname(__FILE__), '../../'))
  2 +
  3 +
  4 +class MockRackWrapper
  5 + def initialize(response)
  6 + @response = response
  7 + end
  8 +
  9 + def call(env)
  10 + @env = env
  11 + @response
  12 + end
  13 +
  14 + def env
  15 + @env
  16 + end
  17 +end
  18 +
  19 +describe Rack::Facebook::MethodFix do
  20 + context "with no exclusions" do
  21 + before do
  22 + header = [200, {"Content-type" => "test/plain", "Content-length" => "5"}, ["foo"]]
  23 + @rack_mock = MockRackWrapper.new(header)
  24 + facebook = Rack::Facebook::MethodFix.new(@rack_mock)
  25 + @request = Rack::MockRequest.new(facebook)
  26 + end
  27 +
  28 + context "POST requests not from facebook" do
  29 + it 'should stay as a POST' do
  30 + @request.post("/", {})
  31 +
  32 + @rack_mock.env["REQUEST_METHOD"].should == "POST"
  33 + end
  34 + end
  35 +
  36 + context 'POST requests from facebook' do
  37 + it 'should be changed to GET requests' do
  38 + @request.post("/", {:params => {"signed_request" => 'nothing'}})
  39 +
  40 + @rack_mock.env["REQUEST_METHOD"].should == "GET"
  41 + end
  42 + end
  43 + end
  44 +end
5 spec/spec_helper.rb
... ... @@ -0,0 +1,5 @@
  1 +require 'rubygems'
  2 +require 'bundler/setup'
  3 +require 'rack/test'
  4 +require 'rack/mock'
  5 +require File.expand_path('../../lib/rack-facebook-method-fix', __FILE__)
18 test/helper.rb
... ... @@ -1,18 +0,0 @@
1   -require 'rubygems'
2   -require 'bundler'
3   -begin
4   - Bundler.setup(:default, :development)
5   -rescue Bundler::BundlerError => e
6   - $stderr.puts e.message
7   - $stderr.puts "Run `bundle install` to install missing gems"
8   - exit e.status_code
9   -end
10   -require 'test/unit'
11   -require 'shoulda'
12   -
13   -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14   -$LOAD_PATH.unshift(File.dirname(__FILE__))
15   -require 'rack-facebook-method-fix'
16   -
17   -class Test::Unit::TestCase
18   -end
7 test/test_rack-facebook-method-fix.rb
... ... @@ -1,7 +0,0 @@
1   -require 'helper'
2   -
3   -class TestRackFacebookMethodFix < Test::Unit::TestCase
4   - should "probably rename this file and start testing for real" do
5   - flunk "hey buddy, you should probably rename this file and start testing for real"
6   - end
7   -end

0 comments on commit 279dde3

Please sign in to comment.
Something went wrong with that request. Please try again.