Skip to content

kurbaitis/adapter-pattern-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

adapter-pattern-example

In config/environments/test.rb

config.google_adapter = Google::Fake.new

In config/environments/production.rb

config.google_adapter = Google::Api.new(ENV.fetch('GOOGLE_CLIENT_ID'), ENV.fetch('GOOGLE_CLIENT_SECRET'))

Usage

documents = Adapter.google.get_documents('_USER TOKEN_')

if documents.success == true
  puts 'Here are your documents'
  puts documents.data.inspect
else
  puts 'Error!'
  puts documents.errors.inspect
end

Benefits

  1. Possible to use across app test environment just fake adapter and avoid HTTP connection, however need to make sure, that Api and Fake adapters are in sync with their interface.
  2. Isolated testing of the real adapter Api
  3. Avoid mocking in the tests easier

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages