synthesis 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
data/README
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Currently we believe that developers are writing unnecessary <em>dependency wired</em> tests to cover uncertainty about the validity of simulated interactions in their <em>dependency neutral</em> tests. In other words, we cannot be certain that all our simulated interaction based tests 'join up'. If it were possible to correlate the simulated interactions in our tests, then we should be able to do away with the need to write large numbers of complex, slow and brittle wired tests (apart from those which interact with the boundaries of the SUT).
|
6
6
|
|
7
|
-
Synthesis combines lightweight
|
7
|
+
Synthesis combines lightweight tests to build confidence that the system under test is complete and reduces the need for large, overarching tests.
|
8
8
|
|
9
9
|
== Installation
|
10
10
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,10 @@ module Synthesis
|
|
8
8
|
class RSpecAdapter < Adapter
|
9
9
|
def run
|
10
10
|
rspec_options.files.clear
|
11
|
-
fail_unless
|
11
|
+
fail_unless do
|
12
|
+
rspec_options.instance_variable_set(:@formatters, nil)
|
13
|
+
rspec_options.run_examples
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
def collect_expectations
|
@@ -8,14 +8,14 @@ module Synthesis
|
|
8
8
|
def intercept_expected_argument_types_on(method_name)
|
9
9
|
@original_with = method_name
|
10
10
|
|
11
|
-
class_eval
|
11
|
+
class_eval <<-end_eval
|
12
12
|
alias intercepted_#{@original_with} #{@original_with}
|
13
13
|
|
14
14
|
def #{@original_with}(*expected_parameters, &matching_block)
|
15
15
|
synthesis_expectation.args = expected_parameters if synthesis_expectation
|
16
16
|
intercepted_#{@original_with}(*expected_parameters, &matching_block)
|
17
17
|
end
|
18
|
-
|
18
|
+
end_eval
|
19
19
|
end
|
20
20
|
|
21
21
|
# Intercept the mock object framework's expectation method for declaring a mocked
|
@@ -23,7 +23,7 @@ module Synthesis
|
|
23
23
|
def intercept_expected_return_values_on(method_name)
|
24
24
|
@original_returns = method_name
|
25
25
|
|
26
|
-
class_eval
|
26
|
+
class_eval <<-end_eval
|
27
27
|
alias intercepted_#{@original_returns} #{@original_returns}
|
28
28
|
|
29
29
|
def #{@original_returns}(*values)
|
@@ -31,21 +31,21 @@ module Synthesis
|
|
31
31
|
synthesis_expectation.add_return_values(*values) if synthesis_expectation
|
32
32
|
mock_expectation
|
33
33
|
end
|
34
|
-
|
34
|
+
end_eval
|
35
35
|
end
|
36
36
|
|
37
37
|
# Restore the original methods ExpectationInterceptor has rewritten and
|
38
38
|
# undefine their intercepted counterparts. Undefine the synthesis_expectation
|
39
39
|
# accessors.
|
40
40
|
def reset!
|
41
|
-
class_eval
|
41
|
+
class_eval <<-end_eval
|
42
42
|
alias #{@original_with} intercepted_#{@original_with}
|
43
43
|
alias #{@original_returns} intercepted_#{@original_returns}
|
44
44
|
undef intercepted_#{@original_with}
|
45
45
|
undef intercepted_#{@original_returns}
|
46
46
|
undef synthesis_expectation
|
47
47
|
undef synthesis_expectation=
|
48
|
-
|
48
|
+
end_eval
|
49
49
|
end
|
50
50
|
|
51
51
|
# Classes extending ExpectationInterceptor will have a synthesis_expectation
|
@@ -8,25 +8,25 @@ module Synthesis
|
|
8
8
|
def record_expectations_on(method_name)
|
9
9
|
@original_expects = method_name
|
10
10
|
|
11
|
-
class_eval
|
11
|
+
class_eval <<-end_eval
|
12
12
|
alias intercepted_#{@original_expects} #{@original_expects}
|
13
13
|
|
14
14
|
def #{@original_expects}(meth)
|
15
|
-
s_expectation =
|
15
|
+
s_expectation = ExpectationRecord.add_expectation(self, meth, caller[0])
|
16
16
|
m_expectation = intercepted_#{@original_expects}(meth)
|
17
17
|
m_expectation.synthesis_expectation = s_expectation
|
18
18
|
m_expectation
|
19
19
|
end
|
20
|
-
|
20
|
+
end_eval
|
21
21
|
end
|
22
22
|
|
23
23
|
# Restore the original methods ExpectationRecordEnabled has rewritten and
|
24
24
|
# undefine their intercepted counterparts.
|
25
25
|
def reset!
|
26
|
-
class_eval
|
26
|
+
class_eval <<-end_eval
|
27
27
|
alias #{@original_expects} intercepted_#{@original_expects}
|
28
28
|
undef intercepted_#{@original_expects}
|
29
|
-
|
29
|
+
end_eval
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/synthesis/recordable.rb
CHANGED
@@ -13,30 +13,26 @@ module Synthesis
|
|
13
13
|
def defined_recordable_method(meth)
|
14
14
|
unless method_defined?("__recordable__#{meth}".intern)
|
15
15
|
alias_method "__recordable__#{meth}".intern, meth
|
16
|
-
class_eval
|
16
|
+
class_eval <<-end_eval
|
17
|
+
def #{meth}(*args, &block)
|
18
|
+
return_value = send("__recordable__#{meth}", *args, &block)
|
19
|
+
MethodInvocationWatcher.invoked(self, "#{meth}".intern, args, [return_value])
|
20
|
+
return_value
|
21
|
+
end
|
22
|
+
end_eval
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
|
-
@@recordable_method_def = proc { |meth| %(
|
21
|
-
def #{meth}(*args, &block)
|
22
|
-
return_value = send("__recordable__#{meth}", *args, &block)
|
23
|
-
MethodInvocationWatcher.invoked(self, "#{meth}".intern, args, [return_value])
|
24
|
-
return_value
|
25
|
-
end
|
26
|
-
)}
|
27
|
-
|
28
26
|
def magic_recordable_method(meth)
|
29
|
-
class_eval
|
27
|
+
class_eval <<-end_eval
|
28
|
+
def #{meth}(*args)
|
29
|
+
return_value = method_missing(:#{meth}, *args)
|
30
|
+
MethodInvocationWatcher.invoked(self, "#{meth}".intern, args, [return_value])
|
31
|
+
return_value
|
32
|
+
end
|
33
|
+
|
34
|
+
def __recordable__#{meth}() raise "Don't ever call me" end
|
35
|
+
end_eval
|
30
36
|
end
|
31
|
-
|
32
|
-
@@recordable_magic_method_def = proc { |meth| %(
|
33
|
-
def #{meth}(*args)
|
34
|
-
return_value = method_missing(:#{meth}, *args)
|
35
|
-
MethodInvocationWatcher.invoked(self, "#{meth}".intern, args, [return_value])
|
36
|
-
return_value
|
37
|
-
end
|
38
|
-
|
39
|
-
def __recordable__#{meth}() raise "Don't ever call me" end
|
40
|
-
)}
|
41
37
|
end
|
42
38
|
end
|
@@ -2,6 +2,10 @@ require File.dirname(__FILE__) + "/helper"
|
|
2
2
|
|
3
3
|
module Synthesis
|
4
4
|
class MethodsTest < Test::Unit::TestCase
|
5
|
+
def teardown
|
6
|
+
ExpectationRecord.expectations.clear
|
7
|
+
end
|
8
|
+
|
5
9
|
def test_records_singleton_method_expectation
|
6
10
|
ExpectationRecord.should_receive(:add_expectation).with(Hash, :foo, an_instance_of(String))
|
7
11
|
Hash.should_receive(:foo)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synthesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Caborn, George Malamidis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-21 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|