Class: IntegrationTest
- Inherits:
-
Object
- Object
- IntegrationTest
- Includes:
- Singleton
- Defined in:
- lib/omnicontacts/integration_test.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
Instance Method Summary collapse
- #clear_mocks ⇒ Object
-
#initialize ⇒ IntegrationTest
constructor
A new instance of IntegrationTest.
- #mock(provider, contacts, user = {}) ⇒ Object
- #mock_authorization_from_user(provider) ⇒ Object
- #mock_fetch_contacts(provider) ⇒ Object
- #mock_fetch_user(provider) ⇒ Object
Constructor Details
#initialize ⇒ IntegrationTest
Returns a new instance of IntegrationTest.
8 9 10 11 |
# File 'lib/omnicontacts/integration_test.rb', line 8 def initialize enabled = false clear_mocks end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
6 7 8 |
# File 'lib/omnicontacts/integration_test.rb', line 6 def enabled @enabled end |
Instance Method Details
#clear_mocks ⇒ Object
13 14 15 16 |
# File 'lib/omnicontacts/integration_test.rb', line 13 def clear_mocks @user_mocks = {} @contact_mocks = {} end |
#mock(provider, contacts, user = {}) ⇒ Object
18 19 20 21 |
# File 'lib/omnicontacts/integration_test.rb', line 18 def mock provider, contacts, user = {} @contact_mocks[provider.to_sym] = contacts @user_mocks[provider.to_sym] = user end |
#mock_authorization_from_user(provider) ⇒ Object
23 24 25 |
# File 'lib/omnicontacts/integration_test.rb', line 23 def provider [302, {"Content-Type" => "application/x-www-form-urlencoded", "location" => provider.redirect_path}, []] end |
#mock_fetch_contacts(provider) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/omnicontacts/integration_test.rb', line 27 def mock_fetch_contacts provider result = @contact_mocks[provider.class_name.to_sym] || [] if result.is_a? Array result elsif result.is_a? Hash [result] else raise result.to_s end end |
#mock_fetch_user(provider) ⇒ Object
38 39 40 |
# File 'lib/omnicontacts/integration_test.rb', line 38 def mock_fetch_user provider @user_mocks[provider.class_name.to_sym] || {} end |