tags:

views:

13

answers:

0

How should I go about testing this helper with RSpec?

module ApplicationHelper
  def build_rpx_url(provider)
    signin_url(provider) << "?token_url=" << token_url << provider_params(provider)
  end


  private

  def signin_url(provider)
    case provider.downcase
    when 'facebook'; 'https://login.xyz.net/facebook/connect_start'
    when 'google';   'https://login.xyz.net/openid/start'
    when 'twitter';  'https://login.xyz.net/twitter/start'
    when 'linkedin'; 'https://login.xyz.net/linkedin/start'
    when 'yahoo';    'https://login.xyz.net/openid/start'
    end
  end

  def provider_params(provider)
    params = case provider.downcase
    when 'facebook'; ["ext_perm=publish_stream,email,offline_access"]
    when 'google';   ["openid_identifier=https://www.google.com/accounts/o8/id"]
    when 'twitter';  []
    when 'linkedin'; []
    when 'yahoo';    ["openid_identifier=http://me.yahoo.com/"]
    end

    params.empty? ? '' : "&" << params.join('&')
  end

  def token_url
    "#{new_user_session_url}?authenticity_token=#{Rack::Utils.escape(form_authenticity_token)}"
  end
end