integration_wrapper 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +12 -0
- data/README.rdoc +82 -0
- data/Rakefile +25 -0
- data/header.txt +6 -0
- data/lib/integration_wrapper/base.rb +48 -0
- data/lib/integration_wrapper.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_helper.rb +3 -0
- data/test/test_integration_wrapper.rb +6 -0
- metadata +128 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
= integration_wrapper
|
2
|
+
|
3
|
+
* http://github.com/cmdjohnson/integration_wrapper
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Helps you test classes that normally use an Internet connection.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Every method on a class is suffixed by _online and _offline.
|
12
|
+
When you call a method 'foo', 'foo_online' or 'foo_offline' will be called,
|
13
|
+
depending on the mode currently used.
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
# First, create a directory called 'test_online' which will contain your online tests.
|
17
|
+
|
18
|
+
# lib/internet_wrapper.rb
|
19
|
+
class InternetChecker < IntegrationWrapper::Base
|
20
|
+
def check_offline
|
21
|
+
# for offline test, always assume check passes.
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_online
|
26
|
+
# for online test, do the actual interfacing to the
|
27
|
+
# third party service.
|
28
|
+
handle = open('http://www.google.com/')
|
29
|
+
# etc ...
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# test/online/internet_checker_test.rb
|
34
|
+
class InternetCheckerTest < IntegrationWrapper::OnlineTest
|
35
|
+
def test_check
|
36
|
+
# this test is automatically executed in ONLINE mode
|
37
|
+
# will invoke 'check_online'
|
38
|
+
InternetChecker.new.check
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# test/unit/internet_checker_test.rb
|
43
|
+
class InternetCheckerTest < ActiveRecord::TestCase
|
44
|
+
def test_check
|
45
|
+
# this test is executed in OFFLINE mode
|
46
|
+
# will invoke 'check_offline'
|
47
|
+
InternetChecker.new.check
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
== REQUIREMENTS:
|
52
|
+
|
53
|
+
- Rails (Tested with 2.3.14)
|
54
|
+
|
55
|
+
== INSTALL:
|
56
|
+
|
57
|
+
- sudo gem install integration_wrapper
|
58
|
+
|
59
|
+
== LICENSE:
|
60
|
+
|
61
|
+
(The MIT License)
|
62
|
+
|
63
|
+
Copyright (c) 2012 Commander Johnson <commanderjohnson@gmail.com>
|
64
|
+
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
66
|
+
a copy of this software and associated documentation files (the
|
67
|
+
'Software'), to deal in the Software without restriction, including
|
68
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
69
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
70
|
+
permit persons to whom the Software is furnished to do so, subject to
|
71
|
+
the following conditions:
|
72
|
+
|
73
|
+
The above copyright notice and this permission notice shall be
|
74
|
+
included in all copies or substantial portions of the Software.
|
75
|
+
|
76
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
77
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
78
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
79
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
80
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
81
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
82
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/integration_wrapper'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'integration_wrapper' do
|
14
|
+
self.developer 'Commander Johnson', 'commanderjohnson@gmail.com'
|
15
|
+
self.rubyforge_name = self.name # TODO this is default value
|
16
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'newgem/tasks'
|
21
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
+
|
23
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
+
# remove_task :default
|
25
|
+
# task :default => [:spec, :features]
|
data/header.txt
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
3
|
+
# Licensed under the MIT License
|
4
|
+
# Year: 2012
|
5
|
+
###############################################################################
|
6
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Wrapper that can be used to still properly test online integration with 3rd party tools such as Amazon S3.
|
2
|
+
module IntegrationWrapper
|
3
|
+
class Base
|
4
|
+
################################################################################
|
5
|
+
# 2 modes
|
6
|
+
################################################################################
|
7
|
+
MODE_ONLINE = "online"
|
8
|
+
MODE_OFFLINE = "offline"
|
9
|
+
|
10
|
+
################################################################################
|
11
|
+
# class methods
|
12
|
+
################################################################################
|
13
|
+
|
14
|
+
@@mode = RAILS_ENV.eql?("production") ? MODE_ONLINE : MODE_OFFLINE
|
15
|
+
|
16
|
+
def initialize(params = {})
|
17
|
+
#@mode = RAILS_ENV.eql?("production") ? MODE_ONLINE : MODE_OFFLINE
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.mode
|
21
|
+
@@mode
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.mode= thing
|
25
|
+
raise "Mode must be MODE_ONLINE or MODE_OFFLINE" unless thing.eql?(MODE_ONLINE) || thing.eql?(MODE_OFFLINE)
|
26
|
+
@@mode = thing
|
27
|
+
end
|
28
|
+
|
29
|
+
# If an action comes in, say :foo, then call the foo_online class method if mode is online, and foo_offline if mode is offline.
|
30
|
+
# def self.perform_action action_name, options = {}
|
31
|
+
# self.send("#{action_name}_#{@@mode}", options)
|
32
|
+
# end
|
33
|
+
|
34
|
+
def method_missing sym, *args, &block
|
35
|
+
# First check if the method we're trying to call is available.
|
36
|
+
name = "#{sym}_#{@@mode}"
|
37
|
+
# Now send
|
38
|
+
begin
|
39
|
+
self.send name, *args, &block
|
40
|
+
rescue NoMethodError => e
|
41
|
+
puts "Error trying to call method #{name}. Maybe you forgot to add it? I need all methods to be suffixed with either #{IntegrationWrapper::MODE_ONLINE} or #{IntegrationWrapper::MODE_OFFLINE}. Example: foo_online. Methods: #{methods.inspect}. Error was: #{e}."
|
42
|
+
puts "Trace:"
|
43
|
+
puts e.backtrace
|
44
|
+
raise e
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/integration_wrapper.rb'}"
|
9
|
+
puts "Loading integration_wrapper gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: integration_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Commander Johnson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-09-28 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rdoc
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 19
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 10
|
32
|
+
version: "3.10"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: newgem
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 5
|
47
|
+
- 3
|
48
|
+
version: 1.5.3
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: hoe
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 5
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 1
|
63
|
+
version: "3.1"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
description: Helps you test classes that normally use an Internet connection.
|
67
|
+
email:
|
68
|
+
- commanderjohnson@gmail.com
|
69
|
+
executables: []
|
70
|
+
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- History.txt
|
75
|
+
- Manifest.txt
|
76
|
+
- README.rdoc
|
77
|
+
- header.txt
|
78
|
+
files:
|
79
|
+
- History.txt
|
80
|
+
- Manifest.txt
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- header.txt
|
84
|
+
- lib/integration_wrapper.rb
|
85
|
+
- lib/integration_wrapper/base.rb
|
86
|
+
- script/console
|
87
|
+
- script/destroy
|
88
|
+
- script/generate
|
89
|
+
- test/test_helper.rb
|
90
|
+
- test/test_integration_wrapper.rb
|
91
|
+
- .gemtest
|
92
|
+
homepage: http://github.com/cmdjohnson/integration_wrapper
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --main
|
98
|
+
- README.rdoc
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: integration_wrapper
|
122
|
+
rubygems_version: 1.8.24
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Helps you test classes that normally use an Internet connection.
|
126
|
+
test_files:
|
127
|
+
- test/test_helper.rb
|
128
|
+
- test/test_integration_wrapper.rb
|