must_be 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6dba067b83e0c97bc82fdcdfd4a2b68b643d0558cfc8fb5722f4eaf1497698a1
4
+ data.tar.gz: 71cffdb6b59e615fc68101e67b546a41174df0727bda20b62c855d3d24c53d53
5
+ SHA512:
6
+ metadata.gz: 8b8243ebdbc2ab03394f692061355459dba0311cdcdb6d159a534ac02cb49ece2b20ea71d3fef47565a37aa6ad28f281d6d2839bda3838b953f354f39e778e0b
7
+ data.tar.gz: 5f4424812be412a0cdd159b30a09313278cf5572f29b9cc2b3a614b4e8f7a29f143e850e5c22b10db0ec0e68c64a13b38024c06c9a9b33378637d05b291e498e
@@ -1,3 +1,8 @@
1
+ # must_be 1.1.0 2018-05-22
2
+
3
+ * Update to Ruby 2.5.
4
+ * Use a Gemfile.
5
+
1
6
  # must_be 1.0.3 2010-11-01
2
7
 
3
8
  * Update to use RSpec-2.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'rspec-its', '~> 1.2'
5
+ end
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.3)
5
+ rspec-core (3.7.1)
6
+ rspec-support (~> 3.7.0)
7
+ rspec-expectations (3.7.0)
8
+ diff-lcs (>= 1.2.0, < 2.0)
9
+ rspec-support (~> 3.7.0)
10
+ rspec-its (1.2.0)
11
+ rspec-core (>= 3.0.0)
12
+ rspec-expectations (>= 3.0.0)
13
+ rspec-support (3.7.1)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rspec-its (~> 1.2)
20
+
21
+ BUNDLED WITH
22
+ 1.16.1
data/README.md CHANGED
@@ -23,11 +23,11 @@ For your everyday, average sanity:
23
23
 
24
24
  87.must_be_a(Float, Integer)
25
25
  87.must_be_a(Symbol, String)
26
- #=> 87.must_be_a(Symbol, String), but is a Fixnum
26
+ #=> 87.must_be_a(Symbol, String), but is a Integer
27
27
 
28
28
  87.must_not_be_a(Symbol, String, "message")
29
29
  87.must_not_be_a(Float, Integer, "message")
30
- #=> 87.must_not_be_a(Float, Integer, "message"), but is a Fixnum
30
+ #=> 87.must_not_be_a(Float, Integer, "message"), but is a Integer
31
31
 
32
32
  `must_be_in` uses `include?` to check. Multiple arguments are grouped together as an array:
33
33
 
@@ -70,11 +70,11 @@ Sometimes close is good enough:
70
70
 
71
71
  5.must_be(1..5)
72
72
  5.must_be(1...5)
73
- #=> 5.must_be(1...5), but matches Fixnum
73
+ #=> 5.must_be(1...5), but matches Integer
74
74
 
75
75
  5.must_not_be(1...5)
76
76
  3.must_not_be(1...5)
77
- #=> 3.must_not_be(1...5), but matches Fixnum
77
+ #=> 3.must_not_be(1...5), but matches Integer
78
78
 
79
79
  true.must_be
80
80
  nil.must_be
@@ -122,7 +122,7 @@ Sometimes close is good enough:
122
122
 
123
123
  class Typed
124
124
  attr_typed :v, Symbol
125
- attr_typed :n, Fixnum, Bignum
125
+ attr_typed :n, String, Integer
126
126
  attr_typed :o, &:odd?
127
127
  end
128
128
 
@@ -133,7 +133,7 @@ Sometimes close is good enough:
133
133
 
134
134
  t.n = 411
135
135
  t.n = 4.1
136
- #=> attribute `n' must be a Fixnum or Bignum, but value 4.1 is a Float
136
+ #=> attribute `n' must be a String or Integer, but value 4.1 is a Float
137
137
 
138
138
  t.o = 7
139
139
  t.o = 8
@@ -145,11 +145,11 @@ It's good to be sure that an array or hash contains the right stuff:
145
145
 
146
146
  ["okay", :ready, "go"].must_only_contain(Symbol, String)
147
147
  ["okay", :ready, 4].must_only_contain(Symbol, String)
148
- #=> must_only_contain: 4.must_be(Symbol, String), but matches Fixnum in container ["okay", :ready, 4]
148
+ #=> must_only_contain: 4.must_be(Symbol, String), but matches Integer in container ["okay", :ready, 4]
149
149
 
150
150
  ["okay", :ready, "go"].must_not_contain(Numeric)
151
151
  ["okay", :ready, 4].must_not_contain(Numeric)
152
- #=> must_not_contain: 4.must_not_be(Numeric), but matches Fixnum in container ["okay", :ready, 4]
152
+ #=> must_not_contain: 4.must_not_be(Numeric), but matches Integer in container ["okay", :ready, 4]
153
153
 
154
154
  [].must_only_contain(:yes, :no)
155
155
  [:yep].must_only_contain(:yes, :no)
@@ -165,13 +165,13 @@ It's good to be sure that an array or hash contains the right stuff:
165
165
 
166
166
  [nil, false].must_not_contain
167
167
  [0].must_not_contain
168
- #=> must_not_contain: 0.must_not_be, but matches Fixnum in container [0]
168
+ #=> must_not_contain: 0.must_not_be, but matches Integer in container [0]
169
169
 
170
170
  {:welcome => :home}.must_only_contain(Symbol => Symbol)
171
- {:symbol => :s, :fixnum => 5}.must_only_contain(Symbol => [Symbol, Fixnum])
172
- {5 => :s, 6 => 5, :t => 5, :s => :s}.must_only_contain([Symbol, Fixnum] => [Symbol, Fixnum])
173
- {6 => 5}.must_only_contain(Symbol => Fixnum, Fixnum => Symbol)
174
- #=> must_only_contain: pair {6=>5} does not match [{Symbol=>Fixnum, Fixnum=>Symbol}] in container {6=>5}
171
+ {:symbol => :s, :Integer => 5}.must_only_contain(Symbol => [Symbol, Integer])
172
+ {5 => :s, 6 => 5, :t => 5, :s => :s}.must_only_contain([Symbol, Integer] => [Symbol, Integer])
173
+ {6 => 5}.must_only_contain(Symbol => Integer, Integer => Symbol)
174
+ #=> must_only_contain: pair {6=>5} does not match [{Symbol=>Integer, Integer=>Symbol}] in container {6=>5}
175
175
 
176
176
  {:welcome => nil}.must_not_contain(nil => Object)
177
177
  {nil => :welcome}.must_not_contain(nil => Object)
@@ -236,7 +236,7 @@ It's best to be sure that your custom container contains the right stuff:
236
236
  box = Box[:hello].must_only_ever_contain(Symbol)
237
237
  box.contents = :world
238
238
  box.contents = 987
239
- #=> must_only_ever_contain: Box#contents=(987): 987.must_be(Symbol), but matches Fixnum in container Box[987]
239
+ #=> must_only_ever_contain: Box#contents=(987): 987.must_be(Symbol), but matches Integer in container Box[987]
240
240
 
241
241
  box = Box[2].must_never_ever_contain(nil)
242
242
  box.contents = 64
data/Rakefile CHANGED
@@ -11,7 +11,6 @@ begin
11
11
  gemspec.authors = ["William Taysom"]
12
12
 
13
13
  gemspec.add_development_dependency('jeweler', '~> 1.4')
14
- gemspec.add_development_dependency('rspec', '~> 2.0')
15
14
  end
16
15
  Jeweler::GemcutterTasks.new
17
16
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.1.0
@@ -2,11 +2,11 @@
2
2
 
3
3
  87.must_be_a(Float, Integer)
4
4
  87.must_be_a(Symbol, String)
5
- #=> 87.must_be_a(Symbol, String), but is a Fixnum
5
+ #=> 87.must_be_a(Symbol, String), but is a Integer
6
6
 
7
7
  87.must_not_be_a(Symbol, String, "message")
8
8
  87.must_not_be_a(Float, Integer, "message")
9
- #=> 87.must_not_be_a(Float, Integer, "message"), but is a Fixnum
9
+ #=> 87.must_not_be_a(Float, Integer, "message"), but is a Integer
10
10
 
11
11
  2.must_be_in(1, 2, 3)
12
12
  2.must_be_in([1, 2, 3])
@@ -41,11 +41,11 @@ nil.must_be_boolean
41
41
 
42
42
  5.must_be(1..5)
43
43
  5.must_be(1...5)
44
- #=> 5.must_be(1...5), but matches Fixnum
44
+ #=> 5.must_be(1...5), but matches Integer
45
45
 
46
46
  5.must_not_be(1...5)
47
47
  3.must_not_be(1...5)
48
- #=> 3.must_not_be(1...5), but matches Fixnum
48
+ #=> 3.must_not_be(1...5), but matches Integer
49
49
 
50
50
  true.must_be
51
51
  nil.must_be
@@ -89,7 +89,7 @@ nil.must_not_be
89
89
 
90
90
  class Typed
91
91
  attr_typed :v, Symbol
92
- attr_typed :n, Fixnum, Bignum
92
+ attr_typed :n, String, Integer
93
93
  attr_typed :o, &:odd?
94
94
  end
95
95
 
@@ -100,7 +100,7 @@ t.v = "world"
100
100
 
101
101
  t.n = 411
102
102
  t.n = 4.1
103
- #=> attribute `n' must be a Fixnum or Bignum, but value 4.1 is a Float
103
+ #=> attribute `n' must be a String or Integer, but value 4.1 is a Float
104
104
 
105
105
  t.o = 7
106
106
  t.o = 8
@@ -110,11 +110,11 @@ t.o = 8
110
110
 
111
111
  ["okay", :ready, "go"].must_only_contain(Symbol, String)
112
112
  ["okay", :ready, 4].must_only_contain(Symbol, String)
113
- #=> must_only_contain: 4.must_be(Symbol, String), but matches Fixnum in container ["okay", :ready, 4]
113
+ #=> must_only_contain: 4.must_be(Symbol, String), but matches Integer in container ["okay", :ready, 4]
114
114
 
115
115
  ["okay", :ready, "go"].must_not_contain(Numeric)
116
116
  ["okay", :ready, 4].must_not_contain(Numeric)
117
- #=> must_not_contain: 4.must_not_be(Numeric), but matches Fixnum in container ["okay", :ready, 4]
117
+ #=> must_not_contain: 4.must_not_be(Numeric), but matches Integer in container ["okay", :ready, 4]
118
118
 
119
119
  [].must_only_contain(:yes, :no)
120
120
  [:yep].must_only_contain(:yes, :no)
@@ -130,12 +130,12 @@ t.o = 8
130
130
 
131
131
  [nil, false].must_not_contain
132
132
  [0].must_not_contain
133
- #=> must_not_contain: 0.must_not_be, but matches Fixnum in container [0]
133
+ #=> must_not_contain: 0.must_not_be, but matches Integer in container [0]
134
134
 
135
135
  {:welcome => :home}.must_only_contain(Symbol => Symbol)
136
- {:symbol => :s, :fixnum => 5}.must_only_contain(Symbol => [Symbol, Fixnum])
137
- {5 => :s, 6 => 5, :t => 5, :s => :s}.must_only_contain([Symbol, Fixnum] => [Symbol, Fixnum])
138
- {6 => 5}.must_only_contain(Symbol => Fixnum, Fixnum => Symbol)
136
+ {:symbol => :s, :Integer => 5}.must_only_contain(Symbol => [Symbol, Integer])
137
+ {5 => :s, 6 => 5, :t => 5, :s => :s}.must_only_contain([Symbol, Integer] => [Symbol, Integer])
138
+ {6 => 5}.must_only_contain(Symbol => Integer, Integer => Symbol)
139
139
  #~> must_only_contain: pair \{6=>5\} does not match .* in container \{6=>5\}
140
140
 
141
141
  {:welcome => nil}.must_not_contain(nil => Object)
@@ -197,7 +197,7 @@ end
197
197
  box = Box[:hello].must_only_ever_contain(Symbol)
198
198
  box.contents = :world
199
199
  box.contents = 987
200
- #=> must_only_ever_contain: Box#contents=(987): 987.must_be(Symbol), but matches Fixnum in container Box[987]
200
+ #=> must_only_ever_contain: Box#contents=(987): 987.must_be(Symbol), but matches Integer in container Box[987]
201
201
 
202
202
  box = Box[2].must_never_ever_contain(nil)
203
203
  box.contents = 64
@@ -34,7 +34,7 @@ if RUBY_VERSION < "1.8.7"
34
34
  end
35
35
 
36
36
  unless 3.respond_to? :odd?
37
- class Fixnum
37
+ class Integer
38
38
  def odd?
39
39
  self % 2 == 1
40
40
  end
@@ -42,7 +42,7 @@ if RUBY_VERSION < "1.8.7"
42
42
  end
43
43
 
44
44
  unless 3.respond_to? :even?
45
- class Fixnum
45
+ class Integer
46
46
  def even?
47
47
  self % 2 == 0
48
48
  end
@@ -1,6 +1,6 @@
1
1
  class Module
2
2
  def attr_typed(symbol, *types, &test)
3
- raise TypeError, "#{symbol} is not a symbol" if symbol.is_a? Fixnum
3
+ raise TypeError, "#{symbol} is not a symbol" if symbol.is_a? Integer
4
4
 
5
5
  types.each do |type|
6
6
  raise TypeError, "class or module required" unless type.is_a? Module
@@ -23,6 +23,7 @@ module MustBe
23
23
  right_word_break = right_word_break_area.index(/\s\b/)
24
24
  stop = right_word_break ? right_start + right_word_break : right_side
25
25
 
26
+ s = s.dup
26
27
  s[start...stop] = SHORT_INSPECT_ELLIPSES
27
28
  end
28
29
  s
@@ -1,79 +1,68 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: must_be 1.1.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{must_be}
8
- s.version = "1.0.3"
8
+ s.name = "must_be".freeze
9
+ s.version = "1.1.0"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["William Taysom"]
12
- s.date = %q{2010-11-01}
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
- s.email = %q{wtaysom@gmail.com}
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["William Taysom".freeze]
14
+ s.date = "2018-05-22"
15
+ s.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.".freeze
16
+ s.email = "wtaysom@gmail.com".freeze
15
17
  s.extra_rdoc_files = [
16
18
  "ChangeLog.md",
17
- "README.md"
19
+ "README.md"
18
20
  ]
19
21
  s.files = [
20
- ".gitignore",
21
- "ChangeLog.md",
22
- "README.md",
23
- "Rakefile",
24
- "VERSION",
25
- "doc/readme/examples.rb",
26
- "doc/readme/run_examples.rb",
27
- "lib/must_be.rb",
28
- "lib/must_be/attr_typed.rb",
29
- "lib/must_be/basic.rb",
30
- "lib/must_be/containers.rb",
31
- "lib/must_be/containers_registered_classes.rb",
32
- "lib/must_be/core.rb",
33
- "lib/must_be/nonstandard_control_flow.rb",
34
- "lib/must_be/proxy.rb",
35
- "must_be.gemspec",
36
- "spec/must_be/attr_typed_spec.rb",
37
- "spec/must_be/basic_spec.rb",
38
- "spec/must_be/containers_spec.rb",
39
- "spec/must_be/core_spec.rb",
40
- "spec/must_be/nonstandard_control_flow_spec.rb",
41
- "spec/must_be/proxy_spec.rb",
42
- "spec/notify_matcher_spec.rb",
43
- "spec/spec_helper.rb",
44
- "spec/typical_usage_spec.rb"
45
- ]
46
- s.homepage = %q{http://github.com/wtaysom/must_be}
47
- s.rdoc_options = ["--charset=UTF-8"]
48
- s.require_paths = ["lib"]
49
- s.rubygems_version = %q{1.3.7}
50
- s.summary = %q{must_be Runtime Assertions}
51
- s.test_files = [
22
+ "ChangeLog.md",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "doc/readme/examples.rb",
29
+ "doc/readme/run_examples.rb",
30
+ "lib/must_be.rb",
31
+ "lib/must_be/attr_typed.rb",
32
+ "lib/must_be/basic.rb",
33
+ "lib/must_be/containers.rb",
34
+ "lib/must_be/containers_registered_classes.rb",
35
+ "lib/must_be/core.rb",
36
+ "lib/must_be/nonstandard_control_flow.rb",
37
+ "lib/must_be/proxy.rb",
38
+ "must_be.gemspec",
52
39
  "spec/must_be/attr_typed_spec.rb",
53
- "spec/must_be/basic_spec.rb",
54
- "spec/must_be/containers_spec.rb",
55
- "spec/must_be/core_spec.rb",
56
- "spec/must_be/nonstandard_control_flow_spec.rb",
57
- "spec/must_be/proxy_spec.rb",
58
- "spec/notify_matcher_spec.rb",
59
- "spec/spec_helper.rb",
60
- "spec/typical_usage_spec.rb"
40
+ "spec/must_be/basic_spec.rb",
41
+ "spec/must_be/containers_spec.rb",
42
+ "spec/must_be/core_spec.rb",
43
+ "spec/must_be/nonstandard_control_flow_spec.rb",
44
+ "spec/must_be/proxy_spec.rb",
45
+ "spec/notify_matcher_spec.rb",
46
+ "spec/spec_helper.rb",
47
+ "spec/typical_usage_spec.rb"
61
48
  ]
49
+ s.homepage = "http://github.com/wtaysom/must_be".freeze
50
+ s.rubygems_version = "2.7.3".freeze
51
+ s.summary = "must_be Runtime Assertions".freeze
62
52
 
63
53
  if s.respond_to? :specification_version then
64
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
- s.specification_version = 3
54
+ s.specification_version = 4
66
55
 
67
56
  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"])
57
+ s.add_development_dependency(%q<rspec-its>.freeze, ["~> 1.2"])
58
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 1.4"])
70
59
  else
71
- s.add_dependency(%q<jeweler>, ["~> 1.4"])
72
- s.add_dependency(%q<rspec>, ["~> 2.0"])
60
+ s.add_dependency(%q<rspec-its>.freeze, ["~> 1.2"])
61
+ s.add_dependency(%q<jeweler>.freeze, ["~> 1.4"])
73
62
  end
74
63
  else
75
- s.add_dependency(%q<jeweler>, ["~> 1.4"])
76
- s.add_dependency(%q<rspec>, ["~> 2.0"])
64
+ s.add_dependency(%q<rspec-its>.freeze, ["~> 1.2"])
65
+ s.add_dependency(%q<jeweler>.freeze, ["~> 1.4"])
77
66
  end
78
67
  end
79
68
 
@@ -6,8 +6,8 @@ describe MustBe do
6
6
  describe 'Module#attr_typed' do
7
7
  context "when updating" do
8
8
  module ModuleWhoUsesAttrTyped
9
- attr_typed :int, Bignum, Fixnum
10
- attr_typed :positive_int, Bignum, Fixnum do |n|
9
+ attr_typed :int, Integer
10
+ attr_typed :positive_int, Integer do |n|
11
11
  n > 0
12
12
  end
13
13
  attr_typed :non_nil
@@ -33,7 +33,7 @@ describe MustBe do
33
33
  it "should notify if new value does not have the type" do
34
34
  subject.float = 23
35
35
  should notify("attribute `float' must be a Float,"\
36
- " but value 23 is a Fixnum")
36
+ " but value 23 is a Integer")
37
37
  end
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ describe MustBe do
45
45
 
46
46
  it "should notify if new value does not match either constraint " do
47
47
  subject.int = 56.6
48
- should notify("attribute `int' must be a Bignum or Fixnum,"\
48
+ should notify("attribute `int' must be a Integer,"\
49
49
  " but value 56.6 is a Float")
50
50
  end
51
51
  end
@@ -84,8 +84,8 @@ describe MustBe do
84
84
 
85
85
  it "should notify if new value does not match one of the types" do
86
86
  subject.positive_int = 87.6
87
- should notify("attribute `positive_int' must be a Bignum"\
88
- " or Fixnum, but value 87.6 is a Float")
87
+ should notify("attribute `positive_int' must be a Integer,"\
88
+ " but value 87.6 is a Float")
89
89
  end
90
90
 
91
91
  it "should notify if block[value] is not true" do
@@ -129,19 +129,19 @@ describe MustBe do
129
129
  it "should raise if symbol cannot be converted #to_sym" do
130
130
  expect do
131
131
  subject.attr_typed [], Object
132
- end.should raise_error(TypeError, "[] is not a symbol")
132
+ end.to raise_error(TypeError, "[] is not a symbol nor a string")
133
133
  end
134
134
 
135
- it "should raise if symbol is a Fixnum" do
135
+ it "should raise if symbol is a Integer" do
136
136
  expect do
137
137
  subject.attr_typed 111, Object
138
- end.should raise_error(TypeError, "111 is not a symbol")
138
+ end.to raise_error(TypeError, "111 is not a symbol")
139
139
  end
140
140
 
141
141
  it "should be fine if symbol is a String" do
142
142
  expect do
143
143
  subject.attr_typed "string", Object
144
- end.should_not raise_error
144
+ end.to_not raise_error(TypeError)
145
145
  end
146
146
  end
147
147
 
@@ -149,13 +149,13 @@ describe MustBe do
149
149
  it "should raise if any type is an array" do
150
150
  expect do
151
151
  subject.attr_typed :prop, [Array, Object]
152
- end.should raise_error(TypeError, "class or module required")
152
+ end.to raise_error(TypeError, "class or module required")
153
153
  end
154
154
 
155
155
  it "should raise if any type is a String" do
156
156
  expect do
157
157
  subject.attr_typed :prop, "string"
158
- end.should raise_error(TypeError, "class or module required")
158
+ end.to raise_error(TypeError, "class or module required")
159
159
  end
160
160
  end
161
161
  end
@@ -184,7 +184,7 @@ describe MustBe do
184
184
  it "should notify again" do
185
185
  @enabled_instance.prop = 91
186
186
  should notify("attribute `prop' must be a Symbol,"\
187
- " but value 91 is a Fixnum")
187
+ " but value 91 is a Integer")
188
188
  end
189
189
  end
190
190
  end
@@ -216,7 +216,7 @@ describe MustBe do
216
216
  @disabled_class.attr_typed :prop, Symbol
217
217
  @disabled_instance.prop = 91
218
218
  should notify("attribute `prop' must be a Symbol,"\
219
- " but value 91 is a Fixnum")
219
+ " but value 91 is a Integer")
220
220
  end
221
221
  end
222
222
  end