<commit_before>require 'spec_helper'

include Trello
include Trello::Authorization

describe Trello do

  describe 'self.configure' do
    it 'builds auth policy client uses to make requests' do
      Trello.configure do |config|
        config.developer_public_key = 'developer_public_key'
        config.member_token         = 'member_<PASSWORD>'
      end

      TInternet.stub(:execute)
      Trello.auth_policy.should_receive(:authorize)
      Trello.client.get(:member, params = {})
    end

    it 'configures basic auth policy' do
      Trello.configure do |config|
        config.developer_public_key = 'developer_public_key'
        config.member_token         = 'member_token'
      end

      auth_policy = Trello.auth_policy
      auth_policy.should be_a(BasicAuthPolicy)
      auth_policy.developer_public_key.should eq('developer_public_key')
      auth_policy.member_token.should eq('member_token')
    end

    context 'oauth' do
      before do
        Trello.configure do |config|
          config.consumer_key     = 'consumer_key'
          config.consumer_secret  = 'consumer_secret'
          config.oauth_token      = 'oauth_token'
          config.oauth_token_secret     = 'oauth_token_secret'
        end
      end

      it 'configures oauth policy' do
        auth_policy = Trello.auth_policy

        auth_policy.should be_a(OAuthPolicy)
        auth_policy.consumer_key.should eq('consumer_key')
        auth_policy.consumer_secret.should eq('consumer_secret')
        auth_policy.oauth_token.should eq('oauth_token')
        auth_policy.oauth_token_secret.should eq('oauth_token_secret')
      end

      it 'updates auth policy configuration' do
        auth_policy = Trello.auth_policy
        auth_policy.consumer_key.should eq('consumer_key')

        Trello.configure do |config|
          config.consumer_key     = 'new_consumer_key'
          config.consumer_secret  = 'new_consumer_secret'
          config.oauth_token      = 'new_oauth_token'
          config.oauth_token_secret     = nil
        end

        auth_policy = Trello.auth_policy

        auth_policy.should be_a(OAuthPolicy)
        auth_policy.consumer_key.should eq('new_consumer_key')
        auth_policy.consumer_secret.should eq('new_consumer_secret')
        auth_policy.oauth_token.should eq('new_oauth_token')
        auth_policy.oauth_token_secret.should be_nil
      end
    end

    context 'not configured' do
      before do
        Trello.configure
      end

      it { Trello.auth_policy.should be_a(AuthPolicy) }
      it { expect { Trello.client.get(:member) }.to raise_error(Trello::ConfigurationError) }
    end

  end
end<commit_msg>Migrate spec/trello_spec.rb to `expect` syntax<commit_after>require 'spec_helper'

include Trello
include Trello::Authorization

describe Trello do

  describe 'self.configure' do
    before do
      Trello.configure do |config|
        config.developer_public_key = 'developer_public_key'
        config.member_token         = 'member_token'
      end
    end

    it 'builds auth policy client uses to make requests' do
      TInternet.stub(:execute)
      expect(Trello.auth_policy).to receive(:authorize)
      Trello.client.get(:member, params = {})
    end

    it 'configures basic auth policy' do
      auth_policy = Trello.auth_policy
      expect(auth_policy).to be_a(BasicAuthPolicy)
      expect(auth_policy.developer_public_key).to eq('developer_public_key')
      expect(auth_policy.member_token).to eq('member_token')
    end

    context 'oauth' do
      before do
        Trello.configure do |config|
          config.consumer_key     = 'consumer_key'
          config.consumer_secret  = 'consumer_secret'
          config.oauth_token      = 'oauth_token'
          config.oauth_token_secret     = 'oauth_token_secret'
        end
      end

      it 'configures oauth policy' do
        auth_policy = Trello.auth_policy

        expect(auth_policy).to be_a(OAuthPolicy)
        expect(auth_policy.consumer_key).to eq('consumer_key')
        expect(auth_policy.consumer_secret).to eq('consumer_secret')
        expect(auth_policy.oauth_token).to eq('oauth_token')
        expect(auth_policy.oauth_token_secret).to eq('oauth_token_secret')
      end

      it 'updates auth policy configuration' do
        auth_policy = Trello.auth_policy
        expect(auth_policy.consumer_key).to eq('consumer_key')

        Trello.configure do |config|
          config.consumer_key     = 'new_consumer_key'
          config.consumer_secret  = 'new_consumer_secret'
          config.oauth_token      = '<PASSWORD>'
          config.oauth_token_secret     = nil
        end

        auth_policy = Trello.auth_policy

        expect(auth_policy).to be_a(OAuthPolicy)
        expect(auth_policy.consumer_key).to eq('new_consumer_key')
        expect(auth_policy.consumer_secret).to eq('new_consumer_secret')
        expect(auth_policy.oauth_token).to eq('new_oauth_token')
        expect(auth_policy.oauth_token_secret).to be_nil
      end
    end

    context 'not configured' do
      before do
        Trello.configure
      end

      it { expect(Trello.auth_policy).to be_a(AuthPolicy) }
      it { expect { Trello.client.get(:member) }.to raise_error(Trello::ConfigurationError) }
    end

  end
end
{'fraction_non_alphanumeric': 0.08075242257267717, 'fraction_numerical': 0.0, 'mean_word_length': 2.7680744452397996, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2839050', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1581, 'n_words': 297}