must 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/must/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Must
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/must.rb CHANGED
@@ -2,6 +2,14 @@ require "must/version"
2
2
 
3
3
  # Must
4
4
  module Must
5
+ ######################################################################
6
+ ### Original Type
7
+
8
+ Boolean = Class.new
9
+
10
+ ######################################################################
11
+ ### Exceptions
12
+
5
13
  class Invalid < StandardError; end
6
14
  class ClassMismatch < Invalid; end
7
15
  class StructMismatch < Invalid; end
@@ -13,6 +21,7 @@ module Must
13
21
  args.each{|klass|
14
22
  return self if self.class == klass # 1.must(Fixnum)
15
23
  return self if self == klass # flag.must(true, false)
24
+ return self if klass == Boolean and (self == true or self == false)
16
25
  }
17
26
 
18
27
  # Or, check it in a slow but strict way
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Must, "boolean" do
4
+ def ok(&block)
5
+ block.should_not raise_error
6
+ end
7
+
8
+ def ng(error = Must::Invalid, &block)
9
+ block.should raise_error(error)
10
+ end
11
+
12
+ specify do
13
+ ok { true.must(Boolean) }
14
+ ok { false.must(Boolean) }
15
+
16
+ ng { nil.must(Boolean) }
17
+ ng { 1.must(Boolean) }
18
+ ng { "".must(Boolean) }
19
+ ng { [true].must(Boolean) }
20
+ end
21
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: must
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - maiha
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-09-04 00:00:00 Z
18
+ date: 2013-10-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -53,6 +53,7 @@ files:
53
53
  - lib/must/struct_info.rb
54
54
  - lib/must/version.rb
55
55
  - must.gemspec
56
+ - spec/boolean_spec.rb
56
57
  - spec/coerced_spec.rb
57
58
  - spec/differ_spec.rb
58
59
  - spec/duck_spec.rb