extra_assertions 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ module ExtraAssertions
2
+ def assert_includes(collection, item, message = nil)
3
+ assert_block (message || "#{collection.inspect} should include #{item.inspect}.") do
4
+ collection.include?(item)
5
+ end
6
+ end
7
+
8
+ def assert_not_includes(collection, item, message = nil)
9
+ assert_block (message || "#{collection.inspect} should not include #{item.inspect}.") do
10
+ !collection.include?(item)
11
+ end
12
+ end
13
+
14
+ def assert_valid(record)
15
+ assert_block (message || "#{record.class.name} is invalid: #{record.errors.full_messages.join("\n")}") do
16
+ record.valid?
17
+ end
18
+ end
19
+
20
+ def assert_invalid(record)
21
+ assert_block (message || "#{record.class.name} should be invalid.") do
22
+ !record.valid?
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ require 'test/unit'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/extra_assertions'))
3
+
4
+ class ExtraAssertionsTest < Test::Unit::TestCase
5
+ include ExtraAssertions
6
+
7
+ def test_includes
8
+ assert_includes [1,2], 2
9
+ end
10
+
11
+ def test_not_includes
12
+ assert_not_includes [1,2], 3
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: extra_assertions
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Justin Weiss
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-09 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: There's a few blocks of code I had to write in tests over and over again. To save time and effort, I made them assertions. These are the ones I came up with so far.
23
+ email:
24
+ - justin@uberweiss.org
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - lib/extra_assertions.rb
33
+ - test/extra_assertions_test.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/justinweiss/extra_assertions
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.7
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Some simple extra rails assertions
68
+ test_files:
69
+ - test/extra_assertions_test.rb