Created
April 6, 2011 08:54
-
-
Save louisgillies/905358 to your computer and use it in GitHub Desktop.
helper method for testing omniauth strategies with Test::Unit and Shoulda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class OmniAuth::Strategies::MyAuthTest < Test::Unit::TestCase | |
it_should_behave_like_an_oauth_strategy | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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