integration_wrapper
DESCRIPTION:
Helps you test classes that normally use an Internet connection.
FEATURES/PROBLEMS:
Every method on a class is suffixed by _online and _offline. When you call a method ‘foo’, ‘foo_online’ or ‘foo_offline’ will be called, depending on the mode currently used.
SYNOPSIS:
# First, create a directory called 'online' in your 'test' dir which will contain your online tests.
# lib/internet_wrapper.rb
class InternetChecker < IntegrationWrapper::Base
def check_offline # for offline test, always assume check passes. true end
def check_online # for online test, do the actual interfacing to the # third party service. handle = open(‘www.google.com/’) # etc … end
end
# test/online/internet_checker_test.rb
class InternetCheckerTest < IntegrationWrapper::OnlineTest
def test_check
# this test is automatically executed in ONLINE mode # will invoke ‘check_online’ InternetChecker.new.check end
end
# test/unit/internet_checker_test.rb
class InternetCheckerTest < ActiveRecord::TestCase
def test_check
# this test is executed in OFFLINE mode # will invoke ‘check_offline’ InternetChecker.new.check end
end
REQUIREMENTS:
- Rails (Tested with 3.2.13)
INSTALL:
- sudo gem install integration_wrapper
LICENSE:
(The MIT License)
Copyright © 2012 Commander Johnson <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.