Sha256: 5784f76760e9d25a5704e9e44a311aa0af39dad721fff68f91d361a9b6da3522

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require "spec_helper"
require "omnigroupcontacts/integration_test"

describe IntegrationTest do

  context "mock_initial_request" do
    it "should redirect to the provider's redirect_path" do
      provider = mock
      redirect_path = "/redirect_path"
      provider.stub(:redirect_path => redirect_path)
      IntegrationTest.instance.mock_authorization_from_user(provider)[1]["location"].should eq(redirect_path)
    end
  end
  
  context "mock_callback" do

    before(:each) {
      @env = {}
      @provider = self.mock
      @provider.stub(:class_name => "test")
      IntegrationTest.instance.clear_mocks
    }
    
    it "should return an empty contacts list" do
      IntegrationTest.instance.mock_fetch_contacts(@provider).should be_empty
    end
    
    it "should return a configured list of contacts " do
      contacts = [:name => 'John Doe', :email => 'john@doe.com']
      IntegrationTest.instance.mock('test', contacts)
      result = IntegrationTest.instance.mock_fetch_contacts(@provider)
      result.size.should be(1)
      result.first[:email].should eq(contacts.first[:email])
      result.first[:name].should eq(contacts.first[:name])
    end

    it "should return a single element list of contacts " do
      contact = {:name => 'John Doe', :email => 'john@doe.com'}
      IntegrationTest.instance.mock('test', contact)
      result = IntegrationTest.instance.mock_fetch_contacts(@provider)
      result.size.should be(1)
      result.first[:email].should eq(contact[:email])
      result.first[:name].should eq(contact[:name])
    end
    
    it "should throw an exception" do
      IntegrationTest.instance.mock('test', :some_error)
      expect {IntegrationTest.instance.mock_fetch_contacts(@provider)}.to raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omnigroupcontacts-0.3.11 spec/omnicontacts/integration_test_spec.rb