union 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adbd1e81a50840bb72f6da5a8d8c8d4880f3cc13cf0a79c75244dbedf5efe28a
4
- data.tar.gz: 63daa94ff856cc50918633b19a4e97c6bf9ba57bebf1c531f4ade27feb138008
3
+ metadata.gz: a619aec0c27be52603178e89364bd85c3dab620ec47971220b75acae15bcca37
4
+ data.tar.gz: fa3c3681e2455953b0da6501a88bb28ff19df7364fef68d4a02a0f9127db218e
5
5
  SHA512:
6
- metadata.gz: 8948712b75415225ee8a97ffe6a54615245230f0efc2fa13dea7c4d2418a42ad253089476c44a7b9d7167e1fdb142cd6debc06dc2aaaa99f9cb6d096f1321ff0
7
- data.tar.gz: 7f2e18cc148c24eaf17b81549ccb04b6eb011a04c15963d5ce8d76c35effcd61c57281e31837da4348ee5545d5902a9bbf4f8835e0e036b79fdf35115768310b
6
+ metadata.gz: bcd3b0684e8d0d278afd1262729828ee85041d42249801206ce7f9de16f6244dfcf5d55e9fbc0bb5500853653c3680f6b361f62ffc136a25389343b5f0bf8678
7
+ data.tar.gz: f95468cadcb0b680fd240034d97c1c51cc9a89ec87976f72a5af3da83c2b4ab46ce59a2683f67afd499ac05f5995e7d72849c9d27637e6b917a0dd9a192ed7f6
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.2.0 - 24-Sep-2020
2
+ * Switched from test-unit to rspec.
3
+ * Added a Gemfile.
4
+
1
5
  == 1.1.0 - 24-Jun-2020
2
6
  * Switch to Apache-2.0 license, and add LICENSE file to repo.
3
7
 
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org' do
2
+ gem 'rake'
3
+ group 'test' do
4
+ gem 'rspec', '~> 3.9'
5
+ end
6
+ end
data/MANIFEST CHANGED
@@ -2,8 +2,9 @@
2
2
  * LICENSE
3
3
  * MANIFEST
4
4
  * README
5
+ * Gemfile
5
6
  * Rakefile
6
7
  * union.gemspec
7
8
  * certs/djberg96_pub.pem
8
9
  * lib/union.rb
9
- * test/test_union.rb
10
+ * spec/union_spec.rb
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
 
5
5
  CLEAN.include("**/*.gem", "**/*.rbc", "**/*.rbx")
6
6
 
@@ -19,9 +19,7 @@ namespace :gem do
19
19
  end
20
20
  end
21
21
 
22
- Rake::TestTask.new do |t|
23
- t.verbose = true
24
- t.warning = true
25
- end
22
+ desc "Run the test suite"
23
+ RSpec::Core::RakeTask.new(:spec)
26
24
 
27
- task :default => :test
25
+ task :default => :spec
@@ -3,7 +3,7 @@
3
3
  #
4
4
  class Union < Struct
5
5
  # The version of the union library
6
- VERSION = '1.1.0'.freeze
6
+ VERSION = '1.2.0'.freeze
7
7
 
8
8
  # Creates and returns a new Union. Unlike Struct::Class.new, this does not
9
9
  # take any arguments. You must assign attributes individually.
@@ -0,0 +1,50 @@
1
+ require 'union'
2
+ require 'rspec'
3
+
4
+ RSpec.describe Union do
5
+ before(:all) do
6
+ described_class.new('Human', :name, :age, :height)
7
+ end
8
+
9
+ before do
10
+ @union = Union::Human.new
11
+ end
12
+
13
+ example "union_version" do
14
+ expect(Union::VERSION).to eq('1.2.0')
15
+ expect(Union::VERSION).to be_frozen
16
+ end
17
+
18
+ example "union_constructor" do
19
+ expect{ Union::Human.new('Matz') }.to raise_error(ArgumentError)
20
+ end
21
+
22
+ example "union_attribute_assignment_basic" do
23
+ expect{ @union.name = 'Daniel' }.not_to raise_error
24
+ expect(@union.name).to eq('Daniel')
25
+ end
26
+
27
+ example "union_attribute_assignment_by_method_name" do
28
+ expect{ @union.name = 'Daniel' }.not_to raise_error
29
+ expect{ @union.age = 38 }.not_to raise_error
30
+ expect(@union.name).to be_nil
31
+ expect(@union.height).to be_nil
32
+ expect(@union.age).to eq(38)
33
+ end
34
+
35
+ example "union_attribute_assignment_by_string_ref" do
36
+ expect{ @union['name'] = 'Daniel' }.not_to raise_error
37
+ expect{ @union['age'] = 38 }.not_to raise_error
38
+ expect(@union['name']).to be_nil
39
+ expect(@union['height']).to be_nil
40
+ expect(@union['age']).to eq(38)
41
+ end
42
+
43
+ example "union_attribute_assignment_by_symbol_ref" do
44
+ expect{ @union[:name] = 'Daniel' }.not_to raise_error
45
+ expect{ @union[:age] = 38 }.not_to raise_error
46
+ expect(@union[:name]).to be_nil
47
+ expect(@union[:height]).to be_nil
48
+ expect(@union[:age]).to eq(38)
49
+ end
50
+ end
@@ -2,18 +2,20 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'union'
5
- spec.version = '1.1.0'
5
+ spec.version = '1.2.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/union'
10
10
  spec.summary = 'A struct-like C union for Ruby'
11
- spec.test_file = 'test/test_union.rb'
11
+ spec.test_file = 'spec/union_spec.rb'
12
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = Dir['certs/*']
14
14
 
15
15
  spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+
16
17
  spec.add_development_dependency('rake')
18
+ spec.add_development_dependency('rspec', '~> 3.9')
17
19
 
18
20
  spec.metadata = {
19
21
  'homepage_uri' => 'https://github.com/djberg96/union',
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: union
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date:
38
+ date:
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.9'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.9'
54
68
  description: |2
55
69
  The union library provides an analog to a C/C++ union for Ruby.
56
70
  In this implementation a union is a kind of struct where multiple
@@ -65,10 +79,10 @@ extra_rdoc_files:
65
79
  - MANIFEST
66
80
  files:
67
81
  - LICENSE
68
- - test
69
- - test/test_union.rb
70
82
  - CHANGES
71
83
  - MANIFEST
84
+ - spec
85
+ - spec/union_spec.rb
72
86
  - union.gemspec
73
87
  - README
74
88
  - Rakefile
@@ -76,6 +90,7 @@ files:
76
90
  - certs/djberg96_pub.pem
77
91
  - lib
78
92
  - lib/union.rb
93
+ - Gemfile
79
94
  homepage: https://github.com/djberg96/union
80
95
  licenses:
81
96
  - Apache-2.0
@@ -86,7 +101,7 @@ metadata:
86
101
  documentation_uri: https://github.com/djberg96/union/wiki
87
102
  source_code_uri: https://github.com/djberg96/union
88
103
  wiki_uri: https://github.com/djberg96/union/wiki
89
- post_install_message:
104
+ post_install_message:
90
105
  rdoc_options: []
91
106
  require_paths:
92
107
  - lib
@@ -101,9 +116,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
116
  - !ruby/object:Gem::Version
102
117
  version: '0'
103
118
  requirements: []
104
- rubygems_version: 3.0.3
105
- signing_key:
119
+ rubygems_version: 3.1.4
120
+ signing_key:
106
121
  specification_version: 4
107
122
  summary: A struct-like C union for Ruby
108
123
  test_files:
109
- - test/test_union.rb
124
+ - spec/union_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,51 +0,0 @@
1
- require 'union'
2
- require 'test/unit'
3
-
4
- class TC_Union < Test::Unit::TestCase
5
- def setup
6
- Union.new('Human', :name, :age, :height) unless defined? Union::Human
7
- @union = Union::Human.new
8
- end
9
-
10
- def test_union_version
11
- assert_equal('1.1.0', Union::VERSION)
12
- assert_true(Union::VERSION.frozen?)
13
- end
14
-
15
- def test_union_constructor
16
- assert_raise(ArgumentError){ Union::Human.new('Matz') }
17
- end
18
-
19
- def test_union_attribute_assignment_basic
20
- assert_nothing_raised{ @union.name = 'Daniel' }
21
- assert_equal('Daniel', @union.name)
22
- end
23
-
24
- def test_union_attribute_assignment_by_method_name
25
- assert_nothing_raised{ @union.name = 'Daniel' }
26
- assert_nothing_raised{ @union.age = 38 }
27
- assert_nil(@union.name)
28
- assert_nil(@union.height)
29
- assert_equal(38, @union.age)
30
- end
31
-
32
- def test_union_attribute_assignment_by_string_ref
33
- assert_nothing_raised{ @union['name'] = 'Daniel' }
34
- assert_nothing_raised{ @union['age'] = 38 }
35
- assert_nil(@union['name'])
36
- assert_nil(@union['height'])
37
- assert_equal(38, @union['age'])
38
- end
39
-
40
- def test_union_attribute_assignment_by_symbol_ref
41
- assert_nothing_raised{ @union[:name] = 'Daniel' }
42
- assert_nothing_raised{ @union[:age] = 38 }
43
- assert_nil(@union[:name])
44
- assert_nil(@union[:height])
45
- assert_equal(38, @union[:age])
46
- end
47
-
48
- def teardown
49
- @union = nil
50
- end
51
- end