synthesis 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -20
- data/Rakefile +0 -10
- data/lib/synthesis/method_invocation_watcher.rb +0 -7
- data/synthesis.gemspec +2 -3
- metadata +8 -7
- data/lib/synthesis/adapter/expectations.rb +0 -36
data/README.rdoc
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
= Synthesis
|
2
2
|
|
3
|
-
==
|
4
|
-
|
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
|
-
|
7
|
-
Synthesis combines lightweight tests to build confidence that the system under test is complete and reduces the need for large, overarching tests.
|
3
|
+
== A tool for verifying mock object assumptions in tests
|
8
4
|
|
9
5
|
== Installation
|
10
6
|
|
@@ -22,11 +18,9 @@ When used with the Mocha adapter, it will depend on the Mocha[http://mocha.rubyf
|
|
22
18
|
|
23
19
|
When used with the RSpec adapter, it will depend on the RSpec[http://rspec.info/] library.
|
24
20
|
|
25
|
-
When used with the Expectations adapter, it will depend on the Expectations[http://expectations.rubyforge.org] library.
|
26
|
-
|
27
21
|
== Usage
|
28
22
|
|
29
|
-
Synthesis can be used through its Rake task. It
|
23
|
+
Synthesis can be used through its Rake task. It has two adapters: Mocha (with Test::Unit, etc) and RSpec. If +adapter+ is not specified, the Mocha adapter will be used by default.
|
30
24
|
|
31
25
|
By default, Synthesis outputs to +STDOUT+, but output can be redirected to alternative IO streams.
|
32
26
|
|
@@ -56,12 +50,11 @@ To use with RSpec, running all specs in the <tt>spec</tt> directory:
|
|
56
50
|
t.pattern = 'spec/**/*_spec.rb'
|
57
51
|
end
|
58
52
|
|
59
|
-
To
|
53
|
+
To to a file:
|
60
54
|
|
61
55
|
require "synthesis/task"
|
62
56
|
|
63
57
|
Synthesis::Task.new do |t|
|
64
|
-
t.adapter = :expectations
|
65
58
|
t.out = File.new "synthesis.test.txt", "a"
|
66
59
|
end
|
67
60
|
|
@@ -95,7 +88,7 @@ To use Synthesis with Rails:
|
|
95
88
|
require "synthesis/util/mock_instance"
|
96
89
|
foo_mock = Foo.mock_instance(arg_one, arg_2)
|
97
90
|
|
98
|
-
This is equivalent, but without calling the real <tt>initialize</tt
|
91
|
+
This is equivalent, but without calling the real <tt>initialize</tt> method, to:
|
99
92
|
|
100
93
|
foo_mock = Foo.new
|
101
94
|
Foo.expects(:new).with(arg_one, arg_two).returns(foo_mock)
|
@@ -111,10 +104,6 @@ Either <tt>"mocha_standalone"</tt> or <tt>"spec/mocks"</tt> need to be required
|
|
111
104
|
|
112
105
|
Public clone URL: git://github.com/gmalamid/synthesis.git
|
113
106
|
|
114
|
-
== Known Issues
|
115
|
-
|
116
|
-
Reporting the location (filename and line number) of tested/untested expectations doesn't work as intended with the Expectations adapter.
|
117
|
-
|
118
107
|
== Contributors
|
119
108
|
|
120
109
|
Danilo Sato, Paul Nasrat, Jerome Riga
|
@@ -123,10 +112,7 @@ Danilo Sato, Paul Nasrat, Jerome Riga
|
|
123
112
|
|
124
113
|
http://groups.google.com/group/synthesized-testing
|
125
114
|
|
115
|
+
|
126
116
|
== Related reading
|
127
117
|
|
128
|
-
|
129
|
-
* Confidence as a test code metric ( http://nutrun.com/weblog/confidence-as-a-test-code-metric )
|
130
|
-
* Using Synthesis With Test::Unit and Mocha ( http://nutrun.com/weblog/using-synthesis-with-testunit-and-mocha )
|
131
|
-
* Using Synthesis With Expectations ( http://nutrun.com/weblog/using-synthesis-with-expectations )
|
132
|
-
* Synthesis validates simulated method calls taking method signature arguments into account ( http://nutrun.com/weblog/synthesis-002 )
|
118
|
+
http://nutrun.com/weblog/using-synthesis-with-testunit-and-mocha
|
data/Rakefile
CHANGED
@@ -50,16 +50,10 @@ Synthesis::Task.new('synthesis:spec:graph') do |t|
|
|
50
50
|
t.formatter = :dot
|
51
51
|
end
|
52
52
|
|
53
|
-
Synthesis::Task.new('synthesis:expectations') do |t|
|
54
|
-
t.adapter = :expectations
|
55
|
-
t.pattern = 'test_project/expectations/test/*_test.rb'
|
56
|
-
end
|
57
|
-
|
58
53
|
namespace :test_project do
|
59
54
|
task :all do
|
60
55
|
STDOUT.puts `rake test_project:mocha`
|
61
56
|
STDOUT.puts `rake test_project:rspec`
|
62
|
-
STDOUT.puts `rake test_project:expectations`
|
63
57
|
end
|
64
58
|
|
65
59
|
Rake::TestTask.new('mocha') do |t|
|
@@ -69,10 +63,6 @@ namespace :test_project do
|
|
69
63
|
Rake::TestTask.new('rspec') do |t|
|
70
64
|
t.pattern = 'test_project/mocha/**/*_test.rb'
|
71
65
|
end
|
72
|
-
|
73
|
-
Rake::TestTask.new('expectations') do |t|
|
74
|
-
t.pattern = 'test_project/mocha/**/*_test.rb'
|
75
|
-
end
|
76
66
|
end
|
77
67
|
|
78
68
|
desc 'Generate RDoc'
|
@@ -1,13 +1,6 @@
|
|
1
1
|
module Synthesis
|
2
2
|
class MethodInvocationWatcher
|
3
3
|
def self.invoked(receiver, method, args = [], return_values = [])
|
4
|
-
# cal = caller.clone
|
5
|
-
# cal.shift # ignore first (eval)
|
6
|
-
# path_from_spec = []
|
7
|
-
# begin
|
8
|
-
# c = cal.shift
|
9
|
-
# path_from_spec.unshift c # unless c =~ /(\(eval\)|gems)/
|
10
|
-
# end until c =~ /(spec|test)/
|
11
4
|
matcher = Expectation.new(receiver, method, nil, args, return_values)
|
12
5
|
ExpectationRecord[matcher].invoked! # path_from_spec
|
13
6
|
end
|
data/synthesis.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
GEMSPEC =Gem::Specification.new do |s|
|
2
2
|
s.name = 'synthesis'
|
3
|
-
s.version = '0.2.
|
3
|
+
s.version = '0.2.7'
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.rubyforge_project = "synthesis"
|
6
|
-
s.summary, s.description = 'A tool for
|
6
|
+
s.summary, s.description = 'A tool for verifying mock object assumptions'
|
7
7
|
s.authors = 'Stuart Caborn, George Malamidis, Danilo Sato'
|
8
8
|
s.email = 'george@nutrun.com'
|
9
9
|
s.homepage = 'http://synthesis.rubyforge.org'
|
@@ -15,7 +15,6 @@ GEMSPEC =Gem::Specification.new do |s|
|
|
15
15
|
"Rakefile",
|
16
16
|
"README.rdoc",
|
17
17
|
"synthesis.gemspec",
|
18
|
-
"lib/synthesis/adapter/expectations.rb",
|
19
18
|
"lib/synthesis/adapter/mocha.rb",
|
20
19
|
"lib/synthesis/adapter/rspec.rb",
|
21
20
|
"lib/synthesis/adapter.rb",
|
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.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Caborn, George Malamidis, Danilo Sato
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-20 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: ""
|
17
17
|
email: george@nutrun.com
|
18
18
|
executables: []
|
19
19
|
|
@@ -27,7 +27,6 @@ files:
|
|
27
27
|
- Rakefile
|
28
28
|
- README.rdoc
|
29
29
|
- synthesis.gemspec
|
30
|
-
- lib/synthesis/adapter/expectations.rb
|
31
30
|
- lib/synthesis/adapter/mocha.rb
|
32
31
|
- lib/synthesis/adapter/rspec.rb
|
33
32
|
- lib/synthesis/adapter.rb
|
@@ -54,6 +53,8 @@ files:
|
|
54
53
|
- lib/synthesis.rb
|
55
54
|
has_rdoc: true
|
56
55
|
homepage: http://synthesis.rubyforge.org
|
56
|
+
licenses: []
|
57
|
+
|
57
58
|
post_install_message:
|
58
59
|
rdoc_options:
|
59
60
|
- --quiet
|
@@ -79,9 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
requirements: []
|
80
81
|
|
81
82
|
rubyforge_project: synthesis
|
82
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.4
|
83
84
|
signing_key:
|
84
|
-
specification_version:
|
85
|
-
summary: A tool for
|
85
|
+
specification_version: 3
|
86
|
+
summary: A tool for verifying mock object assumptions
|
86
87
|
test_files: []
|
87
88
|
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "mocha_standalone"
|
3
|
-
require "expectations"
|
4
|
-
|
5
|
-
require File.dirname(__FILE__) + "/../../synthesis"
|
6
|
-
|
7
|
-
module Synthesis
|
8
|
-
class ExpectationsAdapter < Adapter
|
9
|
-
def run
|
10
|
-
fail_unless { Expectations::SuiteRunner.instance.suite.execute }
|
11
|
-
end
|
12
|
-
|
13
|
-
def collect_expectations
|
14
|
-
ignore_instances_of Class::AnyInstance
|
15
|
-
Object.extend(ExpectationRecorder)
|
16
|
-
Object.record_expectations_on(:expects)
|
17
|
-
Mocha::Expectation.extend(ExpectationInterceptor)
|
18
|
-
Mocha::Expectation.intercept_test_subject_on(:invoke)
|
19
|
-
Mocha::Expectation.intercept_expected_arguments_on(:with)
|
20
|
-
Mocha::Expectation.intercept_expected_return_values_on(:returns)
|
21
|
-
Mocha::Expectation.intercept_expected_return_values_on(:raises)
|
22
|
-
Mocha::Expectation.remove_expectation_on(:never)
|
23
|
-
end
|
24
|
-
|
25
|
-
def stop_collecting_expectations
|
26
|
-
Mocha::Expectation.stop_intercepting!
|
27
|
-
Object.stop_recording!
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Expectations::SuiteRunner
|
33
|
-
def initialize
|
34
|
-
self.suite = Expectations::Suite.new
|
35
|
-
end
|
36
|
-
end
|