sixword 0.3.1 → 0.3.2

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.
@@ -1,13 +1,11 @@
1
- require_relative '../rspec_helper'
2
-
3
- describe Sixword::Lib do
1
+ RSpec.describe Sixword::Lib do
4
2
  it 'should encode 64 bits correctly' do
5
3
  {
6
4
  [0xd1, 0x85, 0x42, 0x18, 0xeb, 0xbb, 0x0b, 0x51] =>
7
5
  %w{ROME MUG FRED SCAN LIVE LACE},
8
6
  }.each do |barray, sentence|
9
7
  debug_puts "Encoding bit array: #{barray.inspect}"
10
- Sixword::Lib.encode_64_bits(barray).should == sentence
8
+ expect(Sixword::Lib.encode_64_bits(barray)).to eq(sentence)
11
9
  end
12
10
  end
13
11
 
@@ -16,17 +14,17 @@ describe Sixword::Lib do
16
14
  %w{ROME MUG FRED SCAN LIVE LACE} => 0xD1854218EBBB0B51,
17
15
  }.each do |words, int|
18
16
  debug_puts "Decoding 6-word array: #{words.inspect}"
19
- Sixword::Lib.decode_6_words(words, false).should == [int, 8]
17
+ expect(Sixword::Lib.decode_6_words(words, false)).to eq([int, 8])
20
18
  end
21
19
  end
22
20
 
23
21
 
24
22
  it 'should convert byte arrays to ints' do
25
- Sixword::Lib.byte_array_to_int([1, 2]).should == 258
23
+ expect(Sixword::Lib.byte_array_to_int([1, 2])).to eq(258)
26
24
  end
27
25
 
28
26
  it 'should convert ints to byte arrays' do
29
- Sixword::Lib.int_to_byte_array(258).should == [1, 2]
30
- Sixword::Lib.int_to_byte_array(258, 3).should == [0, 1, 2]
27
+ expect(Sixword::Lib.int_to_byte_array(258)).to eq([1, 2])
28
+ expect(Sixword::Lib.int_to_byte_array(258, 3)).to eq([0, 1, 2])
31
29
  end
32
30
  end
@@ -1,37 +1,36 @@
1
1
  # coding: binary
2
- require_relative 'rspec_helper'
3
2
 
4
- describe Sixword do
3
+ RSpec.describe Sixword do
5
4
  it 'should encode RFC hex vectors correctly' do
6
- Sixword::TestVectors::HexTests.each do |section, tests|
5
+ Sixword::TestVectors::HexTests.each do |_section, tests|
7
6
  tests.each do |hex, sentence|
8
7
  words = sentence.split
9
8
  byte_string = Sixword::Hex.decode(hex)
10
9
  debug_puts "Encode 0x#{hex} => #{words.inspect}"
11
- Sixword.encode(byte_string).should == words
10
+ expect(Sixword.encode(byte_string)).to eq(words)
12
11
  end
13
12
  end
14
13
  end
15
14
 
16
15
  it 'should decode RFC vectors to hex correctly' do
17
- Sixword::TestVectors::HexTests.each do |section, tests|
16
+ Sixword::TestVectors::HexTests.each do |_section, tests|
18
17
  tests.each do |hex, sentence|
19
18
  words = sentence.split
20
19
  byte_string = Sixword::Hex.decode(hex)
21
20
  debug_puts "Decode #{words.inspect} => 0x#{hex}"
22
- Sixword.decode(words).should == byte_string
21
+ expect(Sixword.decode(words)).to eq(byte_string)
23
22
  end
24
23
  end
25
24
  end
26
25
 
27
26
  it 'should decode with correct parity' do
28
- Sixword::TestVectors::ParityTest.find_all {|k, v| v}.each do |sentence, _|
27
+ Sixword::TestVectors::ParityTest.find_all {|_k, v| v}.each do |sentence, _|
29
28
  debug_puts "correct parity: #{sentence.inspect}"
30
29
  expect { Sixword.decode(sentence) }.to_not raise_error
31
30
  end
32
31
  end
33
32
  it 'should raise with incorrect parity' do
34
- Sixword::TestVectors::ParityTest.find_all {|k, v| !v}.each do |sentence, _|
33
+ Sixword::TestVectors::ParityTest.find_all {|_k, v| !v}.each do |sentence, _|
35
34
  debug_puts "incorrect parity: #{sentence.inspect}"
36
35
  expect { Sixword.decode(sentence) }.
37
36
  to raise_error(Sixword::InvalidParity)
@@ -53,15 +52,15 @@ describe Sixword do
53
52
  byte_string = Sixword::Hex.decode(hex)
54
53
  debug_puts "Encoding #{hex.inspect} to sentences"
55
54
  debug_puts " => #{sentences.inspect}"
56
- Sixword.encode_to_sentences(byte_string).should == sentences
55
+ expect(Sixword.encode_to_sentences(byte_string)).to eq(sentences)
57
56
  end
58
57
  end
59
58
 
60
59
  it 'should handle all null bytes correctly' do
61
60
  binary = "\0" * 8
62
61
  encoded = ['A'] * 6
63
- Sixword.encode(binary).should == encoded
64
- Sixword.decode(encoded).should == binary
62
+ expect(Sixword.encode(binary)).to eq(encoded)
63
+ expect(Sixword.decode(encoded)).to eq(binary)
65
64
  end
66
65
 
67
66
  it 'should handle padded null bytes correctly' do
@@ -70,8 +69,8 @@ describe Sixword do
70
69
  "\0\0\0foo\0\0" => ["A", "A", "HAY", "SLEW", "TROT", "A"],
71
70
  "foo\0\0" => ["CHUB", "EMIL", "MUDD", "A", "A", "A3"],
72
71
  }.each do |binary, encoded|
73
- Sixword.pad_encode(binary).should == encoded
74
- Sixword.pad_decode(encoded).should == binary
72
+ expect(Sixword.pad_encode(binary)).to eq(encoded)
73
+ expect(Sixword.pad_decode(encoded)).to eq(binary)
75
74
  end
76
75
  end
77
76
 
@@ -90,7 +89,7 @@ describe Sixword do
90
89
  "6C617A7920646F672E" =>
91
90
  "The quick brown fox jumps over the lazy dog.",
92
91
  }.each do |hex_string, byte_string|
93
- Sixword::Hex.decode(hex_string).should == byte_string
92
+ expect(Sixword::Hex.decode(hex_string)).to eq(byte_string)
94
93
  end
95
94
  end
96
95
  end
@@ -0,0 +1,97 @@
1
+ require_relative '../lib/sixword'
2
+ require_relative 'test_vectors'
3
+
4
+ # TODO: use a real logger
5
+ $debug = ENV['DEBUG']
6
+ def debug_puts(*args, &blk)
7
+ if $debug
8
+ puts(*args, &blk)
9
+ end
10
+ end
11
+
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # will add to the boot time of your test suite on EVERY test run, even for an
15
+ # individual file that may not need all of that loaded. Instead, consider making
16
+ # a separate helper file that requires the additional dependencies and performs
17
+ # the additional setup, and require it from the spec files that actually need
18
+ # it.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ # config.filter_run :focus
53
+ # config.run_all_when_everything_filtered = true
54
+
55
+ # Allows RSpec to persist some state between runs in order to support
56
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
57
+ # you configure your source control system to ignore this file.
58
+ # config.example_status_persistence_file_path = "spec/examples.txt"
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
63
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ end
@@ -45,7 +45,7 @@ module Sixword
45
45
  'RASH BUSH MILK LOOK BAD BRIM AVID GAFF BAIT ROT POD LOVE',
46
46
  'EFF8 1F9B FBC6 5350 920C DD74 16DE 8009' =>
47
47
  'TROD MUTE TAIL WARM CHAR KONG HAAG CITY BORE O TEAL AWL',
48
- }
48
+ },
49
49
  }
50
50
 
51
51
  # from RFC 2289
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Brody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-21 00:00:00.000000000 Z
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -40,6 +54,34 @@ dependencies:
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ">="
@@ -70,7 +112,10 @@ extra_rdoc_files: []
70
112
  files:
71
113
  - ".gitignore"
72
114
  - ".rspec"
115
+ - ".rubocop-disables.yml"
116
+ - ".rubocop.yml"
73
117
  - ".travis.yml"
118
+ - CHANGELOG.md
74
119
  - Gemfile
75
120
  - LICENSE.txt
76
121
  - README.md
@@ -83,10 +128,10 @@ files:
83
128
  - lib/sixword/version.rb
84
129
  - lib/sixword/words.rb
85
130
  - sixword.gemspec
86
- - spec/rspec_helper.rb
87
131
  - spec/sixword/hex_spec.rb
88
132
  - spec/sixword/lib_spec.rb
89
133
  - spec/sixword_spec.rb
134
+ - spec/spec_helper.rb
90
135
  - spec/test_vectors.rb
91
136
  homepage: https://github.com/ab/sixword
92
137
  licenses:
@@ -108,13 +153,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
153
  version: '0'
109
154
  requirements: []
110
155
  rubyforge_project:
111
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.2.5
112
157
  signing_key:
113
158
  specification_version: 4
114
159
  summary: Implementation of RFC 2289 compatible 6-word encoding
115
160
  test_files:
116
- - spec/rspec_helper.rb
117
161
  - spec/sixword/hex_spec.rb
118
162
  - spec/sixword/lib_spec.rb
119
163
  - spec/sixword_spec.rb
164
+ - spec/spec_helper.rb
120
165
  - spec/test_vectors.rb
166
+ has_rdoc:
@@ -1,10 +0,0 @@
1
- require_relative '../lib/sixword'
2
- require_relative 'test_vectors'
3
-
4
- # TODO: use a real logger
5
- $debug = ENV['DEBUG']
6
- def debug_puts(*args, &blk)
7
- if $debug
8
- puts(*args, &blk)
9
- end
10
- end