expectations 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -45,17 +45,17 @@ expectations can be used for state based and behavior based testing.
45
45
  require File.dirname(__FILE__) + "/test_helper"
46
46
 
47
47
  Expectations do
48
-
48
+
49
49
  # State based expectation where a value equals another value
50
50
  expect 2 do
51
51
  1 + 1
52
52
  end
53
-
53
+
54
54
  # State based expectation where an exception is expected. Simply expect the Class of the intended exception
55
55
  expect NoMethodError do
56
56
  Object.no_method
57
57
  end
58
-
58
+
59
59
  # Behavior based test using a traditional mock
60
60
  expect mock.to.receive(:dial).with("2125551212").times(2) do |phone|
61
61
  phone.dial("2125551212")
@@ -78,34 +78,22 @@ expectations can be used for state based and behavior based testing.
78
78
  expect Object.to.receive(:deal) do
79
79
  Object.deal
80
80
  end
81
-
81
+
82
82
  # State based test utilizing a stub
83
83
  expect 2 do
84
84
  stub(:two => 2).two
85
85
  end
86
-
87
- # State based test utilizing a concrete mock
88
- expect 2 do
89
- Object.expects(:bar).returns 2
90
- Object.bar
91
- end
92
-
93
- # Behavior based test utilizing a stub and a concrete mock
94
- expect 1 do
95
- Object.expects(:give_me_three).with(3).returns 1
96
- Object.give_me_three(stub(:three=>3).three)
97
- end
98
-
86
+
99
87
  # State based test matching a Regexp
100
88
  expect /a string/ do
101
89
  "a string"
102
90
  end
103
-
91
+
104
92
  # State based test checking if actual is in the expected Range
105
93
  expect 1..5 do
106
94
  3
107
95
  end
108
-
96
+
109
97
  # State based test to determine if the object is an instance of the module
110
98
  expect Enumerable do
111
99
  []
@@ -115,33 +103,33 @@ expectations can be used for state based and behavior based testing.
115
103
  expect String do
116
104
  "a string"
117
105
  end
118
-
106
+
119
107
  # State based test to determine if the modules are the same
120
108
  expect Enumerable do
121
109
  Enumerable
122
110
  end
123
-
111
+
124
112
  # State based test to determine if the classes are the same
125
113
  expect String do
126
114
  String
127
115
  end
128
-
116
+
129
117
  # State based test with XML strings, whitespace between tags is ignored
130
118
  expect xml("<a><foo>bar</foo></a>") do
131
119
  "<a>\n\t<foo>bar</foo> \n</a>"
132
120
  end
133
-
121
+
134
122
  # State based test with XML strings, whitespace between tags is ignored
135
123
  expect xml(<<-eos) do
136
124
  <one>
137
- <two>
138
- <three>4</three>
139
- <five> 6 </five>
140
- </two>
125
+ <two>
126
+ <three>4</three>
127
+ <five> 6 </five>
128
+ </two>
141
129
  </one>
142
130
  eos
143
131
  "<one><two><three>4</three>
144
- <five> 6 </five>
132
+ <five> 6 </five>
145
133
  </two></one>"
146
134
  end
147
135
 
@@ -155,7 +143,7 @@ expectations can be used for state based and behavior based testing.
155
143
  expect klass.new.to.delegate(:save).to(:record) do |instance|
156
144
  instance.save(1)
157
145
  end
158
-
146
+
159
147
  # this is normally defined in the file specific to the class
160
148
  klass = Class.new do
161
149
  attr_accessor :started
@@ -164,7 +152,7 @@ expectations can be used for state based and behavior based testing.
164
152
  expect klass.new.to.be.started do |process|
165
153
  process.started = true
166
154
  end
167
-
155
+
168
156
  # this is normally defined in the file specific to the class
169
157
  klass = Class.new do
170
158
  attr_accessor :finished
@@ -173,9 +161,12 @@ expectations can be used for state based and behavior based testing.
173
161
  expect klass.new.to.have.finished do |process|
174
162
  process.finished = true
175
163
  end
176
-
164
+
165
+ expect nil.to.be.nil?
166
+ expect Object.not.to.be.nil?
167
+
177
168
  end
178
169
 
179
170
  == Contributors
180
171
 
181
- Matt Mower, Ola Bini, George Malamidis, Brian Guthrie, Philippe Hanrigou, Steve McLarnon, Rubikitch
172
+ Matt Mower, Ola Bini, George Malamidis, Brian Guthrie, Philippe Hanrigou, Steve McLarnon, Rubikitch, Subhash Gupta, Holger Kohnen
@@ -6,6 +6,10 @@ module Expectations::RecordedExpectation
6
6
  warn_for_expects do
7
7
  instance_exec(expected.subject, &block) if block
8
8
  end
9
+ if expected.subject.is_a?(Mocha::Mock) &&
10
+ !Mocha::Mockery.instance.mocks.include?(expected.subject)
11
+ Mocha::Mockery.instance.__send__(:add_mock, expected.subject)
12
+ end
9
13
  if expected.verify! && mocha_verify
10
14
  self.extend(Expectations::Results::Fulfilled)
11
15
  else
data/rakefile.rb CHANGED
@@ -26,7 +26,6 @@ task :readme do
26
26
  %x[erb README_TEMPLATE > README]
27
27
  end
28
28
 
29
-
30
29
  desc "Upload RDoc to RubyForge"
31
30
  task :publish_rdoc do
32
31
  Rake::Task[:readme].invoke
@@ -34,8 +33,6 @@ task :publish_rdoc do
34
33
  Rake::SshDirPublisher.new("jaycfields@rubyforge.org", "/var/www/gforge-projects/expectations", "doc").upload
35
34
  end
36
35
 
37
- Gem::manage_gems
38
-
39
36
  specification = Gem::Specification.new do |s|
40
37
  s.name = "expectations"
41
38
  s.summary = "A lightweight unit testing framework. Tests (expectations) will be written as follows
@@ -46,7 +43,7 @@ specification = Gem::Specification.new do |s|
46
43
  expect NoMethodError do
47
44
  Object.invalid_method_call
48
45
  end."
49
- s.version = "1.2.0"
46
+ s.version = "1.2.1"
50
47
  s.author = 'Jay Fields'
51
48
  s.description = "A lightweight unit testing framework. Tests (expectations) will be written as follows
52
49
  expect 2 do
@@ -20,6 +20,15 @@ Expectations do
20
20
  suite.execute(Silent).succeeded?
21
21
  end
22
22
 
23
+ expect false do
24
+ suite = Expectations::Suite.new
25
+ suite.expect(true) { true }
26
+ suite.expect suite.mock.to.receive(:some_method) do |some_mock|
27
+ # some_method is not called
28
+ end
29
+ suite.execute(Silent).succeeded?
30
+ end
31
+
23
32
  expect Mocha::Mock do
24
33
  Expectations::Suite.new.mock
25
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Fields
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-28 00:00:00 +01:00
12
+ date: 2009-04-22 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mocha
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -30,43 +31,43 @@ extensions: []
30
31
  extra_rdoc_files:
31
32
  - README
32
33
  files:
34
+ - lib/expectations.rb
35
+ - lib/expectations/range.rb
36
+ - lib/expectations/reverse_result.rb
33
37
  - lib/expectations/blank_slate.rb
34
- - lib/expectations/delegate_recorder.rb
35
- - lib/expectations/expectation.rb
36
- - lib/expectations/mock_recorder.rb
37
- - lib/expectations/module.rb
38
38
  - lib/expectations/object.rb
39
- - lib/expectations/range.rb
40
- - lib/expectations/recorded_expectation.rb
41
- - lib/expectations/recorder.rb
42
- - lib/expectations/regexp.rb
39
+ - lib/expectations/mock_recorder.rb
40
+ - lib/expectations/suite_runner.rb
43
41
  - lib/expectations/results.rb
44
- - lib/expectations/reverse_result.rb
45
- - lib/expectations/standard_error.rb
46
- - lib/expectations/state_based_expectation.rb
47
- - lib/expectations/state_based_recorder.rb
48
- - lib/expectations/string.rb
42
+ - lib/expectations/xml_string.rb
43
+ - lib/expectations/expectation.rb
49
44
  - lib/expectations/suite.rb
45
+ - lib/expectations/state_based_recorder.rb
46
+ - lib/expectations/state_based_expectation.rb
47
+ - lib/expectations/recorded_expectation.rb
48
+ - lib/expectations/standard_error.rb
50
49
  - lib/expectations/suite_results.rb
51
- - lib/expectations/suite_runner.rb
52
- - lib/expectations/xml_string.rb
53
- - lib/expectations.rb
50
+ - lib/expectations/recorder.rb
51
+ - lib/expectations/delegate_recorder.rb
52
+ - lib/expectations/module.rb
53
+ - lib/expectations/string.rb
54
+ - lib/expectations/regexp.rb
55
+ - test/failures_test.rb
56
+ - test/silent.rb
57
+ - test/test_helper.rb
58
+ - test/successes_test.rb
59
+ - test/expectations/regexp_test.rb
60
+ - test/expectations/suite_runner_test.rb
54
61
  - test/expectations/expectation_test.rb
55
- - test/expectations/expectations_test.rb
56
- - test/expectations/module_test.rb
62
+ - test/expectations/string_test.rb
57
63
  - test/expectations/object_test.rb
64
+ - test/expectations/expectations_test.rb
65
+ - test/expectations/xml_string_test.rb
58
66
  - test/expectations/range_test.rb
59
- - test/expectations/regexp_test.rb
60
- - test/expectations/results_test.rb
61
- - test/expectations/string_test.rb
62
- - test/expectations/suite_results_test.rb
63
- - test/expectations/suite_runner_test.rb
64
67
  - test/expectations/suite_test.rb
65
- - test/expectations/xml_string_test.rb
66
- - test/failures_test.rb
67
- - test/silent.rb
68
- - test/successes_test.rb
69
- - test/test_helper.rb
68
+ - test/expectations/suite_results_test.rb
69
+ - test/expectations/results_test.rb
70
+ - test/expectations/module_test.rb
70
71
  - rakefile.rb
71
72
  - README
72
73
  has_rdoc: true
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  requirements: []
96
97
 
97
98
  rubyforge_project: expectations
98
- rubygems_version: 1.0.1
99
+ rubygems_version: 1.3.1
99
100
  signing_key:
100
101
  specification_version: 2
101
102
  summary: A lightweight unit testing framework. Tests (expectations) will be written as follows expect 2 do 1 + 1 end expect NoMethodError do Object.invalid_method_call end.