surrogate 0.5.5 → 0.6.0
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/.rvmrc +0 -3
- data/Changelog.md +21 -0
- data/Readme.md +64 -76
- data/Readme.md.mountain_berry_fields +70 -77
- data/gemfiles/rspec_mocks_2.11 +1 -1
- data/lib/surrogate.rb +1 -1
- data/lib/surrogate/api_comparer.rb +59 -61
- data/lib/surrogate/argument_errorizer.rb +43 -0
- data/lib/surrogate/endower.rb +41 -37
- data/lib/surrogate/hatchery.rb +6 -1
- data/lib/surrogate/hatchling.rb +5 -0
- data/lib/surrogate/method_definition.rb +55 -0
- data/lib/surrogate/porc_reflector.rb +43 -0
- data/lib/surrogate/rspec/invocation_matcher.rb +2 -1
- data/lib/surrogate/rspec/substitute_for.rb +23 -7
- data/lib/surrogate/rspec/with_filter.rb +0 -1
- data/lib/surrogate/surrogate_class_reflector.rb +65 -0
- data/lib/surrogate/surrogate_instance_reflector.rb +15 -0
- data/lib/surrogate/version.rb +1 -1
- data/spec/acceptance_spec.rb +1 -1
- data/spec/defining_api_methods_spec.rb +51 -77
- data/spec/other_shit_spec.rb +131 -0
- data/spec/rspec/block_support_spec.rb +2 -2
- data/spec/rspec/initialization_matcher_spec.rb +12 -4
- data/spec/rspec/rspec_mocks_integration_spec.rb +1 -1
- data/spec/rspec/substitute_for_spec.rb +90 -4
- data/spec/unit/api_comparer_spec.rb +120 -4
- data/spec/unit/argument_errorizer_spec.rb +50 -0
- data/surrogate.gemspec +0 -2
- data/todo +44 -0
- metadata +21 -24
- data/lib/surrogate/options.rb +0 -41
data/lib/surrogate/options.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'bindable_block'
|
2
|
-
|
3
|
-
class Surrogate
|
4
|
-
class Options
|
5
|
-
attr_accessor :options, :default_proc
|
6
|
-
|
7
|
-
def initialize(options, default_proc)
|
8
|
-
self.options, self.default_proc = options, default_proc
|
9
|
-
end
|
10
|
-
|
11
|
-
def has?(name)
|
12
|
-
options.has_key? name
|
13
|
-
end
|
14
|
-
|
15
|
-
def [](key)
|
16
|
-
options[key]
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_hash
|
20
|
-
options
|
21
|
-
end
|
22
|
-
|
23
|
-
def default(instance, invocation, &no_default)
|
24
|
-
if options.has_key? :default
|
25
|
-
options[:default]
|
26
|
-
elsif default_proc
|
27
|
-
# This works for now, but it's a kind of crappy solution because
|
28
|
-
# BindableBlock adds and removes methods for each time it is invoked.
|
29
|
-
#
|
30
|
-
# A better solution would be to instantiate it before passing it to
|
31
|
-
# the options, then we only have to bind it to an instance and invoke
|
32
|
-
BindableBlock.new(instance.class, &default_proc)
|
33
|
-
.bind(instance)
|
34
|
-
.call(*invocation.args, &invocation.block)
|
35
|
-
else
|
36
|
-
no_default.call
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|