cross-stub 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.txt +6 -1
- data/README.rdoc +24 -12
- data/Rakefile +5 -7
- data/VERSION +1 -1
- data/cross-stub.gemspec +14 -13
- data/lib/cross-stub.rb +3 -1
- data/lib/cross-stub/arguments/proc.rb +5 -59
- data/spec/includes.rb +10 -6
- data/spec/integration/shared_spec.rb +13 -8
- metadata +34 -20
- data/spec/arguments/proc_spec.rb +0 -689
data/HISTORY.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.2.1 2010-09-16
|
2
|
+
|
3
|
+
= House-Keeping
|
4
|
+
* use sourcify to extract proc code, instead of handrolled solution [#ngty]
|
5
|
+
* use Otaku instead of handrolled EchoServer [#ngty]
|
6
|
+
|
1
7
|
=== 0.2.0 2010-07-16
|
2
8
|
|
3
9
|
= New Features
|
@@ -6,7 +12,6 @@
|
|
6
12
|
* officially support MRI-1.8.7, MRI-1.9.1, JRUBY-1.5.1 & REE-1.8.7 [#ngty]
|
7
13
|
|
8
14
|
= House-Keeping
|
9
|
-
|
10
15
|
* dropped ParseTree dependency, use RubyParser instead [#ngty]
|
11
16
|
* complete rewrite to have cleaner implementation (hopefully) [#ngty]
|
12
17
|
|
data/README.rdoc
CHANGED
@@ -2,15 +2,21 @@
|
|
2
2
|
|
3
3
|
== Introduction
|
4
4
|
|
5
|
-
Existing mocking/stubbing frameworks support only stubbing in the current process.
|
5
|
+
Existing mocking/stubbing frameworks support only stubbing in the current process.
|
6
|
+
This is OK most of the time. However, when running cucumber integration test suite
|
7
|
+
in another process, these in-process stubbing frameworks simply doesn't help. Eg.
|
8
|
+
I want Time.now to always return a timing that should be a Sunday, how do I do that
|
9
|
+
when running cucumber using selenium, culerity, steam, blah, blah driver? It doesn't
|
10
|
+
seem straight-forward me.
|
6
11
|
|
7
|
-
(Let's not argue whether stubbing should be encouraged. It is an itch, the poor itch
|
12
|
+
(Let's not argue whether stubbing should be encouraged. It is an itch, the poor itch
|
13
|
+
needs to be scratched.)
|
8
14
|
|
9
15
|
== Getting Started
|
10
16
|
|
11
17
|
It's hosted on gemcutter.org.
|
12
18
|
|
13
|
-
$
|
19
|
+
$ gem install cross-stub
|
14
20
|
|
15
21
|
== Setting Up
|
16
22
|
|
@@ -31,7 +37,8 @@ It's hosted on gemcutter.org.
|
|
31
37
|
# point where all request handling starts:
|
32
38
|
CrossStub.refresh :file => <CACHE_FILE>
|
33
39
|
|
34
|
-
For a full list of available cache stores, scroll down to take a look at the
|
40
|
+
For a full list of available cache stores, scroll down to take a look at the
|
41
|
+
'Cache Stores' section.
|
35
42
|
|
36
43
|
== Using It
|
37
44
|
|
@@ -83,8 +90,6 @@ Cross-stubbing is simple:
|
|
83
90
|
|
84
91
|
Someone.new.say('HELLO') # yields: 'saying "HELLO"'
|
85
92
|
|
86
|
-
IMPORTANT: Since switching from ParseTree to RubyParser, dynamic code analysis is no longer possible. When defining methods in the proc, fanciful coding is strongly discouraged, pls follow the conservative style suggested above.
|
87
|
-
|
88
93
|
=== #3. Something more complicated:
|
89
94
|
|
90
95
|
something = 'hello'
|
@@ -96,7 +101,8 @@ IMPORTANT: Since switching from ParseTree to RubyParser, dynamic code analysis i
|
|
96
101
|
|
97
102
|
Someone.say # failure !!
|
98
103
|
|
99
|
-
The above fails as a result of undefined variable/method 'something', to workaround
|
104
|
+
The above fails as a result of undefined variable/method 'something', to workaround
|
105
|
+
we can have:
|
100
106
|
|
101
107
|
Someone.xstub(:something => 'HELLO') do
|
102
108
|
def say
|
@@ -108,7 +114,8 @@ The above fails as a result of undefined variable/method 'something', to workaro
|
|
108
114
|
|
109
115
|
== Cache Stores
|
110
116
|
|
111
|
-
Cache stores are needed to allow stubs to be made available for different processes.
|
117
|
+
Cache stores are needed to allow stubs to be made available for different processes.
|
118
|
+
The following describes all cache stores available:
|
112
119
|
|
113
120
|
=== #1. File
|
114
121
|
|
@@ -134,17 +141,22 @@ Cache stores are needed to allow stubs to be made available for different proces
|
|
134
141
|
# Refreshing (other process)
|
135
142
|
CrossStub.refresh :redis => 'localhost:6379/<CACHE_ID>'
|
136
143
|
|
137
|
-
Adding new store is super easy (w.r.t testing & actual implementation), let me know
|
144
|
+
Adding new store is super easy (w.r.t testing & actual implementation), let me know
|
145
|
+
if u need more :]
|
138
146
|
|
139
147
|
== Caveats
|
140
148
|
|
141
|
-
#1.
|
149
|
+
#1. CrossStub uses ruby's Marshal class to dump & load the stubs, thus it has the
|
150
|
+
same limitations as Marshal (pls note abt a 1.9.1 specific marshal bug at
|
151
|
+
http://redmine.ruby-lang.org/issues/show/3729)
|
142
152
|
|
143
|
-
#2.
|
153
|
+
#2. Under the hood, CrossStub uses Sourcify (http://github.com/ngty/sourcify) for
|
154
|
+
extracting the methods defined within the proc, u may wish to read Sourcify's
|
155
|
+
gotchas to avoid unnecessary headaches.
|
144
156
|
|
145
157
|
== TODO(s)
|
146
158
|
|
147
|
-
#1.
|
159
|
+
#1. Is there any better serialization strategy instead of the current Marshal load/dump?
|
148
160
|
|
149
161
|
== Contacts
|
150
162
|
|
data/Rakefile
CHANGED
@@ -4,6 +4,7 @@ require 'rake'
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
7
8
|
gem.name = "cross-stub"
|
8
9
|
gem.summary = %Q{Simple cross process stubbing}
|
9
10
|
gem.description = %Q{}
|
@@ -11,17 +12,14 @@ begin
|
|
11
12
|
gem.homepage = "http://github.com/ngty/cross-stub"
|
12
13
|
gem.authors = ["NgTzeYang"]
|
13
14
|
gem.add_development_dependency "bacon", ">= 0.0.0"
|
14
|
-
gem.add_development_dependency "
|
15
|
-
gem.add_dependency "ruby2ruby", "
|
16
|
-
gem.add_dependency "
|
15
|
+
gem.add_development_dependency "otaku", ">= 0.4.0"
|
16
|
+
gem.add_dependency "ruby2ruby", ">= 1.2.5"
|
17
|
+
gem.add_dependency "sexp_processor", ">= 3.0.5"
|
18
|
+
gem.add_dependency "sourcify", ">= 0.2.3"
|
17
19
|
gem.required_ruby_version = '>= 1.8.7'
|
18
|
-
# ##
|
19
20
|
# TODO: How do we declare the following optional dependencies ??
|
20
21
|
# 1. gem.add_dependency "memcache-client", "= 1.8.5"
|
21
22
|
# 2. gem.add_dependency "redis", "= 2.0.3"
|
22
|
-
# ##
|
23
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
24
|
-
#
|
25
23
|
end
|
26
24
|
rescue LoadError
|
27
25
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/cross-stub.gemspec
CHANGED
@@ -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.
|
8
|
+
s.version = "0.2.1"
|
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-
|
12
|
+
s.date = %q{2010-09-15}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{ngty77@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,7 +41,6 @@ Gem::Specification.new do |s|
|
|
41
41
|
"rails_generators/cross_stub/templates/config/initializers/cross-stub.rb",
|
42
42
|
"rails_generators/cross_stub/templates/features/support/cross-stub.rb",
|
43
43
|
"spec/.bacon",
|
44
|
-
"spec/arguments/proc_spec.rb",
|
45
44
|
"spec/includes.rb",
|
46
45
|
"spec/integration/clearing_instance_stubs_spec.rb",
|
47
46
|
"spec/integration/clearing_stubs_spec.rb",
|
@@ -61,7 +60,6 @@ Gem::Specification.new do |s|
|
|
61
60
|
s.summary = %q{Simple cross process stubbing}
|
62
61
|
s.test_files = [
|
63
62
|
"spec/includes.rb",
|
64
|
-
"spec/arguments/proc_spec.rb",
|
65
63
|
"spec/service.rb",
|
66
64
|
"spec/integration/stubbing_error_spec.rb",
|
67
65
|
"spec/integration/creating_instance_stubs_spec.rb",
|
@@ -78,20 +76,23 @@ Gem::Specification.new do |s|
|
|
78
76
|
|
79
77
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
80
78
|
s.add_development_dependency(%q<bacon>, [">= 0.0.0"])
|
81
|
-
s.add_development_dependency(%q<
|
82
|
-
s.add_runtime_dependency(%q<ruby2ruby>, ["
|
83
|
-
s.add_runtime_dependency(%q<
|
79
|
+
s.add_development_dependency(%q<otaku>, [">= 0.4.0"])
|
80
|
+
s.add_runtime_dependency(%q<ruby2ruby>, [">= 1.2.5"])
|
81
|
+
s.add_runtime_dependency(%q<sexp_processor>, [">= 3.0.5"])
|
82
|
+
s.add_runtime_dependency(%q<sourcify>, [">= 0.2.3"])
|
84
83
|
else
|
85
84
|
s.add_dependency(%q<bacon>, [">= 0.0.0"])
|
86
|
-
s.add_dependency(%q<
|
87
|
-
s.add_dependency(%q<ruby2ruby>, ["
|
88
|
-
s.add_dependency(%q<
|
85
|
+
s.add_dependency(%q<otaku>, [">= 0.4.0"])
|
86
|
+
s.add_dependency(%q<ruby2ruby>, [">= 1.2.5"])
|
87
|
+
s.add_dependency(%q<sexp_processor>, [">= 3.0.5"])
|
88
|
+
s.add_dependency(%q<sourcify>, [">= 0.2.3"])
|
89
89
|
end
|
90
90
|
else
|
91
91
|
s.add_dependency(%q<bacon>, [">= 0.0.0"])
|
92
|
-
s.add_dependency(%q<
|
93
|
-
s.add_dependency(%q<ruby2ruby>, ["
|
94
|
-
s.add_dependency(%q<
|
92
|
+
s.add_dependency(%q<otaku>, [">= 0.4.0"])
|
93
|
+
s.add_dependency(%q<ruby2ruby>, [">= 1.2.5"])
|
94
|
+
s.add_dependency(%q<sexp_processor>, [">= 3.0.5"])
|
95
|
+
s.add_dependency(%q<sourcify>, [">= 0.2.3"])
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
data/lib/cross-stub.rb
CHANGED
@@ -1,72 +1,18 @@
|
|
1
1
|
module CrossStub
|
2
2
|
module Arguments #:nodoc:
|
3
3
|
module Proc
|
4
|
-
|
5
4
|
class << self
|
6
|
-
def parse(&block)
|
7
|
-
CodeBlock.new(&block).methods_hash
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class CodeBlock
|
12
5
|
|
13
|
-
RUBY_PARSER = RubyParser.new
|
14
6
|
RUBY_2_RUBY = Ruby2Ruby.new
|
15
7
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
def parse(&block)
|
9
|
+
methods = {}
|
10
|
+
block.to_sexp.each_of_type(:defn) do |_sexp|
|
11
|
+
methods[_sexp.to_a[1]] = RUBY_2_RUBY.process(_sexp)
|
20
12
|
end
|
13
|
+
methods
|
21
14
|
end
|
22
15
|
|
23
|
-
attr_reader :methods_hash
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def extract_code(method)
|
28
|
-
ignore, _, code = source_code.match(code_regexp(method))[1..3]
|
29
|
-
remaining = source_code.sub(ignore,'')
|
30
|
-
while frag = remaining[/^(.*?\Wend)/m,1]
|
31
|
-
begin
|
32
|
-
sexp = RUBY_PARSER.parse(code += frag)
|
33
|
-
return RUBY_2_RUBY.process(sexp) if sexp.inspect =~ sexp_regexp(method)
|
34
|
-
rescue SyntaxError, Racc::ParseError, NoMethodError
|
35
|
-
remaining.sub!(frag,'')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def ref_methods
|
41
|
-
@ref_methods ||= (
|
42
|
-
(object = Minimalist.new).__instance_eval__(&@block)
|
43
|
-
object.__methods__ - Minimalist.instance_methods
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
def source_code
|
48
|
-
@source_code ||= (
|
49
|
-
file, line_no = /^#<Proc:0x[0-9A-Fa-f]+@(.+):(\d+).*?>$/.match(@block.inspect)[1..2]
|
50
|
-
File.readlines(file)[line_no.to_i.pred .. -1].join
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
def code_regexp(method)
|
55
|
-
/^(.*?(do|\{)\s*.*?(def\s*#{method}\W))/m
|
56
|
-
end
|
57
|
-
|
58
|
-
def sexp_regexp(method)
|
59
|
-
/^(s\(:defn,\ :#{method},\ s\(:args.*\),\ s\(:scope,\ s\(:block,\ .*\))$/
|
60
|
-
end
|
61
|
-
|
62
|
-
class Minimalist
|
63
|
-
orig_verbosity, $VERBOSE = $VERBOSE, nil
|
64
|
-
alias_method :__instance_eval__, :instance_eval
|
65
|
-
alias_method :__methods__, :methods
|
66
|
-
instance_methods.each{|meth| undef_method(meth) if meth.to_s !~ /^__.*?__$/ }
|
67
|
-
$VERBOSE = orig_verbosity
|
68
|
-
end
|
69
|
-
|
70
16
|
end
|
71
17
|
end
|
72
18
|
end
|
data/spec/includes.rb
CHANGED
@@ -10,7 +10,7 @@ RUBY_VM = [
|
|
10
10
|
RUBY_DESCRIPTION =~ /enterprise/i ? 'e' : ''
|
11
11
|
].join
|
12
12
|
|
13
|
-
PROJECT_ROOT = File.join(File.dirname(__FILE__), '..')
|
13
|
+
PROJECT_ROOT = File.join(File.dirname(File.expand_path(__FILE__)), '..')
|
14
14
|
PROJECT_FILE = lambda{|*args| File.join(*[PROJECT_ROOT, *args]) }
|
15
15
|
|
16
16
|
CACHE_STORES = {
|
@@ -19,10 +19,14 @@ CACHE_STORES = {
|
|
19
19
|
:redis => "localhost:6379/stubbing-#{RUBY_VM}.cache",
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
# /////////////////////////////////////////////////////////////////////////////////////////
|
23
|
+
# Configuring otaku service
|
24
|
+
# /////////////////////////////////////////////////////////////////////////////////////////
|
25
|
+
|
26
|
+
require 'otaku' unless Object.const_defined?('Otaku')
|
27
|
+
Otaku.configure do |config|
|
28
|
+
config.log_file = PROJECT_FILE['tmp', "otaku-#{RUBY_VM}.log"]
|
29
|
+
end
|
26
30
|
|
27
31
|
# /////////////////////////////////////////////////////////////////////////////////////////
|
28
32
|
# Useful methods
|
@@ -51,7 +55,7 @@ def parse_call_args(klass_and_method_and_args)
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def do_remote_method_call(store_type_and_klass_and_method_and_args)
|
54
|
-
(value =
|
58
|
+
(value = Otaku.process(store_type_and_klass_and_method_and_args)) !~ /^undefined method/ ?
|
55
59
|
value : Object.we_just_wanna_trigger_no_method_error_with_this_weird_method!
|
56
60
|
end
|
57
61
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
2
|
require File.join(File.dirname(__FILE__), '..', 'includes')
|
3
|
-
require File.join(File.dirname(__FILE__), '..', 'service')
|
4
3
|
|
5
4
|
shared 'has standard setup' do
|
6
5
|
before { CrossStub.setup(cache_store(@store_type)) }
|
@@ -17,19 +16,25 @@ shared 'has other process setup' do
|
|
17
16
|
behaves_like 'has standard setup'
|
18
17
|
|
19
18
|
before do
|
20
|
-
@call = lambda do |
|
21
|
-
do_remote_method_call("%s/%s" % [@store_type,
|
19
|
+
@call = lambda do |method_call_args|
|
20
|
+
do_remote_method_call("%s/%s" % [@store_type, method_call_args])
|
22
21
|
end
|
23
22
|
$service_started ||= (
|
24
|
-
|
25
|
-
|
23
|
+
ENV['FORK_SERVER'] != 'false' && (
|
24
|
+
Otaku.start do |data|
|
25
|
+
@@_not_isolated_vars = :all # we don't wanna isolate any contextual references
|
26
|
+
require File.join(File.dirname(__FILE__), '..', 'includes')
|
27
|
+
store_type, method_call_args = data.match(/^(.*?)\/(.*)$/)[1..2]
|
28
|
+
CrossStub.refresh(cache_store($prev_store_type)) if $prev_store_type
|
29
|
+
CrossStub.refresh(cache_store($prev_store_type = store_type))
|
30
|
+
do_local_method_call(method_call_args) rescue $!.message
|
31
|
+
end
|
32
|
+
) ; true
|
26
33
|
)
|
27
34
|
end
|
28
35
|
|
29
36
|
end
|
30
37
|
|
31
38
|
at_exit do
|
32
|
-
$service_started &&
|
33
|
-
EchoServer.stop unless ENV['ECHO_SERVER'] == 'false'
|
34
|
-
)
|
39
|
+
ENV['FORK_SERVER'] != 'false' && $service_started && Otaku.stop
|
35
40
|
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
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-
|
18
|
+
date: 2010-09-15 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -35,19 +35,19 @@ dependencies:
|
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: otaku
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 15
|
46
46
|
segments:
|
47
47
|
- 0
|
48
|
+
- 4
|
48
49
|
- 0
|
49
|
-
|
50
|
-
version: 0.0.0
|
50
|
+
version: 0.4.0
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
@@ -56,32 +56,48 @@ dependencies:
|
|
56
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
61
|
+
hash: 21
|
62
62
|
segments:
|
63
63
|
- 1
|
64
64
|
- 2
|
65
|
-
-
|
66
|
-
version: 1.2.
|
65
|
+
- 5
|
66
|
+
version: 1.2.5
|
67
67
|
type: :runtime
|
68
68
|
version_requirements: *id003
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: sexp_processor
|
71
71
|
prerelease: false
|
72
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- - "
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 13
|
78
78
|
segments:
|
79
|
-
-
|
79
|
+
- 3
|
80
80
|
- 0
|
81
|
-
-
|
82
|
-
version:
|
81
|
+
- 5
|
82
|
+
version: 3.0.5
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: sourcify
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 17
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 2
|
97
|
+
- 3
|
98
|
+
version: 0.2.3
|
99
|
+
type: :runtime
|
100
|
+
version_requirements: *id005
|
85
101
|
description: ""
|
86
102
|
email: ngty77@gmail.com
|
87
103
|
executables: []
|
@@ -116,7 +132,6 @@ files:
|
|
116
132
|
- rails_generators/cross_stub/templates/config/initializers/cross-stub.rb
|
117
133
|
- rails_generators/cross_stub/templates/features/support/cross-stub.rb
|
118
134
|
- spec/.bacon
|
119
|
-
- spec/arguments/proc_spec.rb
|
120
135
|
- spec/includes.rb
|
121
136
|
- spec/integration/clearing_instance_stubs_spec.rb
|
122
137
|
- spec/integration/clearing_stubs_spec.rb
|
@@ -165,7 +180,6 @@ specification_version: 3
|
|
165
180
|
summary: Simple cross process stubbing
|
166
181
|
test_files:
|
167
182
|
- spec/includes.rb
|
168
|
-
- spec/arguments/proc_spec.rb
|
169
183
|
- spec/service.rb
|
170
184
|
- spec/integration/stubbing_error_spec.rb
|
171
185
|
- spec/integration/creating_instance_stubs_spec.rb
|
data/spec/arguments/proc_spec.rb
DELETED
@@ -1,689 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
-
|
3
|
-
describe 'Extracting methods from proc' do
|
4
|
-
|
5
|
-
extract = CrossStub::Arguments::Proc.method(:parse)
|
6
|
-
|
7
|
-
describe '>> proc with single method (wo argument)' do
|
8
|
-
|
9
|
-
expected = {:bang => "def bang\n \"oops\"\nend"}
|
10
|
-
|
11
|
-
{
|
12
|
-
# ////////////////////////////////////////////////////////////////////////
|
13
|
-
# >> Always newlinling
|
14
|
-
# ////////////////////////////////////////////////////////////////////////
|
15
|
-
__LINE__ => (
|
16
|
-
lambda do
|
17
|
-
def bang
|
18
|
-
'oops'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
),
|
22
|
-
__LINE__ => (
|
23
|
-
lambda {
|
24
|
-
def bang
|
25
|
-
'oops'
|
26
|
-
end
|
27
|
-
}
|
28
|
-
),
|
29
|
-
__LINE__ => (
|
30
|
-
proc do
|
31
|
-
def bang
|
32
|
-
'oops'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
),
|
36
|
-
__LINE__ => (
|
37
|
-
proc {
|
38
|
-
def bang
|
39
|
-
'oops'
|
40
|
-
end
|
41
|
-
}
|
42
|
-
),
|
43
|
-
__LINE__ => (
|
44
|
-
Proc.new do
|
45
|
-
def bang
|
46
|
-
'oops'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
),
|
50
|
-
__LINE__ => (
|
51
|
-
Proc.new {
|
52
|
-
def bang
|
53
|
-
'oops'
|
54
|
-
end
|
55
|
-
}
|
56
|
-
),
|
57
|
-
# ////////////////////////////////////////////////////////////////////////
|
58
|
-
# >> Partial newlining
|
59
|
-
# ////////////////////////////////////////////////////////////////////////
|
60
|
-
__LINE__ => (
|
61
|
-
lambda do
|
62
|
-
def bang ; 'oops' ; end
|
63
|
-
end
|
64
|
-
),
|
65
|
-
__LINE__ => (
|
66
|
-
lambda {
|
67
|
-
def bang ; 'oops' ; end
|
68
|
-
}
|
69
|
-
),
|
70
|
-
__LINE__ => (
|
71
|
-
proc do
|
72
|
-
def bang ; 'oops' ; end
|
73
|
-
end
|
74
|
-
),
|
75
|
-
__LINE__ => (
|
76
|
-
proc {
|
77
|
-
def bang ; 'oops' ; end
|
78
|
-
}
|
79
|
-
),
|
80
|
-
__LINE__ => (
|
81
|
-
Proc.new do
|
82
|
-
def bang ; 'oops' ; end
|
83
|
-
end
|
84
|
-
),
|
85
|
-
__LINE__ => (
|
86
|
-
Proc.new {
|
87
|
-
def bang ; 'oops' ; end
|
88
|
-
}
|
89
|
-
),
|
90
|
-
# ////////////////////////////////////////////////////////////////////////
|
91
|
-
# >> No newlining
|
92
|
-
# ////////////////////////////////////////////////////////////////////////
|
93
|
-
__LINE__ => (
|
94
|
-
lambda do def bang ; 'oops' ; end end
|
95
|
-
),
|
96
|
-
__LINE__ => (
|
97
|
-
lambda { def bang ; 'oops' ; end }
|
98
|
-
),
|
99
|
-
__LINE__ => (
|
100
|
-
proc do def bang ; 'oops' ; end end
|
101
|
-
),
|
102
|
-
__LINE__ => (
|
103
|
-
proc { def bang ; 'oops' ; end }
|
104
|
-
),
|
105
|
-
__LINE__ => (
|
106
|
-
Proc.new do def bang ; 'oops' ; end end
|
107
|
-
),
|
108
|
-
__LINE__ => (
|
109
|
-
Proc.new { def bang ; 'oops' ; end }
|
110
|
-
),
|
111
|
-
}.each do |debug, block|
|
112
|
-
should "handle proc as variable [##{debug}]" do
|
113
|
-
extract.call(&block).should.equal(expected)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
118
|
-
extract.call do
|
119
|
-
def bang
|
120
|
-
'oops'
|
121
|
-
end
|
122
|
-
end.should.equal(expected)
|
123
|
-
end
|
124
|
-
|
125
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
126
|
-
extract.call do
|
127
|
-
def bang ; 'oops' ; end
|
128
|
-
end.should.equal(expected)
|
129
|
-
end
|
130
|
-
|
131
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
132
|
-
extract.call do def bang ; 'oops' ; end ; end.should.equal(expected)
|
133
|
-
end
|
134
|
-
|
135
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
136
|
-
extract.call do
|
137
|
-
def bang
|
138
|
-
'oops'
|
139
|
-
end
|
140
|
-
end.should.equal(expected)
|
141
|
-
end
|
142
|
-
|
143
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
144
|
-
extract.call {
|
145
|
-
def bang
|
146
|
-
'oops'
|
147
|
-
end
|
148
|
-
}.should.equal(expected)
|
149
|
-
end
|
150
|
-
|
151
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
152
|
-
extract.call {
|
153
|
-
def bang ; 'oops' ; end
|
154
|
-
}.should.equal(expected)
|
155
|
-
end
|
156
|
-
|
157
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
158
|
-
extract.call { def bang ; 'oops' ; end }.should.equal(expected)
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '>> proc with single method (w argument)' do
|
164
|
-
|
165
|
-
expected = {:shout => "def shout(wat)\n wat\nend"}
|
166
|
-
|
167
|
-
{
|
168
|
-
# ////////////////////////////////////////////////////////////////////////
|
169
|
-
# >> Always newlinling
|
170
|
-
# ////////////////////////////////////////////////////////////////////////
|
171
|
-
__LINE__ => (
|
172
|
-
lambda do
|
173
|
-
def shout(wat)
|
174
|
-
wat
|
175
|
-
end
|
176
|
-
end
|
177
|
-
),
|
178
|
-
__LINE__ => (
|
179
|
-
lambda {
|
180
|
-
def shout(wat)
|
181
|
-
wat
|
182
|
-
end
|
183
|
-
}
|
184
|
-
),
|
185
|
-
__LINE__ => (
|
186
|
-
proc do
|
187
|
-
def shout(wat)
|
188
|
-
wat
|
189
|
-
end
|
190
|
-
end
|
191
|
-
),
|
192
|
-
__LINE__ => (
|
193
|
-
proc {
|
194
|
-
def shout(wat)
|
195
|
-
wat
|
196
|
-
end
|
197
|
-
}
|
198
|
-
),
|
199
|
-
__LINE__ => (
|
200
|
-
Proc.new do
|
201
|
-
def shout(wat)
|
202
|
-
wat
|
203
|
-
end
|
204
|
-
end
|
205
|
-
),
|
206
|
-
__LINE__ => (
|
207
|
-
Proc.new {
|
208
|
-
def shout(wat)
|
209
|
-
wat
|
210
|
-
end
|
211
|
-
}
|
212
|
-
),
|
213
|
-
# ////////////////////////////////////////////////////////////////////////
|
214
|
-
# >> Partial newlining
|
215
|
-
# ////////////////////////////////////////////////////////////////////////
|
216
|
-
__LINE__ => (
|
217
|
-
lambda do
|
218
|
-
def shout(wat) ; wat ; end
|
219
|
-
end
|
220
|
-
),
|
221
|
-
__LINE__ => (
|
222
|
-
lambda {
|
223
|
-
def shout(wat) ; wat ; end
|
224
|
-
}
|
225
|
-
),
|
226
|
-
__LINE__ => (
|
227
|
-
proc do
|
228
|
-
def shout(wat) ; wat ; end
|
229
|
-
end
|
230
|
-
),
|
231
|
-
__LINE__ => (
|
232
|
-
proc {
|
233
|
-
def shout(wat) ; wat ; end
|
234
|
-
}
|
235
|
-
),
|
236
|
-
__LINE__ => (
|
237
|
-
Proc.new do
|
238
|
-
def shout(wat) ; wat ; end
|
239
|
-
end
|
240
|
-
),
|
241
|
-
__LINE__ => (
|
242
|
-
Proc.new {
|
243
|
-
def shout(wat) ; wat ; end
|
244
|
-
}
|
245
|
-
),
|
246
|
-
# ////////////////////////////////////////////////////////////////////////
|
247
|
-
# >> No newlining
|
248
|
-
# ////////////////////////////////////////////////////////////////////////
|
249
|
-
__LINE__ => (
|
250
|
-
lambda do def shout(wat) ; wat ; end end
|
251
|
-
),
|
252
|
-
__LINE__ => (
|
253
|
-
lambda { def shout(wat) ; wat ; end }
|
254
|
-
),
|
255
|
-
__LINE__ => (
|
256
|
-
proc do def shout(wat) ; wat ; end end
|
257
|
-
),
|
258
|
-
__LINE__ => (
|
259
|
-
proc { def shout(wat) ; wat ; end }
|
260
|
-
),
|
261
|
-
__LINE__ => (
|
262
|
-
Proc.new do def shout(wat) ; wat ; end end
|
263
|
-
),
|
264
|
-
__LINE__ => (
|
265
|
-
Proc.new { def shout(wat) ; wat ; end }
|
266
|
-
),
|
267
|
-
}.each do |debug, block|
|
268
|
-
should "handle proc as variable [##{debug}]" do
|
269
|
-
extract.call(&block).should.equal(expected)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
274
|
-
extract.call do
|
275
|
-
def shout(wat)
|
276
|
-
wat
|
277
|
-
end
|
278
|
-
end.should.equal(expected)
|
279
|
-
end
|
280
|
-
|
281
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
282
|
-
extract.call do
|
283
|
-
def shout(wat) ; wat ; end
|
284
|
-
end.should.equal(expected)
|
285
|
-
end
|
286
|
-
|
287
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
288
|
-
extract.call do def shout(wat) ; wat ; end end.should.equal(expected)
|
289
|
-
end
|
290
|
-
|
291
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
292
|
-
extract.call do
|
293
|
-
def shout(wat)
|
294
|
-
wat
|
295
|
-
end
|
296
|
-
end.should.equal(expected)
|
297
|
-
end
|
298
|
-
|
299
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
300
|
-
extract.call {
|
301
|
-
def shout(wat)
|
302
|
-
wat
|
303
|
-
end
|
304
|
-
}.should.equal(expected)
|
305
|
-
end
|
306
|
-
|
307
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
308
|
-
extract.call {
|
309
|
-
def shout(wat) ; wat ; end
|
310
|
-
}.should.equal(expected)
|
311
|
-
end
|
312
|
-
|
313
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
314
|
-
extract.call { def shout(wat) ; wat ; end }.should.equal(expected)
|
315
|
-
end
|
316
|
-
|
317
|
-
end
|
318
|
-
|
319
|
-
describe '>> proc with multiple methods (wo argument)' do
|
320
|
-
|
321
|
-
expected = {
|
322
|
-
:bang => "def bang\n \"oops\"\nend",
|
323
|
-
:shout => "def shout\n \"hello\"\nend"
|
324
|
-
}
|
325
|
-
|
326
|
-
{
|
327
|
-
# ////////////////////////////////////////////////////////////////////////
|
328
|
-
# >> Always newlinling
|
329
|
-
# ////////////////////////////////////////////////////////////////////////
|
330
|
-
__LINE__ => (
|
331
|
-
lambda do
|
332
|
-
def bang
|
333
|
-
'oops'
|
334
|
-
end
|
335
|
-
def shout
|
336
|
-
'hello'
|
337
|
-
end
|
338
|
-
end
|
339
|
-
),
|
340
|
-
__LINE__ => (
|
341
|
-
lambda {
|
342
|
-
def bang
|
343
|
-
'oops'
|
344
|
-
end
|
345
|
-
def shout
|
346
|
-
'hello'
|
347
|
-
end
|
348
|
-
}
|
349
|
-
),
|
350
|
-
__LINE__ => (
|
351
|
-
proc do
|
352
|
-
def bang
|
353
|
-
'oops'
|
354
|
-
end
|
355
|
-
def shout
|
356
|
-
'hello'
|
357
|
-
end
|
358
|
-
end
|
359
|
-
),
|
360
|
-
__LINE__ => (
|
361
|
-
proc {
|
362
|
-
def bang
|
363
|
-
'oops'
|
364
|
-
end
|
365
|
-
def shout
|
366
|
-
'hello'
|
367
|
-
end
|
368
|
-
}
|
369
|
-
),
|
370
|
-
__LINE__ => (
|
371
|
-
Proc.new do
|
372
|
-
def bang
|
373
|
-
'oops'
|
374
|
-
end
|
375
|
-
def shout
|
376
|
-
'hello'
|
377
|
-
end
|
378
|
-
end
|
379
|
-
),
|
380
|
-
__LINE__ => (
|
381
|
-
Proc.new {
|
382
|
-
def bang
|
383
|
-
'oops'
|
384
|
-
end
|
385
|
-
def shout
|
386
|
-
'hello'
|
387
|
-
end
|
388
|
-
}
|
389
|
-
),
|
390
|
-
# ////////////////////////////////////////////////////////////////////////
|
391
|
-
# >> Partial newlining
|
392
|
-
# ////////////////////////////////////////////////////////////////////////
|
393
|
-
__LINE__ => (
|
394
|
-
lambda do
|
395
|
-
def bang ; 'oops' ; end
|
396
|
-
def shout ; 'hello' ; end
|
397
|
-
end
|
398
|
-
),
|
399
|
-
__LINE__ => (
|
400
|
-
lambda {
|
401
|
-
def bang ; 'oops' ; end
|
402
|
-
def shout ; 'hello' ; end
|
403
|
-
}
|
404
|
-
),
|
405
|
-
__LINE__ => (
|
406
|
-
proc do
|
407
|
-
def bang ; 'oops' ; end
|
408
|
-
def shout ; 'hello' ; end
|
409
|
-
end
|
410
|
-
),
|
411
|
-
__LINE__ => (
|
412
|
-
proc {
|
413
|
-
def bang ; 'oops' ; end
|
414
|
-
def shout ; 'hello' ; end
|
415
|
-
}
|
416
|
-
),
|
417
|
-
__LINE__ => (
|
418
|
-
Proc.new do
|
419
|
-
def bang ; 'oops' ; end
|
420
|
-
def shout ; 'hello' ; end
|
421
|
-
end
|
422
|
-
),
|
423
|
-
__LINE__ => (
|
424
|
-
Proc.new {
|
425
|
-
def bang ; 'oops' ; end
|
426
|
-
def shout ; 'hello' ; end
|
427
|
-
}
|
428
|
-
),
|
429
|
-
# ////////////////////////////////////////////////////////////////////////
|
430
|
-
# >> No newlining
|
431
|
-
# ////////////////////////////////////////////////////////////////////////
|
432
|
-
__LINE__ => (
|
433
|
-
lambda do def bang ; 'oops' ; end ; def shout ; 'hello' ; end end
|
434
|
-
),
|
435
|
-
__LINE__ => (
|
436
|
-
lambda { def bang ; 'oops' ; end ; def shout ; 'hello' ; end }
|
437
|
-
),
|
438
|
-
__LINE__ => (
|
439
|
-
proc do def bang ; 'oops' ; end ; def shout ; 'hello' ; end end
|
440
|
-
),
|
441
|
-
__LINE__ => (
|
442
|
-
proc { def bang ; 'oops' ; end ; def shout ; 'hello' ; end }
|
443
|
-
),
|
444
|
-
__LINE__ => (
|
445
|
-
Proc.new do def bang ; 'oops' ; end ; def shout ; 'hello' ; end end
|
446
|
-
),
|
447
|
-
__LINE__ => (
|
448
|
-
Proc.new { def bang ; 'oops' ; end ; def shout ; 'hello' ; end }
|
449
|
-
),
|
450
|
-
}.each do |debug, block|
|
451
|
-
should "handle proc as variable [##{debug}]" do
|
452
|
-
extract.call(&block).should.equal(expected)
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
457
|
-
extract.call do
|
458
|
-
def bang
|
459
|
-
'oops'
|
460
|
-
end
|
461
|
-
def shout
|
462
|
-
'hello'
|
463
|
-
end
|
464
|
-
end.should.equal(expected)
|
465
|
-
end
|
466
|
-
|
467
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
468
|
-
extract.call do
|
469
|
-
def bang ; 'oops' ; end
|
470
|
-
def shout ; 'hello' ; end
|
471
|
-
end.should.equal(expected)
|
472
|
-
end
|
473
|
-
|
474
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
475
|
-
extract.call do def bang ; 'oops' ; end ; def shout ; 'hello' ; end end.
|
476
|
-
should.equal(expected)
|
477
|
-
end
|
478
|
-
|
479
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
480
|
-
extract.call {
|
481
|
-
def bang
|
482
|
-
'oops'
|
483
|
-
end
|
484
|
-
def shout
|
485
|
-
'hello'
|
486
|
-
end
|
487
|
-
}.should.equal(expected)
|
488
|
-
end
|
489
|
-
|
490
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
491
|
-
extract.call {
|
492
|
-
def bang ; 'oops' ; end
|
493
|
-
def shout ; 'hello' ; end
|
494
|
-
}.should.equal(expected)
|
495
|
-
end
|
496
|
-
|
497
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
498
|
-
extract.call { def bang ; 'oops' ; end ; def shout ; 'hello' ; end }.
|
499
|
-
should.equal(expected)
|
500
|
-
end
|
501
|
-
|
502
|
-
end
|
503
|
-
|
504
|
-
describe '>> proc with multiple methods (w argument)' do
|
505
|
-
|
506
|
-
expected = {
|
507
|
-
:bang => "def bang(wat)\n wat\nend",
|
508
|
-
:shout => "def shout(wat)\n wat\nend"
|
509
|
-
}
|
510
|
-
|
511
|
-
{
|
512
|
-
# ////////////////////////////////////////////////////////////////////////
|
513
|
-
# >> Always newlinling
|
514
|
-
# ////////////////////////////////////////////////////////////////////////
|
515
|
-
__LINE__ => (
|
516
|
-
lambda do
|
517
|
-
def bang(wat)
|
518
|
-
wat
|
519
|
-
end
|
520
|
-
def shout(wat)
|
521
|
-
wat
|
522
|
-
end
|
523
|
-
end
|
524
|
-
),
|
525
|
-
__LINE__ => (
|
526
|
-
lambda {
|
527
|
-
def bang(wat)
|
528
|
-
wat
|
529
|
-
end
|
530
|
-
def shout(wat)
|
531
|
-
wat
|
532
|
-
end
|
533
|
-
}
|
534
|
-
),
|
535
|
-
__LINE__ => (
|
536
|
-
proc do
|
537
|
-
def bang(wat)
|
538
|
-
wat
|
539
|
-
end
|
540
|
-
def shout(wat)
|
541
|
-
wat
|
542
|
-
end
|
543
|
-
end
|
544
|
-
),
|
545
|
-
__LINE__ => (
|
546
|
-
proc {
|
547
|
-
def bang(wat)
|
548
|
-
wat
|
549
|
-
end
|
550
|
-
def shout(wat)
|
551
|
-
wat
|
552
|
-
end
|
553
|
-
}
|
554
|
-
),
|
555
|
-
__LINE__ => (
|
556
|
-
Proc.new do
|
557
|
-
def bang(wat)
|
558
|
-
wat
|
559
|
-
end
|
560
|
-
def shout(wat)
|
561
|
-
wat
|
562
|
-
end
|
563
|
-
end
|
564
|
-
),
|
565
|
-
__LINE__ => (
|
566
|
-
Proc.new {
|
567
|
-
def bang(wat)
|
568
|
-
wat
|
569
|
-
end
|
570
|
-
def shout(wat)
|
571
|
-
wat
|
572
|
-
end
|
573
|
-
}
|
574
|
-
),
|
575
|
-
# ////////////////////////////////////////////////////////////////////////
|
576
|
-
# >> Partial newlining
|
577
|
-
# ////////////////////////////////////////////////////////////////////////
|
578
|
-
__LINE__ => (
|
579
|
-
lambda do
|
580
|
-
def bang(wat) ; wat ; end
|
581
|
-
def shout(wat) ; wat ; end
|
582
|
-
end
|
583
|
-
),
|
584
|
-
__LINE__ => (
|
585
|
-
lambda {
|
586
|
-
def bang(wat) ; wat ; end
|
587
|
-
def shout(wat) ; wat ; end
|
588
|
-
}
|
589
|
-
),
|
590
|
-
__LINE__ => (
|
591
|
-
proc do
|
592
|
-
def bang(wat) ; wat ; end
|
593
|
-
def shout(wat) ; wat ; end
|
594
|
-
end
|
595
|
-
),
|
596
|
-
__LINE__ => (
|
597
|
-
proc {
|
598
|
-
def bang(wat) ; wat ; end
|
599
|
-
def shout(wat) ; wat ; end
|
600
|
-
}
|
601
|
-
),
|
602
|
-
__LINE__ => (
|
603
|
-
Proc.new do
|
604
|
-
def bang(wat) ; wat ; end
|
605
|
-
def shout(wat) ; wat ; end
|
606
|
-
end
|
607
|
-
),
|
608
|
-
__LINE__ => (
|
609
|
-
Proc.new {
|
610
|
-
def bang(wat) ; wat ; end
|
611
|
-
def shout(wat) ; wat ; end
|
612
|
-
}
|
613
|
-
),
|
614
|
-
# ////////////////////////////////////////////////////////////////////////
|
615
|
-
# >> No newlining
|
616
|
-
# ////////////////////////////////////////////////////////////////////////
|
617
|
-
__LINE__ => (
|
618
|
-
lambda do def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end end
|
619
|
-
),
|
620
|
-
__LINE__ => (
|
621
|
-
lambda { def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end }
|
622
|
-
),
|
623
|
-
__LINE__ => (
|
624
|
-
proc do def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end end
|
625
|
-
),
|
626
|
-
__LINE__ => (
|
627
|
-
proc { def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end }
|
628
|
-
),
|
629
|
-
__LINE__ => (
|
630
|
-
Proc.new do def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end end
|
631
|
-
),
|
632
|
-
__LINE__ => (
|
633
|
-
Proc.new { def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end }
|
634
|
-
),
|
635
|
-
}.each do |debug, block|
|
636
|
-
should "handle proc as variable [##{debug}]" do
|
637
|
-
extract.call(&block).should.equal(expected)
|
638
|
-
end
|
639
|
-
end
|
640
|
-
|
641
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
642
|
-
extract.call do
|
643
|
-
def bang(wat)
|
644
|
-
wat
|
645
|
-
end
|
646
|
-
def shout(wat)
|
647
|
-
wat
|
648
|
-
end
|
649
|
-
end.should.equal(expected)
|
650
|
-
end
|
651
|
-
|
652
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
653
|
-
extract.call do
|
654
|
-
def bang(wat) ; wat ; end
|
655
|
-
def shout(wat) ; wat ; end
|
656
|
-
end.should.equal(expected)
|
657
|
-
end
|
658
|
-
|
659
|
-
should "handle block using do ... end [##{__LINE__}]" do
|
660
|
-
extract.call do def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end end.
|
661
|
-
should.equal(expected)
|
662
|
-
end
|
663
|
-
|
664
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
665
|
-
extract.call {
|
666
|
-
def bang(wat)
|
667
|
-
wat
|
668
|
-
end
|
669
|
-
def shout(wat)
|
670
|
-
wat
|
671
|
-
end
|
672
|
-
}.should.equal(expected)
|
673
|
-
end
|
674
|
-
|
675
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
676
|
-
extract.call {
|
677
|
-
def bang(wat) ; wat ; end
|
678
|
-
def shout(wat) ; wat ; end
|
679
|
-
}.should.equal(expected)
|
680
|
-
end
|
681
|
-
|
682
|
-
should "handle block using { ... } [##{__LINE__}]" do
|
683
|
-
extract.call { def bang(wat) ; wat ; end ; def shout(wat) ; wat ; end }.
|
684
|
-
should.equal(expected)
|
685
|
-
end
|
686
|
-
|
687
|
-
end
|
688
|
-
|
689
|
-
end
|