enumeration 1.1.0 → 1.2.0

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/Gemfile CHANGED
@@ -1,2 +1,5 @@
1
1
  source "http://rubygems.org"
2
+
2
3
  gemspec
4
+
5
+ gem 'rake', '~>0.9.2'
@@ -1,25 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumeration (1.0.0)
4
+ enumeration (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- json (1.5.1)
10
- kelredd-useful (0.4.1)
11
- json
12
- leftright (0.9.1)
13
- shoulda (2.11.3)
14
- test-belt (0.2.1)
15
- kelredd-useful (~> 0.4.0)
16
- leftright (~> 0.9.0)
17
- shoulda (~> 2.11)
9
+ ansi (1.3.0)
10
+ assert (0.2.1)
11
+ ansi (~> 1.3)
12
+ rake (0.9.2)
18
13
 
19
14
  PLATFORMS
20
15
  ruby
21
16
 
22
17
  DEPENDENCIES
18
+ assert (~> 0.2.0)
23
19
  bundler (~> 1.0)
24
20
  enumeration!
25
- test-belt (= 0.2.1)
21
+ rake (~> 0.9.2)
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
+ require 'assert/rake_tasks'
2
+ include Assert::RakeTasks
3
+
1
4
  require 'bundler'
2
5
  Bundler::GemHelper.install_tasks
3
6
 
4
- require 'test_belt/rake_tasks'
5
- TestBelt::RakeTasks.for :test
6
-
7
7
  task :default => :build
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_development_dependency("bundler", ["~> 1.0"])
21
- s.add_development_dependency("test-belt", ["= 0.2.1"])
21
+ s.add_development_dependency("assert", ["~> 0.2.0"])
22
22
  end
@@ -47,4 +47,4 @@ module Enumeration
47
47
  end
48
48
  end
49
49
 
50
- end
50
+ end
@@ -47,4 +47,4 @@ module Enumeration
47
47
  end
48
48
 
49
49
  end
50
- end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Enumeration
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require "assert"
2
+
3
+ require 'enumeration'
4
+
5
+ class APITest < Assert::Context
6
+ desc "Enumeration mixin"
7
+
8
+ subject { Thing.new }
9
+ before do
10
+ Thing.send :include, Enumeration
11
+ end
12
+
13
+ should have_class_method :enum
14
+
15
+ end
@@ -1,86 +1,84 @@
1
- require "test/helper"
1
+ require "assert"
2
+
2
3
  require "enumeration/collection"
3
4
 
4
- class CollectionAPITest < Test::Unit::TestCase
5
- context "Enumeration collection" do
6
- subject { Enumeration::Collection.new([]) }
7
-
8
- should_have_reader :data
9
- should_have_instance_methods :set, :map?, :list?, :[]
10
-
11
- should "only be created from Arrays or Hashes" do
12
- assert_raises ArgumentError do
13
- Enumeration::Collection.new('stuff')
14
- end
15
- assert_nothing_raised do
16
- Enumeration::Collection.new([])
17
- Enumeration::Collection.new({})
18
- end
19
- end
5
+ class CollectionAPITest < Assert::Context
6
+ desc "Enumeration collection"
7
+ subject { Enumeration::Collection.new([]) }
8
+
9
+ should have_reader :data
10
+ should have_instance_methods :set, :map?, :list?, :[]
20
11
 
12
+ should "only be created from Arrays or Hashes" do
13
+ assert_raises ArgumentError do
14
+ Enumeration::Collection.new('stuff')
15
+ end
16
+ assert_nothing_raised do
17
+ Enumeration::Collection.new([])
18
+ Enumeration::Collection.new({})
19
+ end
21
20
  end
22
- end
23
21
 
24
- class ListCollectionTest < Test::Unit::TestCase
25
- context "List collection" do
26
- subject { Enumeration::Collection.new(['one', 'two', 'three']) }
22
+ end
27
23
 
28
- should "be a list" do
29
- assert_equal true, subject.list?
30
- assert_equal false, subject.map?
31
- end
24
+ class ListCollectionTest < Assert::Context
25
+ desc "List collection"
26
+ subject { Enumeration::Collection.new(['one', 'two', 'three']) }
32
27
 
33
- should "know it's data" do
34
- assert_equal ['one', 'two', 'three'], subject.data
35
- end
28
+ should "be a list" do
29
+ assert_equal true, subject.list?
30
+ assert_equal false, subject.map?
31
+ end
36
32
 
37
- should "know it's set" do
38
- assert_equal ['one', 'two', 'three'], subject.set
39
- end
33
+ should "know it's data" do
34
+ assert_equal ['one', 'two', 'three'], subject.data
35
+ end
40
36
 
41
- should "lookup value by key" do
42
- assert_equal 'two', subject['two']
43
- end
37
+ should "know it's set" do
38
+ assert_equal ['one', 'two', 'three'], subject.set
39
+ end
44
40
 
45
- should "lookup key by value" do
46
- assert_equal 'three', subject.key('three')
47
- end
41
+ should "lookup value by key" do
42
+ assert_equal 'two', subject['two']
43
+ end
48
44
 
45
+ should "lookup key by value" do
46
+ assert_equal 'three', subject.key('three')
49
47
  end
50
- end
51
48
 
52
- class MapCollectionTest < Test::Unit::TestCase
53
- context "Map collection" do
54
- subject { Enumeration::Collection.new({ :one => 1, :two => 2, :three => 3}) }
49
+ end
55
50
 
56
- should "be a map" do
57
- assert_equal true, subject.map?
58
- assert_equal false, subject.list?
59
- end
51
+ class MapCollectionTest < Assert::Context
52
+ desc "Map collection"
53
+ subject { Enumeration::Collection.new({ :one => 1, :two => 2, :three => 3}) }
60
54
 
61
- should "know it's data" do
62
- assert_equal({:one=>1,:two=>2,:three=>3}, subject.data)
63
- end
55
+ should "be a map" do
56
+ assert_equal true, subject.map?
57
+ assert_equal false, subject.list?
58
+ end
64
59
 
65
- should "know it's set" do
66
- [:one, :two, :three].each{|n| assert subject.set.include?(n)}
67
- end
60
+ should "know it's data" do
61
+ assert_equal({:one=>1,:two=>2,:three=>3}, subject.data)
62
+ end
68
63
 
69
- should "lookup value by key" do
70
- assert_equal 2, subject[:two]
71
- end
64
+ should "know it's set" do
65
+ [:one, :two, :three].each{|n| assert subject.set.include?(n)}
66
+ end
72
67
 
73
- should "lookup value by value" do
74
- assert_equal 2, subject[2]
75
- end
68
+ should "lookup value by key" do
69
+ assert_equal 2, subject[:two]
70
+ end
76
71
 
77
- should "lookup key by value" do
78
- assert_equal :two, subject.key(2)
79
- end
72
+ should "lookup value by value" do
73
+ assert_equal 2, subject[2]
74
+ end
80
75
 
81
- should "lookup key by key" do
82
- assert_equal :two, subject.key(:two)
83
- end
76
+ should "lookup key by value" do
77
+ assert_equal :two, subject.key(2)
78
+ end
84
79
 
80
+ should "lookup key by key" do
81
+ assert_equal :two, subject.key(:two)
85
82
  end
86
- end
83
+
84
+ end
@@ -1,4 +1,7 @@
1
- require 'rubygems'
2
- require 'test_belt'
3
- require 'test/env'
1
+ # this file is automatically required in when you require 'assert'
2
+ # put test helpers here
3
+
4
+ # add root dir to the load path
5
+ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
+
4
7
  require 'test/thing'
@@ -0,0 +1,10 @@
1
+ require 'assert/setup'
2
+
3
+ # this file is required in when the 'irb' rake test is run.
4
+ # b/c 'assert' is required above, the test helper will be
5
+ # required in.
6
+
7
+ # put any IRB setup code here
8
+
9
+ require 'enumeration'
10
+
@@ -1,49 +1,51 @@
1
- require "test/helper"
1
+ require "assert"
2
2
 
3
- class ListEnumTest < Test::Unit::TestCase
4
- context "instance" do
3
+ require 'enumeration'
5
4
 
6
- subject { Thing.new }
7
- before do
8
- Thing.send :include, Enumeration
9
- Thing.send(:enum, :word, %w{aye bee see})
10
- end
5
+ class ListEnumTest < Assert::Context
6
+ desc "instance"
11
7
 
12
- should_have_class_methods :word_set, :word_collection
13
- should_have_accessor :word
8
+ subject { @a_thing }
9
+ before do
10
+ Thing.send :include, Enumeration
11
+ Thing.send(:enum, :word, %w{aye bee see})
12
+ @a_thing = Thing.new
13
+ end
14
14
 
15
- should "not have a class level lookup method" do
16
- assert_raises NoMethodError do
17
- Thing.word
18
- end
19
- end
15
+ should have_class_methods :word_set, :word_collection
16
+ should have_accessor :word
20
17
 
21
- should "provide class level access to the enum set" do
22
- words = Thing.word_set
23
- assert words
24
- assert_kind_of ::Array, words
25
- assert !words.empty?
26
- assert_equal 3, words.size
27
- assert_equal ['aye', 'bee', 'see'], Thing.word_set
28
- assert_equal Thing.word_set, Thing.word_collection
18
+ should "not have a class level lookup method" do
19
+ assert_raises NoMethodError do
20
+ Thing.word
29
21
  end
22
+ end
30
23
 
31
- should "write a value and read the value" do
32
- subject.word = "see"
33
- assert_equal "see", subject.word
34
- end
24
+ should "provide class level access to the enum set" do
25
+ words = Thing.word_set
26
+ assert words
27
+ assert_kind_of ::Array, words
28
+ assert !words.empty?
29
+ assert_equal 3, words.size
30
+ assert_equal ['aye', 'bee', 'see'], Thing.word_set
31
+ assert_equal Thing.word_set, Thing.word_collection
32
+ end
35
33
 
36
- should "write a value and read the key" do
37
- subject.word = "see"
38
- assert_equal "see", subject.word_key
39
- end
34
+ should "write a value and read the value" do
35
+ subject.word = "see"
36
+ assert_equal "see", subject.word
37
+ end
40
38
 
41
- should "write nil for values that aren't in the enum" do
42
- subject.word = "bady-bad"
43
- assert_equal nil, subject.word
44
- assert_equal nil, subject.word_key
45
- end
39
+ should "write a value and read the key" do
40
+ subject.word = "see"
41
+ assert_equal "see", subject.word_key
42
+ end
46
43
 
44
+ should "write nil for values that aren't in the enum" do
45
+ subject.word = "bady-bad"
46
+ assert_equal nil, subject.word
47
+ assert_equal nil, subject.word_key
47
48
  end
49
+
48
50
  end
49
51
 
@@ -1,63 +1,65 @@
1
- require "test/helper"
2
-
3
- class MapEnumTest < Test::Unit::TestCase
4
- context "instance" do
5
-
6
- subject { Thing.new }
7
- before do
8
- Thing.send :include, Enumeration
9
- Thing.send(:enum, :stuff, {
10
- :a => "aye",
11
- :b => "bee",
12
- :c => "see"
13
- })
14
- end
15
-
16
- should_have_class_methods :stuff, :stuff_set, :stuff_collection
17
- should_have_accessor :stuff
18
-
19
- should "provide class level access to the enum set" do
20
- stuffs = Thing.stuff_set
21
- assert stuffs
22
- assert_kind_of ::Array, stuffs
23
- assert !stuffs.empty?
24
- assert_equal 3, stuffs.size
25
- [:a, :b, :c].each{|t| assert Thing.stuff_set.include?(t)}
26
- assert_equal({:a=>'aye',:b=>'bee',:c=>'see'}, Thing.stuff_collection)
27
- end
28
-
29
- should "provide class level lookup of the enum" do
30
- assert_equal "aye", Thing.stuff(:a)
31
- end
32
-
33
- should "write a key and read the value and key" do
34
- subject.stuff = :b
35
- assert_equal "bee", subject.stuff
36
- assert_equal :b, subject.stuff_key
37
- end
38
-
39
- should "write a value and read the value" do
40
- subject.stuff = "see"
41
- assert_equal "see", subject.stuff
42
- assert_equal :c, subject.stuff_key
43
- end
44
-
45
- should "not read keys like you would values" do
46
- subject.stuff = :c
47
- assert_not_equal :c, subject.stuff
48
- end
49
-
50
- should "write nil for keys that aren't in the enum" do
51
- subject.stuff = :bad
52
- assert_equal nil, subject.stuff
53
- assert_equal nil, subject.stuff_key
54
- end
55
-
56
- should "write nil for values that aren't in the enum" do
57
- subject.stuff = "bady-bad"
58
- assert_equal nil, subject.stuff
59
- assert_equal nil, subject.stuff_key
60
- end
1
+ require "assert"
61
2
 
3
+ require 'enumeration'
4
+
5
+ class MapEnumTest < Assert::Context
6
+ desc "instance"
7
+
8
+ subject { @a_thing }
9
+ before do
10
+ Thing.send :include, Enumeration
11
+ Thing.send(:enum, :stuff, {
12
+ :a => "aye",
13
+ :b => "bee",
14
+ :c => "see"
15
+ })
16
+ @a_thing = Thing.new
17
+ end
18
+
19
+ should have_class_methods :stuff, :stuff_set, :stuff_collection
20
+ should have_accessor :stuff
21
+
22
+ should "provide class level access to the enum set" do
23
+ stuffs = Thing.stuff_set
24
+ assert stuffs
25
+ assert_kind_of ::Array, stuffs
26
+ assert !stuffs.empty?
27
+ assert_equal 3, stuffs.size
28
+ [:a, :b, :c].each{|t| assert Thing.stuff_set.include?(t)}
29
+ assert_equal({:a=>'aye',:b=>'bee',:c=>'see'}, Thing.stuff_collection)
30
+ end
31
+
32
+ should "provide class level lookup of the enum" do
33
+ assert_equal "aye", Thing.stuff(:a)
34
+ end
35
+
36
+ should "write a key and read the value and key" do
37
+ subject.stuff = :b
38
+ assert_equal "bee", subject.stuff
39
+ assert_equal :b, subject.stuff_key
62
40
  end
41
+
42
+ should "write a value and read the value" do
43
+ subject.stuff = "see"
44
+ assert_equal "see", subject.stuff
45
+ assert_equal :c, subject.stuff_key
46
+ end
47
+
48
+ should "not read keys like you would values" do
49
+ subject.stuff = :c
50
+ assert_not_equal :c, subject.stuff
51
+ end
52
+
53
+ should "write nil for keys that aren't in the enum" do
54
+ subject.stuff = :bad
55
+ assert_equal nil, subject.stuff
56
+ assert_equal nil, subject.stuff_key
57
+ end
58
+
59
+ should "write nil for values that aren't in the enum" do
60
+ subject.stuff = "bady-bad"
61
+ assert_equal nil, subject.stuff
62
+ assert_equal nil, subject.stuff_key
63
+ end
64
+
63
65
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumeration
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly D. Redding
@@ -15,12 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-06 00:00:00 -05:00
19
- default_executable:
18
+ date: 2011-08-22 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: bundler
23
21
  prerelease: false
22
+ type: :development
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
@@ -31,23 +30,23 @@ dependencies:
31
30
  - 1
32
31
  - 0
33
32
  version: "1.0"
34
- type: :development
33
+ name: bundler
35
34
  version_requirements: *id001
36
35
  - !ruby/object:Gem::Dependency
37
- name: test-belt
38
36
  prerelease: false
37
+ type: :development
39
38
  requirement: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
- - - "="
41
+ - - ~>
43
42
  - !ruby/object:Gem::Version
44
- hash: 21
43
+ hash: 23
45
44
  segments:
46
45
  - 0
47
46
  - 2
48
- - 1
49
- version: 0.2.1
50
- type: :development
47
+ - 0
48
+ version: 0.2.0
49
+ name: assert
51
50
  version_requirements: *id002
52
51
  description: add enumerated value attributes to your ruby classes
53
52
  email:
@@ -68,14 +67,13 @@ files:
68
67
  - lib/enumeration.rb
69
68
  - lib/enumeration/collection.rb
70
69
  - lib/enumeration/version.rb
71
- - test/api__test.rb
70
+ - test/api_test.rb
72
71
  - test/collection_test.rb
73
- - test/env.rb
74
72
  - test/helper.rb
73
+ - test/irb.rb
75
74
  - test/list_enum_test.rb
76
75
  - test/map_enum_test.rb
77
76
  - test/thing.rb
78
- has_rdoc: true
79
77
  homepage: http://github.com/kelredd/enumeration
80
78
  licenses: []
81
79
 
@@ -105,15 +103,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
103
  requirements: []
106
104
 
107
105
  rubyforge_project:
108
- rubygems_version: 1.3.7
106
+ rubygems_version: 1.8.8
109
107
  signing_key:
110
108
  specification_version: 3
111
109
  summary: add enumerated value attributes to your ruby classes
112
110
  test_files:
113
- - test/api__test.rb
111
+ - test/api_test.rb
114
112
  - test/collection_test.rb
115
- - test/env.rb
116
113
  - test/helper.rb
114
+ - test/irb.rb
117
115
  - test/list_enum_test.rb
118
116
  - test/map_enum_test.rb
119
117
  - test/thing.rb
@@ -1,14 +0,0 @@
1
- require "test/helper"
2
-
3
- class APITest < Test::Unit::TestCase
4
- context "Enumeration mixin" do
5
-
6
- subject { Thing.new }
7
- before do
8
- Thing.send :include, Enumeration
9
- end
10
-
11
- should_have_class_method :enum
12
-
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- # Add test and lib paths to the $LOAD_PATH
2
- [ File.dirname(__FILE__),
3
- File.join(File.dirname(__FILE__), '..', 'lib')
4
- ].each do |path|
5
- full_path = File.expand_path(path)
6
- $LOAD_PATH.unshift(full_path) unless $LOAD_PATH.include?(full_path)
7
- end
8
-
9
- require 'enumeration'
10
-