Sha256: 22f4b9e0c618effb39a17425ab2b0e7b650f85d1087f1143e1b247ca9104cbf3

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'
require 'survey_gizmo/configuration'

describe SurveyGizmo::Configuration do
  before(:each) do
    SurveyGizmo.configure do |config|
      config.api_token = 'token'
      config.api_token_secret = 'doken'
    end
  end

  after(:each) do
    SurveyGizmo.reset!
  end

  it 'should allow changing user and pass' do
    # preload connection to verify that memoization is purged
    SurveyGizmo::Connection.send(:connection)

    SurveyGizmo.configure do |config|
      config.api_token = 'slimthug'
      config.api_token_secret = 'fourfourz'
    end

    expect(SurveyGizmo::Connection.send(:connection).params).to eq('api_token' => 'slimthug', 'api_token_secret' => 'fourfourz')
  end

  describe '#region=' do
    it 'should set US region by default' do
      SurveyGizmo.configure
      expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.com')
      expect(SurveyGizmo.configuration.api_time_zone).to eq('Eastern Time (US & Canada)')
    end

    it 'should set US region with :us symbol specified' do
      SurveyGizmo.configure do |config|
        config.region = :us
      end

      expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.com')
      expect(SurveyGizmo.configuration.api_time_zone).to eq('Eastern Time (US & Canada)')
    end

    it 'should set EU region with :eu symbol specified' do
      SurveyGizmo.configure do |config|
        config.region = :eu
      end

      expect(SurveyGizmo.configuration.api_url).to eq('https://restapi.surveygizmo.eu')
      expect(SurveyGizmo.configuration.api_time_zone).to eq('Berlin')
    end

    it 'should fail with an unavailable region' do
      expect {
        SurveyGizmo.configure do |config|
          config.region = :cz
        end
      }.to raise_error
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
survey-gizmo-ruby-6.5.0 spec/configuration_spec.rb
survey-gizmo-ruby-6.4.1 spec/configuration_spec.rb
survey-gizmo-ruby-6.4.0 spec/configuration_spec.rb
survey-gizmo-ruby-6.3.2 spec/configuration_spec.rb
survey-gizmo-ruby-6.3.1 spec/configuration_spec.rb
survey-gizmo-ruby-6.3.0 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.13 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.12 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.11 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.10 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.9 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.6 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.5 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.4 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.3 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.2 spec/configuration_spec.rb
survey-gizmo-ruby-6.2.0 spec/configuration_spec.rb
survey-gizmo-ruby-6.1.3 spec/configuration_spec.rb