set_assertions 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in set_assertions.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ A set of custom assertions for test-unit.
2
+
3
+ These assertions allow you to assert using set-theory.
4
+
5
+ Currently all you get is assert_identical_set(set_1,set_2,"message")
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ module SetAssertions
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require "set_assertions/version"
3
+
4
+ module SetAssertions
5
+ def assert_identical_set(expected, actual, message=nil)
6
+ full_message = build_message(message, "array with <?> in any order was expected, got: \n<?>.\n", expected, actual)
7
+ assert_block(full_message) {
8
+ (expected.length == actual.length) &&
9
+ ((expected & actual).length == actual.length)
10
+ }
11
+ end
12
+ end
13
+
14
+ class Test::Unit::TestCase
15
+ include SetAssertions
16
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "set_assertions/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "set_assertions"
7
+ s.version = SetAssertions::VERSION
8
+ s.authors = ["Rasheed Abdul-Aziz"]
9
+ s.email = ["squeedee@gmail.com"]
10
+ s.homepage = "http://squeedee.tumblr.com"
11
+ s.summary = %q{Custom test-unit assertions for checking set equality and other set functions}
12
+ s.description = %q{Custom test-unit assertions for checking set equality and other set functions}
13
+
14
+ #s.rubyforge_project = "set_assertions"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "test-unit"
23
+ s.add_development_dependency "rake"
24
+ s.add_runtime_dependency "test-unit"
25
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'test/unit'
4
+ require 'set_assertions'
5
+
6
+ class SetAssertionsTest < Test::Unit::TestCase
7
+ def test_two_empty_tests_pass
8
+ assert_identical_set([], [])
9
+ end
10
+
11
+ def test_two_identical_unit_sets_pass
12
+ assert_identical_set([:a], [:a])
13
+ end
14
+
15
+ def test_an_empty_set_and_a_unit_set_fail
16
+ assert_fail_assertion { assert_identical_set([:a], []) }
17
+ assert_fail_assertion { assert_identical_set([], [:a]) }
18
+ end
19
+
20
+ def test_order_does_not_matter
21
+ assert_identical_set([:a, :b], [:b, :a])
22
+ end
23
+
24
+ def test_same_cardinality_but_different_set_fails
25
+ assert_fail_assertion { assert_identical_set([:a, :b], [:c, :b]) }
26
+ end
27
+
28
+ def test_large_cardinality_passes
29
+ assert_identical_set([:a, :b, "c", 4, "f", :g, :h], [:a, :b, "c", 4, "f", :g, :h])
30
+ end
31
+
32
+ def test_object_equality_passes
33
+ a = "foo"
34
+ b = {:foo => "bar"}
35
+ assert_identical_set([a,b], [b,a])
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: set_assertions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rasheed Abdul-Aziz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-28 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-unit
16
+ requirement: &2157896860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2157896860
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &2157896440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2157896440
36
+ - !ruby/object:Gem::Dependency
37
+ name: test-unit
38
+ requirement: &2157896020 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2157896020
47
+ description: Custom test-unit assertions for checking set equality and other set functions
48
+ email:
49
+ - squeedee@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - lib/set_assertions.rb
59
+ - lib/set_assertions/version.rb
60
+ - set_assertions.gemspec
61
+ - test/test_set_assertions.rb
62
+ homepage: http://squeedee.tumblr.com
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.15
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Custom test-unit assertions for checking set equality and other set functions
86
+ test_files:
87
+ - test/test_set_assertions.rb