cross-stub 0.2.3 → 0.2.4

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.
@@ -1,3 +1,7 @@
1
+ === 0.2.4 (9th Nov, 2010)
2
+
3
+ * adds generator for rails-3.* [#liangzan]
4
+
1
5
  === 0.2.3 (Oct 16, 2010)
2
6
 
3
7
  * adds official support for MRI-1.9.2 [#ngty]
@@ -20,12 +20,17 @@ It's hosted on gemcutter.org.
20
20
 
21
21
  == Setting Up
22
22
 
23
- === #1. Rails:
23
+ === 1. Rails-3.*
24
+
25
+ $ rails g cucumber:install
26
+ $ rails g cross_stub
27
+
28
+ === 2. Rails-2.*
24
29
 
25
30
  $ ./script/generate cucumber
26
31
  $ ./script/generate cross_stub
27
32
 
28
- === #2. Others (back to basics):
33
+ === 3. Others (back to basics)
29
34
 
30
35
  # In the test setup method:
31
36
  CrossStub.setup :file => <CACHE_FILE>
@@ -44,9 +49,9 @@ For a full list of available cache stores, scroll down to take a look at the
44
49
 
45
50
  Cross-stubbing is simple:
46
51
 
47
- === #1. Simple returning of nil or non-nil value:
52
+ === 1. Simple returning of nil or non-nil value:
48
53
 
49
- ==== #1.1. Class method:
54
+ ==== 1.1. Class method:
50
55
 
51
56
  class Someone
52
57
  def self.say
@@ -60,7 +65,7 @@ Cross-stubbing is simple:
60
65
  Someone.xstub(:say => 'HELLO')
61
66
  Someone.say # yields: 'HELLO'
62
67
 
63
- ==== #1.2. Instance method:
68
+ ==== 1.2. Instance method:
64
69
 
65
70
  Someone.xstub(:say, :instance => true)
66
71
  Someone.new.say # yields: nil
@@ -68,9 +73,9 @@ Cross-stubbing is simple:
68
73
  Someone.xstub({:say => 'HELLO'}, :instance => true)
69
74
  Someone.new.say # yields: 'HELLO'
70
75
 
71
- === #2. If a stubbed method requires argument, pass xstub a proc:
76
+ === 2. If a stubbed method requires argument, pass xstub a proc:
72
77
 
73
- ==== #2.1. Class method:
78
+ ==== 2.1. Class method:
74
79
 
75
80
  Someone.xstub do
76
81
  def say(something)
@@ -80,7 +85,7 @@ Cross-stubbing is simple:
80
85
 
81
86
  Someone.say('HELLO') # yields: 'saying "HELLO"'
82
87
 
83
- ==== #2.2. Instance method:
88
+ ==== 2.2. Instance method:
84
89
 
85
90
  Someone.xstub(:instance => true) do
86
91
  def say(something)
@@ -90,7 +95,7 @@ Cross-stubbing is simple:
90
95
 
91
96
  Someone.new.say('HELLO') # yields: 'saying "HELLO"'
92
97
 
93
- === #3. Something more complicated:
98
+ === 3. Something more complicated:
94
99
 
95
100
  something = 'hello'
96
101
  Someone.xstub do
@@ -117,7 +122,7 @@ we can have:
117
122
  Cache stores are needed to allow stubs to be made available for different processes.
118
123
  The following describes all cache stores available:
119
124
 
120
- === #1. File
125
+ === 1. File
121
126
 
122
127
  # Setting up (current process)
123
128
  CrossStub.setup :file => '<CACHE_FILE>'
@@ -125,7 +130,7 @@ The following describes all cache stores available:
125
130
  # Refreshing (other process)
126
131
  CrossStub.refresh :file => '<CACHE_FILE>'
127
132
 
128
- === #2. Memcache (requires memcache-client gem)
133
+ === 2. Memcache (requires memcache-client gem)
129
134
 
130
135
  # Setting up (current process)
131
136
  CrossStub.setup :memcache => 'localhost:11211/<CACHE_ID>'
@@ -133,7 +138,7 @@ The following describes all cache stores available:
133
138
  # Refreshing (other process)
134
139
  CrossStub.refresh :memcache => 'localhost:11211/<CACHE_ID>'
135
140
 
136
- === #3. Redis (requires redis gem)
141
+ === 3. Redis (requires redis gem)
137
142
 
138
143
  # Setting up (current process)
139
144
  CrossStub.setup :redis => 'localhost:6379/<CACHE_ID>'
@@ -146,24 +151,24 @@ if u need more :]
146
151
 
147
152
  == Caveats
148
153
 
149
- #1. CrossStub uses ruby's Marshal class to dump & load the stubs, thus it has the
154
+ 1. CrossStub uses ruby's Marshal class to dump & load the stubs, thus it has the
150
155
  same limitations as Marshal (pls note abt a 1.9.1 specific marshal bug at
151
156
  http://redmine.ruby-lang.org/issues/show/3729)
152
157
 
153
- #2. Under the hood, CrossStub uses Sourcify (http://github.com/ngty/sourcify) for
158
+ 2. Under the hood, CrossStub uses Sourcify (http://github.com/ngty/sourcify) for
154
159
  extracting the methods defined within the proc, u may wish to read Sourcify's
155
160
  gotchas to avoid unnecessary headaches.
156
161
 
157
162
  == TODO(s)
158
163
 
159
- #1. Is there any better serialization strategy instead of the current Marshal load/dump?
164
+ 1. Is there any better serialization strategy instead of the current Marshal load/dump?
160
165
 
161
166
  == Contacts
162
167
 
163
168
  Written since 2009 by:
164
169
 
165
- #1. NgTzeYang, contact ngty77[at]gmail[dot]com or http://github.com/ngty
170
+ 1. NgTzeYang, contact ngty77[at]gmail[dot]com or http://github.com/ngty
166
171
 
167
- #2. WongLiangZan, contact liangzan[at]gmail[dot]com or http://github.com/liangzan
172
+ 2. WongLiangZan, contact liangzan[at]gmail[dot]com or http://github.com/liangzan
168
173
 
169
174
  Released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cross-stub}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["NgTzeYang"]
12
- s.date = %q{2010-10-16}
12
+ s.date = %q{2010-11-09}
13
13
  s.description = %q{}
14
14
  s.email = %q{ngty77@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,9 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "cross-stub.gemspec",
29
+ "generators/cross_stub/cross_stub_generator.rb",
30
+ "generators/cross_stub/templates/config/initializers/cross-stub.rb",
31
+ "generators/cross_stub/templates/features/support/cross-stub.rb",
29
32
  "lib/cross-stub.rb",
30
33
  "lib/cross-stub/arguments.rb",
31
34
  "lib/cross-stub/arguments/array.rb",
@@ -39,9 +42,9 @@ Gem::Specification.new do |s|
39
42
  "lib/cross-stub/stores/memcache.rb",
40
43
  "lib/cross-stub/stores/redis.rb",
41
44
  "lib/cross-stub/stubber.rb",
42
- "rails_generators/cross_stub/cross_stub_generator.rb",
43
- "rails_generators/cross_stub/templates/config/initializers/cross-stub.rb",
44
- "rails_generators/cross_stub/templates/features/support/cross-stub.rb",
45
+ "lib/generators/cross_stub/cross_stub_generator.rb",
46
+ "lib/generators/cross_stub/templates/config/initializers/cross-stub.rb",
47
+ "lib/generators/cross_stub/templates/features/support/cross-stub.rb",
45
48
  "spec/.bacon",
46
49
  "spec/includes.rb",
47
50
  "spec/integration/clearing_instance_stubs_spec.rb",
@@ -4,14 +4,14 @@ class CrossStubGenerator < Rails::Generator::Base
4
4
  record do |m|
5
5
  m.file 'config/initializers/cross-stub.rb', 'config/initializers/cross-stub.rb'
6
6
  m.file 'features/support/cross-stub.rb', 'features/support/cross-stub.rb'
7
- m.gsub_file 'config/environments/cucumber.rb', /\z/, "config.gem 'cross-stub', :version => '>=0.2.0'\n"
7
+ m.gsub_file 'config/environments/cucumber.rb', /\z/, "config.gem 'cross-stub', :lib => false, :version => '>=0.2.4' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cross-stub'))\n"
8
8
  end
9
9
  end
10
10
 
11
- protected
11
+ protected
12
12
 
13
- def banner
14
- "Usage: #{$0} cross_stub"
15
- end
13
+ def banner
14
+ "Usage: #{$0} cross_stub"
15
+ end
16
16
 
17
17
  end
@@ -0,0 +1,8 @@
1
+ class CrossStubGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../templates", __FILE__)
3
+
4
+ def generate
5
+ copy_file 'config/initializers/cross-stub.rb', 'config/initializers/cross-stub.rb'
6
+ copy_file 'features/support/cross-stub.rb', 'features/support/cross-stub.rb'
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ if Rails.env.test?
2
+ ActionDispatch::Callbacks.before do
3
+ # /////////////////////////////////////////////////////////////////////////////////
4
+ # NOTE: By default, we use file-based cache store for cross-stub. Alternatively,
5
+ # u may wanna try out the other cache stores. Adding new cache store support is
6
+ # super easy, w.r.t actual implementation & testing, just drop me a note at
7
+ # http://github.com/ngty/cross-stub & i'll do it for u, of course FOC lah !!
8
+ # /////////////////////////////////////////////////////////////////////////////////
9
+ #CrossStub.refresh :redis => 'localhost:6379/xstub.cache' # requires *redis* gem
10
+ #CrossStub.refresh :memcache => 'localhost:11211/xstub.cache' # requires *memcache-client* gem
11
+ CrossStub.refresh :file => Rails.root.join('tmp', 'crossstub.cache')
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'cross-stub'
2
+
3
+ Before do
4
+ # /////////////////////////////////////////////////////////////////////////////////
5
+ # NOTE: By default, we use file-based cache store for cross-stub. Alternatively,
6
+ # u may wanna try out the other cache stores. Adding new cache store support is
7
+ # super easy, w.r.t actual implementation & testing, just drop me a note at
8
+ # http://github.com/ngty/cross-stub & i'll do it for u, of course FOC lah !!
9
+ # /////////////////////////////////////////////////////////////////////////////////
10
+ #CrossStub.setup :redis => 'localhost:6379/xstub.cache' # requires *redis* gem
11
+ #CrossStub.setup :memcache => 'localhost:11211/xstub.cache' # requires *memcache-client* gem
12
+ CrossStub.setup :file => Rails.root.join('tmp', 'xstub.cache')
13
+ end
14
+
15
+ After do
16
+ CrossStub.clear
17
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cross-stub
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - NgTzeYang
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-16 00:00:00 +08:00
18
+ date: 2010-11-09 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -117,6 +117,9 @@ files:
117
117
  - Rakefile
118
118
  - VERSION
119
119
  - cross-stub.gemspec
120
+ - generators/cross_stub/cross_stub_generator.rb
121
+ - generators/cross_stub/templates/config/initializers/cross-stub.rb
122
+ - generators/cross_stub/templates/features/support/cross-stub.rb
120
123
  - lib/cross-stub.rb
121
124
  - lib/cross-stub/arguments.rb
122
125
  - lib/cross-stub/arguments/array.rb
@@ -130,9 +133,9 @@ files:
130
133
  - lib/cross-stub/stores/memcache.rb
131
134
  - lib/cross-stub/stores/redis.rb
132
135
  - lib/cross-stub/stubber.rb
133
- - rails_generators/cross_stub/cross_stub_generator.rb
134
- - rails_generators/cross_stub/templates/config/initializers/cross-stub.rb
135
- - rails_generators/cross_stub/templates/features/support/cross-stub.rb
136
+ - lib/generators/cross_stub/cross_stub_generator.rb
137
+ - lib/generators/cross_stub/templates/config/initializers/cross-stub.rb
138
+ - lib/generators/cross_stub/templates/features/support/cross-stub.rb
136
139
  - spec/.bacon
137
140
  - spec/includes.rb
138
141
  - spec/integration/clearing_instance_stubs_spec.rb