-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use explicit stubs instead of recorded responses
never really worked out the way I thought it would
- Loading branch information
Showing
11 changed files
with
14 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,10 @@ | |
|
||
require 'podio' | ||
|
||
ENABLE_STUBS = ENV['ENABLE_STUBS'] == 'true' | ||
ENABLE_RECORD = ENV['ENABLE_RECORD'] == 'true' | ||
|
||
class Test::Unit::TestCase | ||
|
||
def setup | ||
set_podio_client | ||
stub_responses if ENABLE_STUBS | ||
end | ||
|
||
# test "verify something" do | ||
|
@@ -33,8 +29,7 @@ def set_podio_client | |
:api_url => 'http://api-sandbox.podio.dev', | ||
:api_key => '[email protected]', | ||
:api_secret => 'sandbox_secret', | ||
:enable_stubs => ENABLE_STUBS && !ENABLE_RECORD, | ||
:record_mode => ENABLE_RECORD, | ||
:enable_stubs => true, | ||
:test_mode => true | ||
) | ||
end | ||
|
@@ -47,24 +42,6 @@ def login_as(user_identifier) | |
Podio.client.reset | ||
end | ||
|
||
def stub_responses | ||
folder_name = self.class.name.underscore.gsub('_test', '') | ||
current_folder = File.join(File.dirname(__FILE__), 'fixtures', folder_name) | ||
|
||
if File.exists?(current_folder) | ||
Dir.foreach(current_folder) do |filename| | ||
next unless filename.include?('.rack') | ||
|
||
rack_response = eval(File.read(File.join(current_folder, filename))) | ||
|
||
url = rack_response.shift | ||
method = rack_response.shift | ||
|
||
Podio.client.stubs.send(method, url) { rack_response } | ||
end | ||
end | ||
end | ||
|
||
def fixtures | ||
@fixtures ||= YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'fixtures.yaml')) | ||
end | ||
|