gmalamid-synthesis 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/synthesis/adapter/expectations.rb +4 -4
- data/lib/synthesis/adapter/mocha.rb +4 -4
- data/lib/synthesis/adapter/rspec.rb +13 -13
- data/lib/synthesis/expectation_interceptor.rb +2 -2
- data/lib/synthesis/{expectation_record_enabled.rb → expectation_recorder.rb} +2 -2
- data/lib/synthesis.rb +1 -1
- data/synthesis.gemspec +2 -2
- metadata +2 -2
data/README
CHANGED
@@ -12,12 +12,12 @@ module Synthesis
|
|
12
12
|
|
13
13
|
def collect_expectations
|
14
14
|
ignore_instances_of Class::AnyInstance
|
15
|
-
Object.extend(
|
15
|
+
Object.extend(ExpectationRecorder)
|
16
16
|
Object.record_expectations_on(:expects)
|
17
17
|
Mocha::Expectation.extend(ExpectationInterceptor)
|
18
|
-
Mocha::Expectation.
|
19
|
-
Mocha::Expectation.
|
20
|
-
Mocha::Expectation.
|
18
|
+
Mocha::Expectation.intercept_expected_arguments_on(:with)
|
19
|
+
Mocha::Expectation.intercept_expected_return_values_on(:returns)
|
20
|
+
Mocha::Expectation.intercept_expected_return_values_on(:raises)
|
21
21
|
Mocha::Expectation.remove_expectation_on(:never)
|
22
22
|
end
|
23
23
|
|
@@ -13,12 +13,12 @@ module Synthesis
|
|
13
13
|
|
14
14
|
def collect_expectations
|
15
15
|
ignore_instances_of Class::AnyInstance
|
16
|
-
Object.extend(
|
16
|
+
Object.extend(ExpectationRecorder)
|
17
17
|
Object.record_expectations_on(:expects)
|
18
18
|
Mocha::Expectation.extend(ExpectationInterceptor)
|
19
|
-
Mocha::Expectation.
|
20
|
-
Mocha::Expectation.
|
21
|
-
Mocha::Expectation.
|
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
22
|
Mocha::Expectation.remove_expectation_on(:never)
|
23
23
|
end
|
24
24
|
|
@@ -7,22 +7,28 @@ require File.dirname(__FILE__) + "/../../synthesis"
|
|
7
7
|
module Synthesis
|
8
8
|
class RSpecAdapter < Adapter
|
9
9
|
def run
|
10
|
-
Synthesis.rspec_runner_options.files.clear
|
11
10
|
fail_unless do
|
12
|
-
|
11
|
+
rspec_options = begin
|
12
|
+
Spec::Runner.options
|
13
|
+
rescue
|
14
|
+
rspec_options
|
15
|
+
end
|
16
|
+
|
17
|
+
rspec_options.files.clear
|
18
|
+
rspec_options.instance_variable_set(:@formatters, nil)
|
19
|
+
rspec_options.run_examples
|
13
20
|
# Synthesis.rspec_runner_options.instance_variable_set(:@format_options, [["profile", STDOUT]])
|
14
|
-
Synthesis.rspec_runner_options.run_examples
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
24
|
def collect_expectations
|
19
25
|
ignore_instances_of Spec::Mocks::Mock
|
20
|
-
Spec::Mocks::Methods.extend(
|
26
|
+
Spec::Mocks::Methods.extend(ExpectationRecorder)
|
21
27
|
Spec::Mocks::Methods.record_expectations_on(:should_receive)
|
22
28
|
Spec::Mocks::MessageExpectation.extend(ExpectationInterceptor)
|
23
|
-
Spec::Mocks::MessageExpectation.
|
24
|
-
Spec::Mocks::MessageExpectation.
|
25
|
-
Spec::Mocks::MessageExpectation.
|
29
|
+
Spec::Mocks::MessageExpectation.intercept_expected_arguments_on(:with)
|
30
|
+
Spec::Mocks::MessageExpectation.intercept_expected_return_values_on(:and_return)
|
31
|
+
Spec::Mocks::MessageExpectation.intercept_expected_return_values_on(:and_raise)
|
26
32
|
Spec::Mocks::MessageExpectation.remove_expectation_on(:never)
|
27
33
|
end
|
28
34
|
|
@@ -31,10 +37,4 @@ module Synthesis
|
|
31
37
|
Spec::Mocks::Methods.stop_recording!
|
32
38
|
end
|
33
39
|
end
|
34
|
-
|
35
|
-
def rspec_runner_options
|
36
|
-
Spec::Runner.options rescue rspec_options
|
37
|
-
end
|
38
|
-
|
39
|
-
module_function :rspec_runner_options
|
40
40
|
end
|
@@ -5,7 +5,7 @@ module Synthesis
|
|
5
5
|
module ExpectationInterceptor
|
6
6
|
# Intercept the mock object framework's expectation method for declaring a mocked
|
7
7
|
# method's arguments so that Synthesis can record them.
|
8
|
-
def
|
8
|
+
def intercept_expected_arguments_on(method_name)
|
9
9
|
(@original_methods ||= []) << method_name
|
10
10
|
|
11
11
|
class_eval do
|
@@ -25,7 +25,7 @@ module Synthesis
|
|
25
25
|
|
26
26
|
# Intercept the mock object framework's expectation method for declaring a mocked
|
27
27
|
# method's return values so that Synthesis can record them.
|
28
|
-
def
|
28
|
+
def intercept_expected_return_values_on(method_name)
|
29
29
|
(@original_methods ||= []) << method_name
|
30
30
|
|
31
31
|
class_eval do
|
@@ -2,7 +2,7 @@ module Synthesis
|
|
2
2
|
# Extend by the mock object framework's construct for declaring a
|
3
3
|
# mock object so that Synthesis can tap into it in order to record
|
4
4
|
# the expectation.
|
5
|
-
module
|
5
|
+
module ExpectationRecorder
|
6
6
|
# Intercept the mock object framework's method for declaring a mock
|
7
7
|
# object so that Synthesis can record it.
|
8
8
|
def record_expectations_on(method_name)
|
@@ -25,7 +25,7 @@ module Synthesis
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
# Restore the original methods
|
28
|
+
# Restore the original methods ExpectationRecorder has rewritten and
|
29
29
|
# undefine their intercepted counterparts.
|
30
30
|
def stop_recording!
|
31
31
|
method_name = @original_expects
|
data/lib/synthesis.rb
CHANGED
@@ -12,6 +12,6 @@ require "synthesis/method_invocation_watcher"
|
|
12
12
|
require "synthesis/expectation"
|
13
13
|
require "synthesis/expectation_matcher"
|
14
14
|
require "synthesis/expectation_interceptor"
|
15
|
-
require "synthesis/
|
15
|
+
require "synthesis/expectation_recorder"
|
16
16
|
require "synthesis/reporter"
|
17
17
|
require "synthesis/adapter"
|
data/synthesis.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GEMSPEC =Gem::Specification.new do |s|
|
2
2
|
s.name = 'synthesis'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.8'
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.rubyforge_project = "synthesis"
|
6
6
|
s.summary, s.description = 'A tool for Synthesized Testing'
|
@@ -24,7 +24,7 @@ GEMSPEC =Gem::Specification.new do |s|
|
|
24
24
|
"lib/synthesis/expectation_interceptor.rb",
|
25
25
|
"lib/synthesis/expectation_matcher.rb",
|
26
26
|
"lib/synthesis/expectation_record.rb",
|
27
|
-
"lib/synthesis/
|
27
|
+
"lib/synthesis/expectation_recorder.rb",
|
28
28
|
"lib/synthesis/logging.rb",
|
29
29
|
"lib/synthesis/method_invocation_watcher.rb",
|
30
30
|
"lib/synthesis/module.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmalamid-synthesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Caborn, George Malamidis
|
@@ -36,7 +36,7 @@ files:
|
|
36
36
|
- lib/synthesis/expectation_interceptor.rb
|
37
37
|
- lib/synthesis/expectation_matcher.rb
|
38
38
|
- lib/synthesis/expectation_record.rb
|
39
|
-
- lib/synthesis/
|
39
|
+
- lib/synthesis/expectation_recorder.rb
|
40
40
|
- lib/synthesis/logging.rb
|
41
41
|
- lib/synthesis/method_invocation_watcher.rb
|
42
42
|
- lib/synthesis/module.rb
|