Sha256: 34e45ef22e739f1cd8c6e2ab7fcc0d6d76d9018f1482125336c13b529d287eb9

Contents?: true

Size: 1.93 KB

Versions: 8

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe Weeter::Configuration::TwitterConfig do
  %w{basic_auth oauth}.each do |setting|
    it "should accept setting for #{setting}" do
      Weeter.configure do |conf|
        conf.twitter do |app|
          app.send("#{setting}=", "testvalue")
        end
      end
      Weeter::Configuration::TwitterConfig.instance.send(setting).should == "testvalue"
    end
  end
  
  describe "auth_options" do
    
    before do
      Weeter::Configuration::TwitterConfig.instance.oauth = nil
      Weeter::Configuration::TwitterConfig.instance.basic_auth = nil
    end
    
    it "should return the oauth settings with a oauth credentials" do
      Weeter::Configuration::TwitterConfig.instance.oauth = {:consumer_key => 'consumer_key', :consumer_secret => 'consumer_secret', :access_key => 'acces_key', :access_secret => 'access_secret'}
      Weeter::Configuration::TwitterConfig.instance.auth_options.should == {:oauth => {:consumer_key => 'consumer_key', :consumer_secret => 'consumer_secret', :access_key => 'acces_key', :access_secret => 'access_secret'}}
    end
    
    it "should return the basic auth settings separated by a colon" do
      Weeter::Configuration::TwitterConfig.instance.basic_auth = {:username => "bob", :password => "s3cr3t"}
      Weeter::Configuration::TwitterConfig.instance.auth_options.should == {:auth => "bob:s3cr3t"}
    end
  
    it "should prefer oauth over basic auth" do
      Weeter::Configuration::TwitterConfig.instance.basic_auth = {:username => "bob", :password => "s3cr3t"}
      Weeter::Configuration::TwitterConfig.instance.oauth = {:consumer_key => 'consumer_key', :consumer_secret => 'consumer_secret', :access_key => 'acces_key', :access_secret => 'access_secret'}
      Weeter::Configuration::TwitterConfig.instance.auth_options.should == {:oauth => {:consumer_key => 'consumer_key', :consumer_secret => 'consumer_secret', :access_key => 'acces_key', :access_secret => 'access_secret'}}
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
weeter-0.15.0 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.14.0 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.13.0 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.11.0 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.10.0 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.9.2 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.9.1 spec/weeter/configuration/twitter_config_spec.rb
weeter-0.9.0 spec/weeter/configuration/twitter_config_spec.rb