metal_archives 2.2.0 → 2.2.3

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.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +46 -0
  3. data/.github/workflows/release.yml +69 -0
  4. data/.gitignore +6 -6
  5. data/.overcommit.yml +35 -0
  6. data/.rspec +1 -0
  7. data/.rubocop.yml +54 -8
  8. data/.rubocop_todo.yml +92 -0
  9. data/CHANGELOG.md +22 -0
  10. data/Gemfile +1 -1
  11. data/LICENSE.md +1 -1
  12. data/README.md +35 -64
  13. data/Rakefile +8 -7
  14. data/bin/console +41 -0
  15. data/bin/setup +8 -0
  16. data/docker-compose.yml +14 -0
  17. data/lib/metal_archives.rb +48 -29
  18. data/lib/metal_archives/{utils/collection.rb → collection.rb} +0 -0
  19. data/lib/metal_archives/configuration.rb +9 -33
  20. data/lib/metal_archives/{error.rb → errors.rb} +0 -0
  21. data/lib/metal_archives/http_client.rb +13 -8
  22. data/lib/metal_archives/{utils/lru_cache.rb → lru_cache.rb} +0 -0
  23. data/lib/metal_archives/middleware/cache_check.rb +2 -4
  24. data/lib/metal_archives/middleware/encoding.rb +2 -2
  25. data/lib/metal_archives/middleware/headers.rb +5 -5
  26. data/lib/metal_archives/middleware/rewrite_endpoint.rb +2 -2
  27. data/lib/metal_archives/models/artist.rb +40 -24
  28. data/lib/metal_archives/models/band.rb +47 -29
  29. data/lib/metal_archives/models/base_model.rb +64 -61
  30. data/lib/metal_archives/models/label.rb +11 -11
  31. data/lib/metal_archives/models/release.rb +17 -15
  32. data/lib/metal_archives/{utils/nil_date.rb → nil_date.rb} +10 -18
  33. data/lib/metal_archives/parsers/artist.rb +62 -31
  34. data/lib/metal_archives/parsers/band.rb +97 -74
  35. data/lib/metal_archives/parsers/label.rb +21 -21
  36. data/lib/metal_archives/parsers/parser.rb +23 -8
  37. data/lib/metal_archives/parsers/release.rb +77 -72
  38. data/lib/metal_archives/{utils/range.rb → range.rb} +5 -2
  39. data/lib/metal_archives/version.rb +12 -1
  40. data/metal_archives.env.example +7 -0
  41. data/metal_archives.gemspec +40 -28
  42. data/nginx/default.conf +60 -0
  43. metadata +126 -65
  44. data/.travis.yml +0 -12
  45. data/spec/configuration_spec.rb +0 -96
  46. data/spec/factories/artist_factory.rb +0 -37
  47. data/spec/factories/band_factory.rb +0 -60
  48. data/spec/factories/nil_date_factory.rb +0 -9
  49. data/spec/factories/range_factory.rb +0 -8
  50. data/spec/models/artist_spec.rb +0 -138
  51. data/spec/models/band_spec.rb +0 -164
  52. data/spec/models/base_model_spec.rb +0 -219
  53. data/spec/models/release_spec.rb +0 -133
  54. data/spec/parser_spec.rb +0 -19
  55. data/spec/spec_helper.rb +0 -111
  56. data/spec/support/factory_girl.rb +0 -5
  57. data/spec/support/metal_archives.rb +0 -33
  58. data/spec/utils/collection_spec.rb +0 -72
  59. data/spec/utils/lru_cache_spec.rb +0 -53
  60. data/spec/utils/nil_date_spec.rb +0 -156
  61. data/spec/utils/range_spec.rb +0 -62
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe MetalArchives::Release do
4
- describe 'properties' do
5
- it 'Tales of Ancient Prophecies has properties' do
6
- release = MetalArchives::Release.find 416934
7
-
8
- expect(release).to be_instance_of MetalArchives::Release
9
- expect(release.id).to eq 416934
10
- expect(release.title).to eq 'Tales of Ancient Prophecies'
11
- expect(release.type).to eq :full_length
12
- expect(release.date_released).to eq MetalArchives::NilDate.new(2014, 6, 4)
13
- expect(release.catalog_id).to eq 'BLOD091CD'
14
- expect(release.version_description).to be_nil
15
- expect(release.format).to eq :cd
16
- expect(release.limitation).to be_nil
17
- expect(release.notes).to be_nil
18
- end
19
-
20
- it '...And Oceans has properties' do
21
- release = MetalArchives::Release.find 123563
22
-
23
- expect(release).to be_instance_of MetalArchives::Release
24
- expect(release.id).to eq 123563
25
- expect(release.title).to eq '...and Oceans'
26
- expect(release.type).to eq :compilation
27
- expect(release.date_released).to eq MetalArchives::NilDate.new(2000)
28
- expect(release.catalog_id).to eq 'NMLP 025'
29
- expect(release.version_description).to be_nil
30
- expect(release.format).to eq :vinyl
31
- expect(release.limitation).to be_nil
32
- expect(release.notes).to be_nil
33
- end
34
-
35
- it 'uses NilDate' do
36
- release = MetalArchives::Release.find 123563
37
-
38
- expect(release.title).to eq '...and Oceans'
39
- expect(release.date_released).to be_instance_of MetalArchives::NilDate
40
- expect(release.date_released).to eq MetalArchives::NilDate.new(2000, nil, nil)
41
- end
42
- end
43
-
44
- describe 'methods' do
45
- describe 'find' do
46
- it 'finds a release' do
47
- release = MetalArchives::Release.find 416934
48
-
49
- expect(release).not_to be_nil
50
- expect(release).to be_instance_of MetalArchives::Release
51
- expect(release.id).to eq 416934
52
- expect(release.title).to eq 'Tales of Ancient Prophecies'
53
- end
54
-
55
- it 'lazily loads' do
56
- release = MetalArchives::Release.find -1
57
-
58
- expect(release).to be_instance_of MetalArchives::Release
59
- end
60
- end
61
-
62
- describe 'find!' do
63
- it 'finds a release' do
64
- release = MetalArchives::Release.find! 416934
65
-
66
- expect(release).to be_instance_of MetalArchives::Release
67
- expect(release.title).to eq 'Tales of Ancient Prophecies'
68
- end
69
-
70
- it 'raises on invalid id' do
71
- expect(-> { MetalArchives::Release.find! -1 }).to raise_error MetalArchives::Errors::APIError
72
- expect(-> { MetalArchives::Release.find! 0 }).to raise_error MetalArchives::Errors::InvalidIDError
73
- expect(-> { MetalArchives::Release.find! nil }).to raise_error MetalArchives::Errors::InvalidIDError
74
- end
75
- end
76
-
77
- describe 'find_by' do
78
- it 'finds a release by title' do
79
- release = MetalArchives::Release.find_by :title => 'Tales of Ancient Prophecies'
80
-
81
- expect(release).to be_instance_of MetalArchives::Release
82
- expect(release.id).to eq 416934
83
- end
84
-
85
- it 'returns nil on invalid id' do
86
- release = MetalArchives::Release.find_by :title => 'SomeNonExistantName'
87
-
88
- expect(release).to be_nil
89
- end
90
- end
91
-
92
- describe 'find_by!' do
93
- it 'finds a release' do
94
- release = MetalArchives::Release.find_by! :title => 'Tales of Ancient Prophecies'
95
-
96
- expect(release).to be_instance_of MetalArchives::Release
97
- expect(release.id).to eq 416934
98
- end
99
-
100
- it 'returns nil on invalid id' do
101
- release = MetalArchives::Release.find_by! :title => 'SomeNonExistantName'
102
-
103
- expect(release).to be_nil
104
- end
105
- end
106
-
107
- describe 'search' do
108
- it 'returns a collection' do
109
- collection = MetalArchives::Release.search 'Rhapsody'
110
-
111
- expect(collection).to be_instance_of MetalArchives::Collection
112
- expect(collection.first).to be_instance_of MetalArchives::Release
113
- end
114
-
115
- it 'returns an empty collection' do
116
- expect(MetalArchives::Release.search 'SomeNoneExistantName').to be_empty
117
- end
118
-
119
- it 'searches by title' do
120
- expect(MetalArchives::Release.search_by(:title => 'Rhapsody').count).to eq 13
121
- # expect(MetalArchives::Release.search_by(:title => 'Lost Horizon').count).to eq 3
122
- # expect(MetalArchives::Release.search_by(:title => 'Lost Horizon', :exact => true).count).to eq 2
123
- # expect(MetalArchives::Release.search_by(:title => 'Alquimia', :genre => 'Melodic Power').count).to eq 2
124
- end
125
- end
126
-
127
- describe 'all' do
128
- it 'returns a collection' do
129
- expect(MetalArchives::Release.all).to be_instance_of MetalArchives::Collection
130
- end
131
- end
132
- end
133
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe MetalArchives::Parsers::Parser do
4
- it 'parses countries' do
5
- expect(described_class.parse_country('United States')).to eq ISO3166::Country['US']
6
- expect(described_class.parse_country('Germany')).to eq ISO3166::Country['DE']
7
- expect(described_class.parse_country('Belgium')).to eq ISO3166::Country['BE']
8
- end
9
-
10
- it 'parses genres' do
11
- expect(described_class.parse_genre('Death, Power, Black')).to match_array ['Black', 'Death', 'Power']
12
- expect(described_class.parse_genre('Death, Power, Black')).to match_array ['Black', 'Death', 'Power']
13
- expect(described_class.parse_genre('Death (early), Heavy/Power Metal, Black (later)')).to match_array ['Black', 'Death', 'Heavy', 'Power']
14
- expect(described_class.parse_genre(' Death , Power Metal, Power, Power')).to match_array ['Death', 'Power']
15
- expect(described_class.parse_genre('Heavy/Speed Power Metal')).to match_array ['Heavy Power', 'Speed Power']
16
- expect(described_class.parse_genre('Traditional Heavy/Power Metal')).to match_array ['Traditional Heavy', 'Traditional Power']
17
- expect(described_class.parse_genre('Traditional/Classical Heavy/Power Metal')).to match_array ['Traditional Heavy', 'Traditional Power', 'Classical Heavy', 'Classical Power']
18
- end
19
- end
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
-
19
- require 'factory_girl'
20
- require 'faker'
21
- require 'coveralls'
22
- Coveralls.wear!
23
-
24
- require 'metal_archives'
25
-
26
- Dir[File.join(__dir__, 'support/**/*.rb')].each { |f| require f }
27
- Dir[File.join(__dir__, 'factories/**/*.rb')].each { |f| require f }
28
-
29
- RSpec.configure do |config|
30
- # rspec-expectations config goes here. You can use an alternate
31
- # assertion/expectation library such as wrong or the stdlib/minitest
32
- # assertions if you prefer.
33
- config.expect_with :rspec do |expectations|
34
- # This option will default to `true` in RSpec 4. It makes the `description`
35
- # and `failure_message` of custom matchers include text for helper methods
36
- # defined using `chain`, e.g.:
37
- # be_bigger_than(2).and_smaller_than(4).description
38
- # # => "be bigger than 2 and smaller than 4"
39
- # ...rather than:
40
- # # => "be bigger than 2"
41
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
42
- end
43
-
44
- # rspec-mocks config goes here. You can use an alternate test double
45
- # library (such as bogus or mocha) by changing the `mock_with` option here.
46
- config.mock_with :rspec do |mocks|
47
- # Prevents you from mocking or stubbing a method that does not exist on
48
- # a real object. This is generally recommended, and will default to
49
- # `true` in RSpec 4.
50
- mocks.verify_partial_doubles = true
51
- end
52
-
53
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
54
- # have no way to turn it off -- the option exists only for backwards
55
- # compatibility in RSpec 3). It causes shared context metadata to be
56
- # inherited by the metadata hash of host groups and examples, rather than
57
- # triggering implicit auto-inclusion in groups with matching metadata.
58
- config.shared_context_metadata_behavior = :apply_to_host_groups
59
-
60
- # The settings below are suggested to provide a good initial experience
61
- # with RSpec, but feel free to customize to your heart's content.
62
- # # This allows you to limit a spec run to individual examples or groups
63
- # # you care about by tagging them with `:focus` metadata. When nothing
64
- # # is tagged with `:focus`, all examples get run. RSpec also provides
65
- # # aliases for `it`, `describe`, and `context` that include `:focus`
66
- # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
67
- # config.filter_run_when_matching :focus
68
- #
69
- # # Allows RSpec to persist some state between runs in order to support
70
- # # the `--only-failures` and `--next-failure` CLI options. We recommend
71
- # # you configure your source control system to ignore this file.
72
- # config.example_status_persistence_file_path = "spec/examples.txt"
73
- #
74
- # # Limits the available syntax to the non-monkey patched syntax that is
75
- # # recommended. For more details, see:
76
- # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
77
- # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
78
- # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
79
- # config.disable_monkey_patching!
80
- #
81
- # # This setting enables warnings. It's recommended, but in some cases may
82
- # # be too noisy due to issues in dependencies.
83
- # config.warnings = true
84
- #
85
- # # Many RSpec users commonly either run the entire suite or an individual
86
- # # file, and it's useful to allow more verbose output when running an
87
- # # individual spec file.
88
- # if config.files_to_run.one?
89
- # # Use the documentation formatter for detailed output,
90
- # # unless a formatter has already been configured
91
- # # (e.g. via a command-line flag).
92
- # config.default_formatter = "doc"
93
- # end
94
- #
95
- # # Print the 10 slowest examples and example groups at the
96
- # # end of the spec run, to help surface which specs are running
97
- # # particularly slow.
98
- # config.profile_examples = 10
99
- #
100
- # # Run specs in random order to surface order dependencies. If you find an
101
- # # order dependency and want to debug it, you can fix the order by providing
102
- # # the seed, which is printed after each run.
103
- # # --seed 1234
104
- # config.order = :random
105
- #
106
- # # Seed global randomization in this process using the `--seed` CLI option.
107
- # # Setting this allows you to use `--seed` to deterministically reproduce
108
- # # test failures related to randomization by passing the same `--seed` value
109
- # # as the one that triggered the failure.
110
- # Kernel.srand config.seed
111
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.include FactoryGirl::Syntax::Methods
5
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'metal_archives'
4
-
5
- MetalArchives.configure do |c|
6
- ## Application identity (required)
7
- c.app_name = 'MetalArchivesGemTestSuite'
8
- c.app_version = MetalArchives::VERSION
9
- c.app_contact = 'user@example.com'
10
-
11
- if ENV.has_key? 'TRAVIS'
12
- ## Request throttling (optional, overrides defaults)
13
- c.request_rate = 1
14
- c.request_timeout = 3
15
- end
16
-
17
- ## Connect additional Faraday middleware
18
- # c.middleware = [MyMiddleware, MyOtherMiddleware]
19
-
20
- ## Custom cache size per object class (optional, overrides defaults)
21
- # c.cache_size = 100
22
-
23
- ## Metal Archives endpoint (optional, overrides default)
24
- c.endpoint = ENV['MA_ENDPOINT'] if ENV['MA_ENDPOINT']
25
-
26
- if ENV['MA_ENDPOINT']
27
- puts "Using '#{ENV['MA_ENDPOINT']}' as MA endpoint"
28
- end
29
-
30
- ## Custom logger (optional)
31
- c.logger = Logger.new STDOUT
32
- c.logger.level = Logger::INFO
33
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe MetalArchives::Collection do
4
- it 'iterates' do
5
- l = lambda do
6
- @i ||= 0
7
-
8
- next [] if @i >= 100
9
- items = (@i .. (@i + 9)).to_a
10
- @i += 10
11
-
12
- items
13
- end
14
-
15
- c = MetalArchives::Collection.new l
16
-
17
- i = 0
18
- c.each do |item|
19
- expect(item).to eq i
20
- i += 1
21
- end
22
- end
23
-
24
- it 'returns' do
25
- l = lambda do
26
- @i ||= 0
27
-
28
- raise StandardError if @i >= 100
29
- items = (@i .. (@i + 9)).to_a
30
- @i += 10
31
-
32
- items
33
- end
34
-
35
- c = MetalArchives::Collection.new l
36
-
37
- i = 0
38
- c.each do |item|
39
- break if i == 99
40
- expect(item).to eq i
41
- i += 1
42
- end
43
-
44
- expect(i).to eq 99
45
- end
46
-
47
- describe 'empty?' do
48
- it 'is not empty' do
49
- l = lambda do
50
- @i ||= 0
51
-
52
- next [] if @i >= 100
53
- items = (@i .. (@i + 9)).to_a
54
- @i += 10
55
-
56
- items
57
- end
58
-
59
- c = MetalArchives::Collection.new l
60
-
61
- i = 0
62
-
63
- expect(c).not_to be_empty
64
- end
65
-
66
- it 'is empty' do
67
- c = MetalArchives::Collection.new -> { [] }
68
-
69
- expect(c).to be_empty
70
- end
71
- end
72
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe MetalArchives::LRUCache do
4
- let(:cache) { MetalArchives::LRUCache.new 3 }
5
-
6
- it 'stores and retrieves objects' do
7
- cache[:key] = 'MyString'
8
-
9
- expect(cache[:key]).to eq 'MyString'
10
- end
11
-
12
- it 'clears cache' do
13
- cache[:key] = 'MyString'
14
- cache.clear
15
-
16
- expect(cache[:key]).to be_nil
17
- end
18
-
19
- it 'peeks' do
20
- expect(cache).not_to include :key
21
-
22
- cache[:key] = 'MyString'
23
-
24
- expect(cache).to include :key
25
- end
26
-
27
- it 'deletes' do
28
- cache[:key] = 'MyString'
29
-
30
- expect(cache).to include :key
31
-
32
- cache.delete :key
33
-
34
- expect(cache).not_to include :key
35
- end
36
-
37
- it 'implements LRU caching' do
38
- cache[:a] = 'one'
39
- cache[:b] = 'two'
40
- cache[:c] = 'three'
41
-
42
- expect(cache.instance_variable_get '@size').to eq 3
43
-
44
- cache[:d] = 'four'
45
-
46
- expect(cache.instance_variable_get '@size').to eq 3
47
-
48
- expect(cache[:b]).to eq 'two'
49
- expect(cache[:c]).to eq 'three'
50
- expect(cache[:d]).to eq 'four'
51
- expect(cache[:a]).to be_nil
52
- end
53
- end
@@ -1,156 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe MetalArchives::NilDate do
4
- let(:date) { build :nil_date }
5
- let(:date_without_day) { build :nil_date, :day => nil }
6
- let(:date_without_month) { build :nil_date, :month => nil }
7
-
8
- it 'has the correct properties' do
9
- expect(date).to respond_to :year
10
- expect(date).to respond_to :year=
11
- expect(date).to respond_to :year?
12
-
13
- expect(date).to respond_to :month
14
- expect(date).to respond_to :month=
15
- expect(date).to respond_to :month?
16
-
17
- expect(date).to respond_to :day
18
- expect(date).to respond_to :day=
19
- expect(date).to respond_to :day?
20
- end
21
-
22
- it 'returns the correct values' do
23
- expect(date.year).not_to be_nil
24
- expect(date.year).to be_an Integer
25
- expect(date.year?).to be true
26
-
27
- expect(date.month).not_to be_nil
28
- expect(date.month).to be_an Integer
29
- expect(date.month?).to be true
30
-
31
- expect(date.day).not_to be_nil
32
- expect(date.day).to be_an Integer
33
- expect(date.day?).to be true
34
- end
35
-
36
- it 'does not require a day' do
37
- expect(date_without_day.day).to be_nil
38
- expect(date_without_day.day?).to be false
39
- end
40
-
41
- it 'does not require a month' do
42
- expect(date_without_month.month).to be_nil
43
- expect(date_without_month.month?).to be false
44
- end
45
-
46
- it 'returns a date' do
47
- expect(date.date).to be_a Date
48
- expect(date.date.year).to eq date.year
49
- expect(date.date.month).to eq date.month
50
- expect(date.date.day).to eq date.day
51
- end
52
-
53
- describe 'parsing' do
54
- it 'parses empty dates' do
55
- date = described_class.parse ''
56
-
57
- expect(date.year?).to be false
58
- expect(date.month?).to be false
59
- expect(date.day?).to be false
60
- end
61
-
62
- it 'parses dates with year only' do
63
- date = described_class.parse '2012'
64
-
65
- expect(date.year?).to be true
66
- expect(date.year).to eq 2012
67
- expect(date.month?).to be false
68
- expect(date.day?).to be false
69
- end
70
-
71
- it 'parses parses dates with year and month' do
72
- date = described_class.parse '2012-10'
73
-
74
- expect(date.year?).to be true
75
- expect(date.year).to eq 2012
76
- expect(date.month?).to be true
77
- expect(date.month).to eq 10
78
- expect(date.day?).to be false
79
- end
80
-
81
- it 'parses dates with leading zeroes' do
82
- date = described_class.parse '2017-01-00'
83
-
84
- expect(date.year).to eq 2017
85
- expect(date.month).to eq 1
86
- expect(date.day).to eq nil
87
- end
88
-
89
- it 'parses full dates' do
90
- date = described_class.parse '2012-10-02'
91
-
92
- expect(date.year?).to be true
93
- expect(date.year).to eq 2012
94
- expect(date.month?).to be true
95
- expect(date.month).to eq 10
96
- expect(date.day?).to be true
97
- expect(date.day).to eq 2
98
- end
99
-
100
- it 'does not parse on invalid dates' do
101
- expect(-> { described_class.parse 'October 2nd, 2012' }).to raise_error MetalArchives::Errors::ArgumentError
102
- expect(-> { described_class.parse 'a-b-c' }).to raise_error MetalArchives::Errors::ArgumentError
103
- expect(-> { described_class.parse "This isn't a date" }).to raise_error MetalArchives::Errors::ArgumentError
104
- end
105
- end
106
-
107
- it 'includes comparable' do
108
- date1 = described_class.new 2015, 01, 01
109
- date2 = described_class.new 2015, 01, 02
110
- date3 = described_class.new 2015, 02, 01
111
- date4 = described_class.new 2016, 01, 02
112
- date5 = described_class.new 2015, 01, 01
113
- date6 = described_class.new 2014, 12, 31
114
- date7 = described_class.new 2015, 01, nil
115
- date8 = described_class.new 2015, 01, nil
116
- date9 = described_class.new 2015, 02, nil
117
- date10 = described_class.new 2015, nil, nil
118
- date11 = described_class.new 2016, nil, nil
119
-
120
- expect(date1 <=> date2).to eq -1
121
- expect(date2 <=> date1).to eq 1
122
- expect(date1 <=> date3).to eq -1
123
- expect(date3 <=> date1).to eq 1
124
- expect(date1 <=> date4).to eq -1
125
- expect(date4 <=> date1).to eq 1
126
- expect(date1 <=> date5).to eq 0
127
- expect(date5 <=> date1).to eq 0
128
- expect(date6 <=> date1).to eq -1
129
- expect(date1 <=> date6).to eq 1
130
-
131
- expect(date1 <=> date7).to eq nil
132
- expect(date7 <=> date1).to eq nil
133
- expect(date1 <=> date9).to eq nil
134
- expect(date9 <=> date1).to eq nil
135
- expect(date7 <=> date8).to eq 0
136
- expect(date8 <=> date7).to eq 0
137
- expect(date7 <=> date9).to eq -1
138
- expect(date9 <=> date7).to eq 1
139
- expect(date7 <=> date10).to eq nil
140
- expect(date10 <=> date7).to eq nil
141
- expect(date10 <=> date11).to eq -1
142
- expect(date11 <=> date10).to eq 1
143
- end
144
-
145
- it 'prints to string' do
146
- date1 = described_class.new 2015, nil, nil
147
- date2 = described_class.new 2015, 01, nil
148
- date3 = described_class.new 2015, 01, 01
149
- date4 = described_class.new 2015, nil, 01
150
-
151
- expect(date1.to_s).to eq '2015-00-00'
152
- expect(date2.to_s).to eq '2015-01-00'
153
- expect(date3.to_s).to eq '2015-01-01'
154
- expect(date4.to_s).to eq '2015-00-01'
155
- end
156
- end