synthesis 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -32,7 +32,7 @@ By default, Synthesis outputs to +STDOUT+, but output can be redirected to alter
32
32
 
33
33
  Synthesis can be setup to ignore certain classes or modules when collecting expectations for verification.
34
34
 
35
- If +pattern+ is not specified, it will default to <tt>test/**/*.rb</tt>
35
+ If +pattern+ is not specified, it will default to <tt>test/**/*_test.rb</tt>
36
36
 
37
37
  == Usage examples
38
38
 
data/Rakefile CHANGED
@@ -5,6 +5,8 @@ require 'rake/rdoctask'
5
5
  require 'rake/contrib/sshpublisher'
6
6
  require File.dirname(__FILE__) + "/lib/synthesis/task"
7
7
 
8
+ load 'synthesis.gemspec'
9
+
8
10
  task :default => :test
9
11
 
10
12
  desc "Run all tests"
@@ -56,24 +58,7 @@ task :publish_rdoc do
56
58
  Rake::SshDirPublisher.new("gmalamid@rubyforge.org", "/var/www/gforge-projects/synthesis", "doc").upload
57
59
  end
58
60
 
59
- gem_spec = Gem::Specification.new do |s|
60
- s.name = 'synthesis'
61
- s.version = '0.1.4'
62
- s.platform = Gem::Platform::RUBY
63
- s.rubyforge_project = "synthesis"
64
- s.summary, s.description = 'A tool for Synthesized Testing'
65
- s.authors = 'Stuart Caborn, George Malamidis'
66
- s.email = 'george@nutrun.com'
67
- s.homepage = 'http://synthesis.rubyforge.org'
68
- s.has_rdoc = true
69
- s.rdoc_options += ['--quiet', '--title', 'Synthesis', '--main', 'README', '--inline-source']
70
- s.extra_rdoc_files = ['README', 'COPYING']
71
- excluded = FileList['etc/*']
72
- # s.test_files = FileList['test/**/*_test.rb']
73
- s.files = FileList['**/*.rb', 'COPYING', 'README', 'Rakefile'] - excluded
74
- end
75
-
76
- Rake::GemPackageTask.new(gem_spec) do |t|
61
+ Rake::GemPackageTask.new(GEMSPEC) do |t|
77
62
  t.need_zip = false
78
63
  t.need_tar = false
79
64
  end
@@ -19,6 +19,7 @@ module Synthesis
19
19
  Mocha::Expectation.record_expected_arguments_on(:with)
20
20
  Mocha::Expectation.record_expected_return_values_on(:returns)
21
21
  Mocha::Expectation.record_expected_return_values_on(:raises)
22
+ Mocha::Expectation.remove_expectation_on(:never)
22
23
  end
23
24
 
24
25
  def stop_collecting_expectations
@@ -23,6 +23,7 @@ module Synthesis
23
23
  Spec::Mocks::MessageExpectation.record_expected_arguments_on(:with)
24
24
  Spec::Mocks::MessageExpectation.record_expected_return_values_on(:and_return)
25
25
  Spec::Mocks::MessageExpectation.record_expected_return_values_on(:and_raise)
26
+ Spec::Mocks::MessageExpectation.remove_expectation_on(:never)
26
27
  end
27
28
 
28
29
  def stop_collecting_expectations
@@ -39,6 +39,19 @@ module Synthesis
39
39
  end
40
40
  end
41
41
 
42
+ def remove_expectation_on(method_name)
43
+ (@original_methods ||= []) << method_name
44
+
45
+ class_eval do
46
+ alias_method "intercepted_#{method_name}", method_name
47
+
48
+ define_method(method_name) do |*values|
49
+ Synthesis::ExpectationRecord.remove(synthesis_expectation) if synthesis_expectation
50
+ send("intercepted_#{method_name}")
51
+ end
52
+ end
53
+ end
54
+
42
55
  # Restore the original methods ExpectationInterceptor has rewritten and
43
56
  # undefine their intercepted counterparts. Undefine the synthesis_expectation
44
57
  # accessors.
@@ -10,6 +10,10 @@ module Synthesis
10
10
  expectation
11
11
  end
12
12
  end
13
+
14
+ def remove(expectation)
15
+ expectations.delete(expectation)
16
+ end
13
17
 
14
18
  def ignore(*args)
15
19
  ignored.merge(args)
@@ -11,7 +11,7 @@ module Synthesis
11
11
  def initialize(name='synthesis:test')
12
12
  @name, @ignored = name, []
13
13
  yield self if block_given?
14
- @pattern ||= 'test/**/*.rb'
14
+ @pattern ||= 'test/**/*_test.rb'
15
15
  @ruby_opts ||= []
16
16
  @adapter ||= :mocha
17
17
  define
@@ -78,5 +78,12 @@ module Synthesis
78
78
  ExpectationRecord.record_invocations
79
79
  ExpectationRecord.expectations.each { |val| assert(!val.is_a?(Array)) }
80
80
  end
81
+
82
+ def test_removes_expectation
83
+ c = Class.new { def foo; end }
84
+ expectation = ExpectationRecord.add_expectation(c, :foo, :track)
85
+ ExpectationRecord.remove(expectation)
86
+ assert_equal(0, ExpectationRecord.expectations.size)
87
+ end
81
88
  end
82
89
  end
@@ -15,4 +15,7 @@ Expectations do
15
15
  expect Problem do
16
16
  Storage.new("").ouch!
17
17
  end
18
+
19
+ # expect(Storage.new("").to.receive(:never_call_me).never) {}
20
+
18
21
  end
@@ -1,6 +1,8 @@
1
1
  require "test/unit"
2
2
  require "fileutils"
3
3
  require File.dirname(__FILE__) + "/../../test_project"
4
+ require "rubygems"
5
+ require "mocha"
4
6
 
5
7
  class StorageTest < Test::Unit::TestCase
6
8
  def test_saves_to_file
@@ -21,4 +23,9 @@ class StorageTest < Test::Unit::TestCase
21
23
  def test_ok_raises_problem_when_not_given_ok
22
24
  assert_raise(Problem) { Storage.new("").ok_or_problem(:not_ok) }
23
25
  end
26
+
27
+ def test_never_called
28
+ storage = Storage.new("")
29
+ storage.expects(:never_call_me).never
30
+ end
24
31
  end
@@ -22,4 +22,9 @@ describe Storage do
22
22
  it "should raise problem when not give :ok" do
23
23
  proc { Storage.new("").ok_or_problem(:not_ok) }.should raise_error(Problem)
24
24
  end
25
+
26
+ it "should never call" do
27
+ storage = Storage.new("")
28
+ storage.should_receive(:never_call_me).never
29
+ end
25
30
  end
@@ -38,6 +38,10 @@ class Storage
38
38
  def ok_or_problem(ok)
39
39
  ok == :ok ? ok : raise(Problem)
40
40
  end
41
+
42
+ def never_call_me
43
+ :whatever
44
+ end
41
45
  end
42
46
 
43
47
  class Problem < Exception;end
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.1.4
4
+ version: 0.1.5
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-06-16 00:00:00 +01:00
12
+ date: 2008-07-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  requirements: []
101
101
 
102
102
  rubyforge_project: synthesis
103
- rubygems_version: 1.1.1
103
+ rubygems_version: 1.2.0
104
104
  signing_key:
105
105
  specification_version: 2
106
106
  summary: A tool for Synthesized Testing