Sha256: 060cab247079633593e37734ac98bce359eecd80632a1ff589a7387995043f48

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

require "spec_helper"
require "omnicontacts/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

8 entries across 8 versions & 1 rubygems

Version Path
omnicontacts-0.3.7 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.6 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.5 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.4 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.3 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.2 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.1 spec/omnicontacts/integration_test_spec.rb
omnicontacts-0.3.0 spec/omnicontacts/integration_test_spec.rb