integration_wrapper 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/lib/integration_wrapper.rb +12 -1
- data/lib/integration_wrapper/base.rb +11 -2
- data/lib/integration_wrapper/online_test.rb +52 -0
- data/test/test_helper.rb +9 -0
- data/test/test_integration_wrapper.rb +9 -0
- metadata +60 -73
data/Manifest.txt
CHANGED
data/lib/integration_wrapper.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# -- begin header --
|
3
|
+
###############################################################################
|
4
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
5
|
+
# Licensed under the MIT License
|
6
|
+
# Year: 2012
|
7
|
+
###############################################################################
|
8
|
+
|
9
|
+
# -- end header --
|
1
10
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
11
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
12
|
|
4
13
|
module IntegrationWrapper
|
5
|
-
VERSION = '0.0.
|
14
|
+
VERSION = '0.0.2'
|
6
15
|
end
|
16
|
+
|
17
|
+
require 'integration_wrapper/base' if defined?(Rails)
|
@@ -1,3 +1,12 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# -- begin header --
|
3
|
+
###############################################################################
|
4
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
5
|
+
# Licensed under the MIT License
|
6
|
+
# Year: 2012
|
7
|
+
###############################################################################
|
8
|
+
|
9
|
+
# -- end header --
|
1
10
|
# Wrapper that can be used to still properly test online integration with 3rd party tools such as Amazon S3.
|
2
11
|
module IntegrationWrapper
|
3
12
|
class Base
|
@@ -11,10 +20,10 @@ module IntegrationWrapper
|
|
11
20
|
# class methods
|
12
21
|
################################################################################
|
13
22
|
|
14
|
-
@@mode =
|
23
|
+
@@mode = Rails.env.eql?("production") ? MODE_ONLINE : MODE_OFFLINE
|
15
24
|
|
16
25
|
def initialize(params = {})
|
17
|
-
#@mode =
|
26
|
+
#@mode = Rails.env.eql?("production") ? MODE_ONLINE : MODE_OFFLINE
|
18
27
|
end
|
19
28
|
|
20
29
|
def self.mode
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# -- begin header --
|
3
|
+
###############################################################################
|
4
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
5
|
+
# Licensed under the MIT License
|
6
|
+
# Year: 2012
|
7
|
+
###############################################################################
|
8
|
+
|
9
|
+
# -- end header --
|
10
|
+
require 'test_helper'
|
11
|
+
|
12
|
+
# Nifty class that helps you do online integration tests (e.g. FooTest < OnlineTest)
|
13
|
+
# An online integration test is an integration test that uses your Internet connection
|
14
|
+
# to communicate with third party APIs.
|
15
|
+
# Of course, this integration needs to be tested (this is very important!)
|
16
|
+
# Use the switch_to_online_and back method to test your functionality in the 'online' mode
|
17
|
+
# which will also be used in production when the app is live.
|
18
|
+
# e.g.
|
19
|
+
# def test_my_function
|
20
|
+
# switch_to_online_and_back do
|
21
|
+
# # do stuff here ...
|
22
|
+
# # do more stuff here ...
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# Works in conjunction with IntegrationWrapper, the nifty class that gives you
|
27
|
+
# two kinds of methods, viz. online and offline methods.
|
28
|
+
#
|
29
|
+
# Use the rake task 'test:online' to execute all the test files in the tests_online directory.
|
30
|
+
|
31
|
+
module IntegrationWrapper
|
32
|
+
class OnlineTest < ActiveRecord::TestCase
|
33
|
+
# Switch to online and back. Supplanted by the setup and teardown methods.
|
34
|
+
def switch_to_online_and_back
|
35
|
+
# Go to online
|
36
|
+
IntegrationWrapper.mode = IntegrationWrapper::MODE_ONLINE
|
37
|
+
# yield
|
38
|
+
yield
|
39
|
+
# Set it back to offline because other tests will be using this as well.
|
40
|
+
IntegrationWrapper.mode = IntegrationWrapper::MODE_OFFLINE
|
41
|
+
end
|
42
|
+
|
43
|
+
def setup
|
44
|
+
IntegrationWrapper.mode = IntegrationWrapper::MODE_ONLINE
|
45
|
+
end
|
46
|
+
|
47
|
+
def teardown
|
48
|
+
IntegrationWrapper.mode = IntegrationWrapper::MODE_OFFLINE
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# -- begin header --
|
3
|
+
###############################################################################
|
4
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
5
|
+
# Licensed under the MIT License
|
6
|
+
# Year: 2012
|
7
|
+
###############################################################################
|
8
|
+
|
9
|
+
# -- end header --
|
1
10
|
require 'stringio'
|
2
11
|
require 'test/unit'
|
3
12
|
require File.dirname(__FILE__) + '/../lib/integration_wrapper'
|
@@ -1,3 +1,12 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# -- begin header --
|
3
|
+
###############################################################################
|
4
|
+
# Author: Commander Johnson <commanderjohnson@gmail.com>
|
5
|
+
# Licensed under the MIT License
|
6
|
+
# Year: 2012
|
7
|
+
###############################################################################
|
8
|
+
|
9
|
+
# -- end header --
|
1
10
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
11
|
|
3
12
|
class TestIntegrationWrapper < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,81 +1,75 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: integration_wrapper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Commander Johnson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rdoc
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 10
|
32
|
-
version: "3.10"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.10'
|
33
22
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: newgem
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: newgem
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
48
37
|
version: 1.5.3
|
49
38
|
type: :development
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: hoe
|
53
39
|
prerelease: false
|
54
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hoe
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
55
49
|
none: false
|
56
|
-
requirements:
|
50
|
+
requirements:
|
57
51
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 3
|
62
|
-
- 1
|
63
|
-
version: "3.1"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.5'
|
64
54
|
type: :development
|
65
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
66
62
|
description: Helps you test classes that normally use an Internet connection.
|
67
|
-
email:
|
63
|
+
email:
|
68
64
|
- commanderjohnson@gmail.com
|
69
65
|
executables: []
|
70
|
-
|
71
66
|
extensions: []
|
72
|
-
|
73
|
-
extra_rdoc_files:
|
67
|
+
extra_rdoc_files:
|
74
68
|
- History.txt
|
75
69
|
- Manifest.txt
|
76
70
|
- README.rdoc
|
77
71
|
- header.txt
|
78
|
-
files:
|
72
|
+
files:
|
79
73
|
- History.txt
|
80
74
|
- Manifest.txt
|
81
75
|
- README.rdoc
|
@@ -83,6 +77,7 @@ files:
|
|
83
77
|
- header.txt
|
84
78
|
- lib/integration_wrapper.rb
|
85
79
|
- lib/integration_wrapper/base.rb
|
80
|
+
- lib/integration_wrapper/online_test.rb
|
86
81
|
- script/console
|
87
82
|
- script/destroy
|
88
83
|
- script/generate
|
@@ -91,38 +86,30 @@ files:
|
|
91
86
|
- .gemtest
|
92
87
|
homepage: http://github.com/cmdjohnson/integration_wrapper
|
93
88
|
licenses: []
|
94
|
-
|
95
89
|
post_install_message:
|
96
|
-
rdoc_options:
|
90
|
+
rdoc_options:
|
97
91
|
- --main
|
98
92
|
- README.rdoc
|
99
|
-
require_paths:
|
93
|
+
require_paths:
|
100
94
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
96
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
- 0
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
102
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
119
107
|
requirements: []
|
120
|
-
|
121
108
|
rubyforge_project: integration_wrapper
|
122
109
|
rubygems_version: 1.8.24
|
123
110
|
signing_key:
|
124
111
|
specification_version: 3
|
125
112
|
summary: Helps you test classes that normally use an Internet connection.
|
126
|
-
test_files:
|
127
|
-
- test/test_helper.rb
|
113
|
+
test_files:
|
128
114
|
- test/test_integration_wrapper.rb
|
115
|
+
- test/test_helper.rb
|