must_be 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,4 +1,9 @@
1
- # dynamic_variable 1.0.2 2010-09-29
1
+ # must_be 1.0.3 2010-11-01
2
+
3
+ * Update to use RSpec-2.
4
+ * Add development dependencies.
5
+
6
+ # must_be 1.0.2 2010-09-29
2
7
 
3
8
  * Update for compatibility with Ruby 1.8.6.
4
9
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require 'spec/rake/spectask'
1
+ require 'rspec/core/rake_task'
2
2
 
3
3
  begin
4
4
  require 'jeweler'
@@ -9,6 +9,9 @@ begin
9
9
  gemspec.email = "wtaysom@gmail.com"
10
10
  gemspec.homepage = "http://github.com/wtaysom/must_be"
11
11
  gemspec.authors = ["William Taysom"]
12
+
13
+ gemspec.add_development_dependency('jeweler', '~> 1.4')
14
+ gemspec.add_development_dependency('rspec', '~> 2.0')
12
15
  end
13
16
  Jeweler::GemcutterTasks.new
14
17
  rescue LoadError
@@ -16,9 +19,9 @@ rescue LoadError
16
19
  end
17
20
 
18
21
  desc "Run the spec suite against rcov"
19
- Spec::Rake::SpecTask.new(:rcov_helper) do |t|
22
+ RSpec::Core::RakeTask.new(:rcov_helper) do |t|
20
23
  t.rcov = true
21
- t.rcov_opts = ['--exclude', '/Library/Ruby/Gems/']
24
+ t.rcov_opts = %q{--exclude "gems/,spec/"}
22
25
  end
23
26
 
24
27
  desc "Run the spec suite against rcov and open coverage results"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -54,12 +54,12 @@ class Module
54
54
  end
55
55
  ))
56
56
 
57
- module_eval %Q{
57
+ module_eval(<<-END, __FILE__, __LINE__ + 1)
58
58
  def #{name}=(value)
59
59
  #{check_method_name}(value)
60
60
  @#{name} = value
61
61
  end
62
- }
62
+ END
63
63
  end
64
64
 
65
65
  MustBe.register_disabled_handler do |enabled|
@@ -152,7 +152,7 @@ module MustBe
152
152
  module ClassMethods
153
153
  def must_check_contents_after(*methods)
154
154
  methods.each do |method|
155
- module_eval %Q{
155
+ module_eval(<<-END, __FILE__, __LINE__ + 1)
156
156
  def #{method}(*args)
157
157
  begin
158
158
  super
@@ -160,7 +160,7 @@ module MustBe
160
160
  must_check_contents
161
161
  end
162
162
  end
163
- }
163
+ END
164
164
  end
165
165
  end
166
166
  end
@@ -229,11 +229,11 @@ module MustBe
229
229
 
230
230
  REGISTERED_CLASSES[klass] = mod = Module.new
231
231
  mod.send(:include, Base)
232
- mod.class_eval &body
232
+ mod.class_eval(&body)
233
233
 
234
234
  mutator_advice = Module.new
235
235
  mod.instance_methods(false).each do |method_name|
236
- mutator_advice.module_eval %Q{
236
+ mutator_advice.module_eval(<<-END, __FILE__, __LINE__ + 1)
237
237
  def #{method_name}(*args, &block)
238
238
  must_check(lambda { super(*args, &block) }) do |note|
239
239
  note.prefix = nil
@@ -244,7 +244,7 @@ module MustBe
244
244
  note
245
245
  end
246
246
  end
247
- }
247
+ END
248
248
  end
249
249
  mod.const_set(:MutatorAdvice, mutator_advice)
250
250
  mod.instance_eval do
data/must_be.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{must_be}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Taysom"]
12
- s.date = %q{2010-09-29}
12
+ s.date = %q{2010-11-01}
13
13
  s.description = %q{must_be provides runtime assertions which can easily be disabled in production environments. Likewise, the notifier can be customized to raise errors, log failure, enter the debugger, or anything else.}
14
14
  s.email = %q{wtaysom@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -65,9 +65,15 @@ Gem::Specification.new do |s|
65
65
  s.specification_version = 3
66
66
 
67
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
+ s.add_development_dependency(%q<jeweler>, ["~> 1.4"])
69
+ s.add_development_dependency(%q<rspec>, ["~> 2.0"])
68
70
  else
71
+ s.add_dependency(%q<jeweler>, ["~> 1.4"])
72
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
69
73
  end
70
74
  else
75
+ s.add_dependency(%q<jeweler>, ["~> 1.4"])
76
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
71
77
  end
72
78
  end
73
79
 
@@ -719,10 +719,8 @@ describe MustBe do
719
719
  end
720
720
  end
721
721
  end
722
-
723
- describe "custom" do
724
- it_should_behave_like "custom MustOnlyEverContain"
725
-
722
+
723
+ it_should_behave_like "custom MustOnlyEverContain" do
726
724
  context "without MustOnlyEverContain.registered_class" do
727
725
  describe '#must_only_contain' do
728
726
  it "should use each to check the contents" do
@@ -881,9 +879,7 @@ describe MustBe do
881
879
  end
882
880
  end
883
881
 
884
- describe "custom" do
885
- it_should_behave_like "custom MustOnlyEverContain"
886
-
882
+ it_should_behave_like "custom MustOnlyEverContain" do
887
883
  describe "without MustOnlyEverContain.registered_class" do
888
884
  describe '#must_not_contain' do
889
885
  it "should use each to check the contents" do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'stringio'
2
3
 
3
4
  describe MustBe do
4
5
  include MustBeExampleHelper
@@ -634,13 +634,13 @@ describe MustBe do
634
634
  throw :ball, :gently
635
635
  end
636
636
  ensure
637
- note = @note
638
- @note = nil
637
+ note = $note
638
+ $note = nil
639
639
  end
640
640
  end
641
641
  ensure
642
- outer_note = @note
643
- @note = nil
642
+ outer_note = $note
643
+ $note = nil
644
644
  end
645
645
  end
646
646
  end.should throw_symbol(:ball)
@@ -825,13 +825,13 @@ describe MustBe do
825
825
  throw :ball, :gently
826
826
  end
827
827
  ensure
828
- note = @note
829
- @note = nil
828
+ note = $note
829
+ $note = nil
830
830
  end
831
831
  end
832
832
  ensure
833
- outer_note = @note
834
- @note = nil
833
+ outer_note = $note
834
+ $note = nil
835
835
  end
836
836
  end
837
837
  end.should throw_symbol(:ball)
@@ -29,14 +29,14 @@ describe MustBe do
29
29
  module ItShouldNotifyExpectations
30
30
  def it_should_notify(message, &implementation)
31
31
  example "#{message} should notify" do
32
- instance_eval &implementation
32
+ instance_eval(&implementation)
33
33
  should notify(message)
34
34
  end
35
35
  end
36
36
 
37
37
  def it_should_not_notify(message, &implementation)
38
38
  example "#{message} should not notify" do
39
- instance_eval &implementation
39
+ instance_eval(&implementation)
40
40
  should_not notify
41
41
  end
42
42
  end
@@ -29,10 +29,19 @@ describe "Notify Matcher" do
29
29
  end
30
30
 
31
31
  pattern_notify.send(result ? :should : :should_not, raise_error(
32
- Spec::Expectations::ExpectationNotMetError, result))
32
+ RSpec::Expectations::ExpectationNotMetError, result))
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ context "when called with more than one argument" do
38
+ it "should raise ArgumentError" do
39
+ expect do
40
+ :it.should notify("one", "two")
41
+ end.should raise_error(ArgumentError,
42
+ "wrong number of arguments (2 for 1)")
43
+ end
44
+ end
36
45
 
37
46
  it_should_follow_pattern :note, :should, nil, nil
38
47
  it_should_follow_pattern :note, :should, 'same', nil
data/spec/spec_helper.rb CHANGED
@@ -55,6 +55,8 @@ end
55
55
 
56
56
  ### MustBeExampleHelper ###
57
57
 
58
+ require 'rspec'
59
+
58
60
  module MustBeExampleHelper
59
61
 
60
62
  $default_must_be_notifier = MustBe.notifier
@@ -62,10 +64,14 @@ module MustBeExampleHelper
62
64
  def self.included(example_group)
63
65
  example_group.before do
64
66
  MustBe.notifier = lambda do |note|
65
- @note = note
67
+ $note = note
66
68
  false
67
69
  end
68
70
  end
71
+
72
+ example_group.after do
73
+ $note = nil
74
+ end
69
75
 
70
76
  class <<example_group
71
77
 
@@ -141,40 +147,54 @@ module MustBeExampleHelper
141
147
 
142
148
  ### Notify Matcher ###
143
149
 
144
- def notify(message = nil)
145
- simple_matcher do |given, matcher|
146
- result, message =
147
- if @note
148
- if message
149
- if message === @note.message
150
- [true,
151
- "did NOT expect note with message: #{message.inspect}\n"\
152
- " got note with message: #{@note.message.inspect}"]
153
- else
154
- [false,
155
- "expected note with message: #{message.inspect}\n"\
156
- " got note with message: #{@note.message.inspect}"]
157
- end
150
+ RSpec::Matchers.define :notify do |*message|
151
+ if (count = message.size) > 1
152
+ raise ArgumentError, "wrong number of arguments (#{count} for 1)"
153
+ end
154
+ message = message[0]
155
+
156
+ def does(message)
157
+ @message = message
158
+ true
159
+ end
160
+
161
+ def does_not(message)
162
+ @message = message
163
+ false
164
+ end
165
+
166
+ match do |given|
167
+ if $note
168
+ if message
169
+ if message === $note.message
170
+ does(
171
+ "did NOT expect note with message: #{message.inspect}\n"\
172
+ " got note with message: #{$note.message.inspect}")
158
173
  else
159
- [true,
160
- "expected no note\n"\
161
- "got note with message: #{@note.message.inspect}"]
174
+ does_not(
175
+ "expected note with message: #{message.inspect}\n"\
176
+ " got note with message: #{$note.message.inspect}")
162
177
  end
163
178
  else
164
- [false, if message
165
- "expected a note with message: #{message.inspect}"
166
- else
167
- "expected a note"
168
- end]
179
+ does(
180
+ "expected no note\n"\
181
+ "got note with message: #{$note.message.inspect}")
169
182
  end
170
-
171
- if result
172
- matcher.negative_failure_message = message
173
183
  else
174
- matcher.failure_message = message
184
+ does_not(if message
185
+ "expected a note with message: #{message.inspect}"
186
+ else
187
+ "expected a note"
188
+ end)
175
189
  end
190
+ end
191
+
192
+ failure_message_for_should do |given|
193
+ @message
194
+ end
176
195
 
177
- result
196
+ failure_message_for_should_not do |given|
197
+ @message
178
198
  end
179
199
  end
180
200
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: must_be
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - William Taysom
@@ -15,10 +15,39 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-29 00:00:00 +08:00
18
+ date: 2010-11-01 00:00:00 +08:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: jeweler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 1
32
+ - 4
33
+ version: "1.4"
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 0
48
+ version: "2.0"
49
+ type: :development
50
+ version_requirements: *id002
22
51
  description: must_be provides runtime assertions which can easily be disabled in production environments. Likewise, the notifier can be customized to raise errors, log failure, enter the debugger, or anything else.
23
52
  email: wtaysom@gmail.com
24
53
  executables: []