Permalink
Browse files

Starting to build out tests with rspec

  • Loading branch information...
1 parent 7268b33 commit 236efd1907f936de621704c4a59bc47a769c22c1 @treeder treeder committed Dec 14, 2010
Showing with 49 additions and 47 deletions.
  1. +49 −47 test/test_mini_fb.rb
View
@@ -1,67 +1,69 @@
require 'test/unit'
+require 'rspec'
require 'uri'
require 'yaml'
require 'active_support/core_ext'
require '../lib/mini_fb'
-class MiniFBTests < Test::Unit::TestCase
+describe "Some Feature" do
-
- def setup
- @config = File.open(File.expand_path("~/.mini_fb_tests.yml")) { |yf| YAML::load(yf) }
- puts @config.inspect
+ before :all do
+ @is_setup = true
+ @config = File.open(File.expand_path("~/.test_configs/mini_fb_tests.yml")) { |yf| YAML::load(yf) }
+ puts "@config=" + @config.inspect
MiniFB.log_level = :debug
-# MiniFB.oauth_url(@config["fb_api_key"], @config["fb_secret"])
- end
-
- def teardown
-
- end
-
- def test_authenticate_as_app
- res = MiniFB.authenticate_as_app(@config["fb_api_key"], @config["fb_secret"])
- puts 'res=' + res.inspect
- assert res["access_token"].present?
- assert res["access_token"].starts_with?(@config["fb_app_id"].to_s)
- end
-
- # Test signature verification.
- def test_signature
-
+ @oauth_url = MiniFB.oauth_url(@config['fb_app_id'], # your Facebook App ID (NOT API_KEY)
+ "http://localhost:3000", # redirect url
+ :scope=>MiniFB.scopes.join(","))
+ puts "If you need an access token, go here in your browser:"
+ puts "#{@oauth_url}"
+ puts "Then grab the 'code' parameter in the redirect url and add it to mini_fb_tests.yml."
end
- def test_me_with_fields
- fields = {
- 'interests' => [:name],
- 'activities'=> [:name],
- 'music' => [:name],
- 'videos' => [:name],
- 'television'=> [:name],
- 'movies' => [:name],
- 'likes' => [:name],
- 'work' => [:name],
- 'education' => [:name],
- 'books' => [:name]
- }
- snap = MiniFB.get(access_token, 'me', :fields =>fields.keys)
- end
-
- def test_basic_calls
+ before :each do
+ # this code runs once per-test
end
- def test_session
-
+ it "should do something useful, rather than just being called test1" do
+ # el code here
+ puts 'whatup'
+ true.should be_true
end
- def test_photos
-
+ it 'test_uri_escape' do
+ URI.escape("x=y").should eq("x=y")
end
- def test_uri_escape
- assert URI.escape("x=y") == "x=y"
+ it 'test_authenticate_as_app' do
+ res = MiniFB.authenticate_as_app(@config["fb_api_key"], @config["fb_secret"])
+ puts 'res=' + res.inspect
+ res.should include("access_token")
+ res["access_token"].should match(/^#{@config['fb_app_id']}/)#starts_with?(@config["fb_app_id"].to_s)
end
-
-end
+end
+
+
+def access_token
+ @config['access_token']
+end
+
+
+def test_me_with_fields
+ fields = {
+ 'interests' => [:name],
+ 'activities'=> [:name],
+ 'music' => [:name],
+ 'videos' => [:name],
+ 'television'=> [:name],
+ 'movies' => [:name],
+ 'likes' => [:name],
+ 'work' => [:name],
+ 'education' => [:name],
+ 'books' => [:name]
+ }
+
+ snap = MiniFB.get(access_token, 'me', :fields =>fields.keys)
+end

0 comments on commit 236efd1

Please sign in to comment.