insist 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/insist.gemspec CHANGED
@@ -2,9 +2,9 @@ Gem::Specification.new do |spec|
2
2
  files = %x{git ls-files}.split("\n")
3
3
 
4
4
  spec.name = "insist"
5
- spec.version = "0.0.3"
6
- spec.summary = "insist"
7
- spec.description = "insist"
5
+ spec.version = "0.0.4"
6
+ spec.summary = "A simple block-driven assertion library for both testing and for production code"
7
+ spec.description = spec.summary
8
8
  spec.license = "none chosen yet"
9
9
 
10
10
  # Note: You should set the version explicitly.
@@ -42,4 +42,16 @@ module Insist::Comparators
42
42
  assert(value != expected,
43
43
  "Expected #{value.inspect} != #{expected.inspect}")
44
44
  end # def !=
45
+
46
+ # value =~ pattern
47
+ def =~(pattern)
48
+ assert(value =~ pattern,
49
+ "Expected #{value.inspect} =~ #{pattern.inspect}")
50
+ end # def =~
51
+
52
+ # value !~ pattern
53
+ def !~(pattern)
54
+ assert(value !~ pattern,
55
+ "Expected #{value.inspect} !~ #{pattern.inspect}")
56
+ end # def !~
45
57
  end # module Insist::Comparators
data/lib/insist.rb CHANGED
@@ -40,18 +40,22 @@ class Insist
40
40
  # insist { value }
41
41
  def initialize(&block)
42
42
  @callback = block
43
- end
43
+ end # def initialize
44
44
 
45
45
  def value
46
46
  # TODO(sissel): make caching the value optional
47
47
  @value ||= @callback.call
48
48
  return @value
49
- end
49
+ end # def value
50
50
  end # class Insist
51
51
 
52
52
  module Kernel
53
53
  # A shortcut to 'Insist.new'
54
+ #
55
+ # Example:
56
+ #
57
+ # insist { "hello world" } != "fizzle"
54
58
  def insist(&block)
55
59
  return Insist.new(&block)
56
- end
57
- end
60
+ end # def insist
61
+ end # module Kernel
@@ -79,4 +79,32 @@ describe Insist::Comparators do
79
79
  insist { subject > larger }.fails
80
80
  end
81
81
  end
82
+
83
+ describe "#=~" do
84
+ subject do
85
+ Insist.new { "hello" }
86
+ end
87
+
88
+ it "should be OK if the #value matches the given pattern" do
89
+ subject =~ /hello/
90
+ end
91
+
92
+ it "should fail if the #value does not match the pattern" do
93
+ insist { subject =~ /world/ }.fails
94
+ end
95
+ end
96
+
97
+ describe "#!~" do
98
+ subject do
99
+ Insist.new { "hello" }
100
+ end
101
+
102
+ it "should be OK if the #value does not match the pattern" do
103
+ subject !~ /world/
104
+ end
105
+
106
+ it "should fail if the #value matches the given pattern" do
107
+ insist { subject !~ /hello/ }.fails
108
+ end
109
+ end
82
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000 Z
12
+ date: 2012-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cabin
16
- requirement: &12960960 !ruby/object:Gem::Requirement
16
+ requirement: &9912680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>'
@@ -21,8 +21,9 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12960960
25
- description: insist
24
+ version_requirements: *9912680
25
+ description: A simple block-driven assertion library for both testing and for production
26
+ code
26
27
  email:
27
28
  - jls@semicomplete.com
28
29
  executables: []
@@ -80,6 +81,7 @@ rubyforge_project:
80
81
  rubygems_version: 1.8.16
81
82
  signing_key:
82
83
  specification_version: 3
83
- summary: insist
84
+ summary: A simple block-driven assertion library for both testing and for production
85
+ code
84
86
  test_files: []
85
87
  has_rdoc: