Skip to content

Instantly share code, notes, and snippets.

@louisgillies
Created April 6, 2011 08:54
Show Gist options
  • Save louisgillies/905358 to your computer and use it in GitHub Desktop.
Save louisgillies/905358 to your computer and use it in GitHub Desktop.
helper method for testing omniauth strategies with Test::Unit and Shoulda
require 'test_helper'
class OmniAuth::Strategies::MyAuthTest < Test::Unit::TestCase
it_should_behave_like_an_oauth_strategy
end
# Add this into your test_helper.rb file.
class Test::Unit::TestCase
def strategy_class
self.class.name.gsub("Test", "").constantize
end
def self.it_should_behave_like_an_oauth_strategy()
should "be initializable with only three arguments" do
assert_nothing_raised do
strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret')
end
end
should 'be initializable with a block' do
assert_nothing_raised do
strategy_class.new( lambda{|env| [200, {}, ['Hello World']]}){|s| s.consumer_key = 'abc'}
end
end
should 'handle the setting of client options' do
s = strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret', :client_options => {:abc => 'def'})
assert s.consumer.options[:abc] == 'def'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment