synthesis 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -91,7 +91,7 @@ end
91
91
 
92
92
  gem_spec = Gem::Specification.new do |s|
93
93
  s.name = 'synthesis'
94
- s.version = '0.0.13'
94
+ s.version = '0.0.14'
95
95
  s.platform = Gem::Platform::RUBY
96
96
  s.rubyforge_project = "synthesis"
97
97
  s.summary, s.description = 'A tool for Synthesized Testing'
@@ -15,13 +15,13 @@ module Synthesis
15
15
  Object.extend(ExpectationRecordEnabled)
16
16
  Object.record_expectations_on(:expects)
17
17
  Mocha::Expectation.extend(ExpectationInterceptor)
18
- Mocha::Expectation.intercept_expected_argument_types_on(:with)
19
- Mocha::Expectation.intercept_expected_return_values_on(:returns)
18
+ Mocha::Expectation.record_expected_argument_types_on(:with)
19
+ Mocha::Expectation.record_expected_return_values_on(:returns)
20
20
  end
21
21
 
22
22
  def stop_collecting_expectations
23
- Mocha::Expectation.reset!
24
- Object.reset!
23
+ Mocha::Expectation.stop_intercepting!
24
+ Object.stop_recording!
25
25
  end
26
26
  end
27
27
  end
@@ -16,13 +16,13 @@ module Synthesis
16
16
  Object.extend(ExpectationRecordEnabled)
17
17
  Object.record_expectations_on(:expects)
18
18
  Mocha::Expectation.extend(ExpectationInterceptor)
19
- Mocha::Expectation.intercept_expected_argument_types_on(:with)
20
- Mocha::Expectation.intercept_expected_return_values_on(:returns)
19
+ Mocha::Expectation.record_expected_argument_types_on(:with)
20
+ Mocha::Expectation.record_expected_return_values_on(:returns)
21
21
  end
22
22
 
23
23
  def stop_collecting_expectations
24
- Mocha::Expectation.reset!
25
- Object.reset!
24
+ Mocha::Expectation.stop_intercepting!
25
+ Object.stop_recording!
26
26
  end
27
27
  end
28
28
  end
@@ -20,13 +20,13 @@ module Synthesis
20
20
  Spec::Mocks::Methods.extend(ExpectationRecordEnabled)
21
21
  Spec::Mocks::Methods.record_expectations_on(:should_receive)
22
22
  Spec::Mocks::MessageExpectation.extend(ExpectationInterceptor)
23
- Spec::Mocks::MessageExpectation.intercept_expected_argument_types_on(:with)
24
- Spec::Mocks::MessageExpectation.intercept_expected_return_values_on(:and_return)
23
+ Spec::Mocks::MessageExpectation.record_expected_argument_types_on(:with)
24
+ Spec::Mocks::MessageExpectation.record_expected_return_values_on(:and_return)
25
25
  end
26
26
 
27
27
  def stop_collecting_expectations
28
- Spec::Mocks::MessageExpectation.reset!
29
- Spec::Mocks::Methods.reset!
28
+ Spec::Mocks::MessageExpectation.stop_intercepting!
29
+ Spec::Mocks::Methods.stop_recording!
30
30
  end
31
31
  end
32
32
  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 intercept_expected_argument_types_on(method_name)
8
+ def record_expected_argument_types_on(method_name)
9
9
  @original_with = method_name
10
10
 
11
11
  class_eval <<-end_eval
@@ -20,7 +20,7 @@ module Synthesis
20
20
 
21
21
  # Intercept the mock object framework's expectation method for declaring a mocked
22
22
  # method's return values so that Synthesis can record them.
23
- def intercept_expected_return_values_on(method_name)
23
+ def record_expected_return_values_on(method_name)
24
24
  @original_returns = method_name
25
25
 
26
26
  class_eval <<-end_eval
@@ -37,7 +37,7 @@ module Synthesis
37
37
  # Restore the original methods ExpectationInterceptor has rewritten and
38
38
  # undefine their intercepted counterparts. Undefine the synthesis_expectation
39
39
  # accessors.
40
- def reset!
40
+ def stop_intercepting!
41
41
  class_eval <<-end_eval
42
42
  alias #{@original_with} intercepted_#{@original_with}
43
43
  alias #{@original_returns} intercepted_#{@original_returns}
@@ -17,7 +17,7 @@ module Synthesis
17
17
 
18
18
  def return_values_match?
19
19
  return true unless @expectation_one.return_values_defined? || @expectation_two.return_values_defined?
20
- (@expectation_one.return_value_types & @expectation_two.return_value_types).any?
20
+ @expectation_one.return_value_types == @expectation_two.return_value_types
21
21
  end
22
22
  end
23
23
  end
@@ -22,7 +22,7 @@ module Synthesis
22
22
 
23
23
  # Restore the original methods ExpectationRecordEnabled has rewritten and
24
24
  # undefine their intercepted counterparts.
25
- def reset!
25
+ def stop_recording!
26
26
  class_eval <<-end_eval
27
27
  alias #{@original_expects} intercepted_#{@original_expects}
28
28
  undef intercepted_#{@original_expects}
@@ -0,0 +1,18 @@
1
+ class Object
2
+ def self.mock_instance(*args)
3
+ class_eval do
4
+ alias original_initialize initialize
5
+ def initialize()end
6
+ end
7
+
8
+ instance = new
9
+ expects(:new).with(*args).returns(instance)
10
+
11
+ class_eval do
12
+ alias initialize original_initialize
13
+ undef original_initialize
14
+ end
15
+
16
+ return instance
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ module Spec::Mocks::Methods
2
+ def mock_instance(*args)
3
+ class_eval do
4
+ alias original_initialize initialize
5
+ def initialize()end
6
+ end
7
+
8
+ instance = new
9
+ should_receive(:new).with(*args).and_return(instance)
10
+
11
+ class_eval do
12
+ alias initialize original_initialize
13
+ undef original_initialize
14
+ end
15
+
16
+ return instance
17
+ end
18
+
19
+ # Don't know if this sucks or not...
20
+
21
+ # def stub_instance
22
+ # class_eval do
23
+ # alias original_initialize initialize
24
+ # def initialize()end
25
+ # end
26
+ #
27
+ # instance = new
28
+ # stub!(:new).and_return(instance)
29
+ #
30
+ # class_eval do
31
+ # alias initialize original_initialize
32
+ # undef original_initialize
33
+ # end
34
+ #
35
+ # return instance
36
+ # end
37
+ end
@@ -39,7 +39,7 @@ module Synthesis
39
39
  assert(!ExpectationMatcher.new(exp1, exp2).match?)
40
40
  end
41
41
 
42
- def test_match_based_on_intersection_of_return_value_types
42
+ def test_match_based_on_return_value_types
43
43
  exp1 = Expectation.new(Object.new, :foo, :track, [Array, Hash], [[1], {:a => :b}])
44
44
  exp2 = Expectation.new(Object.new, :foo, :track, [Array, Hash], [[4], {:a => 9}])
45
45
  assert(ExpectationMatcher.new(exp1, exp2).match?)
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.13
4
+ version: 0.0.14
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-05-19 00:00:00 +01:00
12
+ date: 2008-05-21 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -41,6 +41,8 @@ files:
41
41
  - lib/synthesis/reporter.rb
42
42
  - lib/synthesis/runner.rb
43
43
  - lib/synthesis/task.rb
44
+ - lib/synthesis/util/mock_instance/mocha.rb
45
+ - lib/synthesis/util/mock_instance/rspec.rb
44
46
  - lib/synthesis.rb
45
47
  - test/synthesis/adapter/mocha/expectation_record_test.rb
46
48
  - test/synthesis/adapter/mocha/helper.rb