insist 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright 2012-2013 Jordan Sissel and contributors.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
@@ -2,10 +2,10 @@ 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.8"
5
+ spec.version = "1.0.0"
6
6
  spec.summary = "A simple block-driven assertion library for both testing and for production code"
7
7
  spec.description = spec.summary
8
- spec.license = "none chosen yet"
8
+ spec.license = "Apache 2"
9
9
 
10
10
  # Note: You should set the version explicitly.
11
11
  #spec.add_dependency "cabin", ">0" # for logging. apache 2 license
@@ -5,11 +5,21 @@ module Insist::Predicates
5
5
  include Insist::Assert
6
6
  PREDICATE_METHOD_RE = /\?$/
7
7
 
8
+ # Fails if the value does not respond to a method.
9
+ #
10
+ # insist { "hurray" }.respond_to?(:size)
8
11
  def respond_to?(method)
9
12
  assert(value.respond_to?(method),
10
13
  "#{value.class} does not respond to the '#{method}' method")
11
14
  end # def respond_to?
12
15
 
16
+ # Fails if the value.is_a?(klass) returns false.
17
+ #
18
+ # insist { "hurray" }.is_a?(Number)
19
+ def is_a?(klass)
20
+ assert(value.is_a?(klass), "#{value.class} is not a #{klass}")
21
+ end
22
+
13
23
  # Pass through any 'foo?' style method calls to the 'value'
14
24
  # and fail if the the return is false.
15
25
  def method_missing(m, *args)
@@ -5,6 +5,18 @@ require "insist/predicates"
5
5
  # The predicates feature will delegateany predicate method calls (ones ending
6
6
  # in "?") to the block value and fail if the return is false.
7
7
  describe Insist::Predicates do
8
+ describe "#is_a?" do
9
+ it "should succeed if value#is_a? returns true" do
10
+ insist { "some string" }.is_a?(Object)
11
+ insist { "some string" }.is_a?(String)
12
+ end
13
+ it "should fail if value#is_a? returns false" do
14
+ reject { "some string" }.is_a?(Numeric)
15
+ reject { "some string" }.is_a?(Fixnum)
16
+ reject { "some string" }.is_a?(File)
17
+ end
18
+ end
19
+
8
20
  describe "#respond_to?" do
9
21
  subject do
10
22
  insist { [1, 2, 3] }
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.8
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2013-09-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple block-driven assertion library for both testing and for production
15
15
  code
@@ -24,6 +24,7 @@ files:
24
24
  - .travis.yml
25
25
  - Gemfile
26
26
  - Gemfile.lock
27
+ - LICENSE
27
28
  - Makefile
28
29
  - README.md
29
30
  - insist.gemspec
@@ -50,7 +51,7 @@ files:
50
51
  - test/testing.rb
51
52
  homepage:
52
53
  licenses:
53
- - none chosen yet
54
+ - Apache 2
54
55
  post_install_message:
55
56
  rdoc_options: []
56
57
  require_paths:
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  version: '0'
71
72
  requirements: []
72
73
  rubyforge_project:
73
- rubygems_version: 1.8.24
74
+ rubygems_version: 1.8.25
74
75
  signing_key:
75
76
  specification_version: 3
76
77
  summary: A simple block-driven assertion library for both testing and for production