notu 1.0.2 → 1.0.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/notu.gemspec +1 -2
  4. metadata +3 -73
  5. data/.gitignore +0 -5
  6. data/.rspec +0 -2
  7. data/Gemfile +0 -3
  8. data/Rakefile +0 -10
  9. data/spec/cassettes/Notu_HtmlDocument/_get/follows_redirects.yml +0 -167
  10. data/spec/cassettes/Notu_HtmlDocument/_get/raise_a_NetworkError_on_404.yml +0 -71
  11. data/spec/cassettes/Notu_HtmlDocument/_get/raise_a_ParseError_if_not_a_valid_document.yml +0 -365
  12. data/spec/cassettes/Notu_HtmlDocument/_get/returns_document_parsed.yml +0 -125
  13. data/spec/cassettes/Notu_HttpDownload/_get/accepts_HTTPS_URL.yml +0 -125
  14. data/spec/cassettes/Notu_HttpDownload/_get/follow_redirects.yml +0 -167
  15. data/spec/cassettes/Notu_HttpDownload/_get/raise_a_NetworkError_if_too_many_redirects.yml +0 -45
  16. data/spec/cassettes/Notu_HttpDownload/_get/raise_a_NetworkError_on_404.yml +0 -71
  17. data/spec/cassettes/Notu_HttpDownload/_get/retrives_document_from_given_URL.yml +0 -125
  18. data/spec/cassettes/Notu_LovedTracks/_each/returns_nil.yml +0 -7013
  19. data/spec/cassettes/Notu_LovedTracks/_each/returns_some_tracks.yml +0 -14021
  20. data/spec/cassettes/Notu_LovedTracks/_page_urls/is_correct.yml +0 -14019
  21. data/spec/cassettes/Notu_LovedTracks/_pages_count/is_correct.yml +0 -7011
  22. data/spec/cassettes/Notu_MostPlayedTracks/_each/returns_nil.yml +0 -22449
  23. data/spec/cassettes/Notu_MostPlayedTracks/_each/returns_some_tracks.yml +0 -16108
  24. data/spec/cassettes/Notu_MostPlayedTracks/_page_urls/is_correct.yml +0 -16473
  25. data/spec/cassettes/Notu_MostPlayedTracks/_pages_count/is_correct.yml +0 -8529
  26. data/spec/cassettes/Notu_PlayedTracks/_each/returns_nil.yml +0 -7917
  27. data/spec/cassettes/Notu_PlayedTracks/_each/returns_some_tracks.yml +0 -15829
  28. data/spec/cassettes/Notu_PlayedTracks/_page_urls/is_correct.yml +0 -15827
  29. data/spec/cassettes/Notu_PlayedTracks/_pages_count/is_correct.yml +0 -7915
  30. data/spec/notu/error_spec.rb +0 -40
  31. data/spec/notu/html_document_spec.rb +0 -31
  32. data/spec/notu/http_download_spec.rb +0 -39
  33. data/spec/notu/library_spec.rb +0 -138
  34. data/spec/notu/loved_tracks_spec.rb +0 -77
  35. data/spec/notu/most_played_tracks_spec.rb +0 -101
  36. data/spec/notu/network_error_spec.rb +0 -15
  37. data/spec/notu/parse_error_spec.rb +0 -15
  38. data/spec/notu/played_tracks_spec.rb +0 -62
  39. data/spec/notu/track_spec.rb +0 -141
  40. data/spec/spec_helper.rb +0 -10
  41. data/spec/support/vcr.rb +0 -8
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Notu::ParseError do
4
-
5
- let(:error) { Notu::ParseError.new('BAM!') }
6
-
7
- describe '#message' do
8
-
9
- it 'is message set at initialization' do
10
- expect(error.message).to eq('BAM!')
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Notu::PlayedTracks, :vcr do
4
-
5
- let(:library) { Notu::Library.new(username: 'alexistoulotte') }
6
- let(:played_tracks) { Notu::PlayedTracks.new(library) }
7
-
8
- describe '#each' do
9
-
10
- it 'returns some tracks' do
11
- tracks = played_tracks.take(42)
12
- expect(tracks.size).to eq(42)
13
- tracks.each do |track|
14
- expect(track).to be_a(Notu::Track)
15
- expect(track.artist).to be_present
16
- expect(track.plays_count).to be_nil
17
- expect(track.title).to be_present
18
- end
19
- end
20
-
21
- it 'returns nil' do
22
- allow(played_tracks).to receive(:pages_count).and_return(1)
23
- expect(played_tracks.each {}).to be_nil
24
- end
25
-
26
- end
27
-
28
- describe '#page_urls' do
29
-
30
- it 'is correct' do
31
- urls = played_tracks.page_urls
32
- expect(urls.size).to eq(played_tracks.pages_count)
33
- expect(urls).to include('https://www.last.fm/user/alexistoulotte/library?page=12')
34
- expect(urls).to include('https://www.last.fm/user/alexistoulotte/library?page=3')
35
- end
36
-
37
- end
38
-
39
- describe '#pages_count' do
40
-
41
- it 'is correct' do
42
- expect(played_tracks.pages_count).to be_within(500).of(1500)
43
- end
44
-
45
- end
46
-
47
- describe '#params' do
48
-
49
- it 'is an empty hash' do
50
- expect(played_tracks.params).to eq({})
51
- end
52
-
53
- end
54
-
55
- describe '#path' do
56
-
57
- it 'is "library"' do
58
- expect(played_tracks.path).to eq('library')
59
- end
60
-
61
- end
62
- end
@@ -1,141 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Notu::Track do
4
-
5
- let(:track) { Notu::Track.new(artist: 'Serial Killaz', title: 'Good Enough') }
6
-
7
- describe '#<=>' do
8
-
9
- let(:other) { track.dup }
10
-
11
- it 'compares track by artist' do
12
- expect {
13
- allow(other).to receive(:artist).and_return('Technimatic')
14
- }.to change { track <=> other }.from(0).to(-1)
15
- end
16
-
17
- it 'compares track by artist and then by title' do
18
- expect {
19
- allow(other).to receive(:title).and_return('Send Dem')
20
- }.to change { track <=> other }.from(0).to(-1)
21
- end
22
-
23
- it 'returns nil if given track is not a track' do
24
- expect(track <=> nil).to be_nil
25
- expect(track <=> 'foo').to be_nil
26
- end
27
-
28
- end
29
-
30
- describe '#==' do
31
-
32
- let(:other) { track.dup }
33
-
34
- it 'is false if not a track' do
35
- expect(track == 'foo').to be(false)
36
- end
37
-
38
- it 'is false if artist differs' do
39
- expect {
40
- allow(other).to receive(:artist).and_return('Foo')
41
- }.to change { track == other }.from(true).to(false)
42
- end
43
-
44
- it 'is false if title differs' do
45
- expect {
46
- allow(other).to receive(:title).and_return('Bar')
47
- }.to change { track == other }.from(true).to(false)
48
- end
49
-
50
- it 'is true if plays_count differs' do
51
- expect {
52
- allow(other).to receive(:plays_count).and_return(102)
53
- }.not_to change { track == other }
54
- end
55
-
56
- end
57
-
58
- describe '#eql?' do
59
-
60
- it 'is true for same object' do
61
- expect(track.eql?(track)).to be(true)
62
- end
63
-
64
- it 'is true if == returns true' do
65
- other = track.dup
66
- expect {
67
- allow(track).to receive(:==).and_return(false)
68
- }.to change { track.eql?(other) }.from(true).to(false)
69
- end
70
-
71
- end
72
-
73
- describe '#artist' do
74
-
75
- it 'is value set at initialization' do
76
- expect(track.artist).to eq('Serial Killaz')
77
- end
78
-
79
- it 'is squished' do
80
- expect(Notu::Track.new(artist: 'Serial Killaz ', title: 'Good Enough').artist).to eq('Serial Killaz')
81
- end
82
-
83
- it 'raise an error if blank' do
84
- expect {
85
- Notu::Track.new(artist: ' ', title: 'Good Enough')
86
- }.to raise_error(Notu::Error, 'Notu::Track#artist must be specified, " " given')
87
- end
88
-
89
- end
90
-
91
- describe '#plays_count' do
92
-
93
- it 'is nil by default' do
94
- expect(track.plays_count).to be_nil
95
- end
96
-
97
- it 'can be specified' do
98
- expect(Notu::Track.new(artist: 'Serial Killaz', plays_count: 42, title: 'Good Enough').plays_count).to eq(42)
99
- end
100
-
101
- it 'can be specified (as string)' do
102
- expect(Notu::Track.new(artist: 'Serial Killaz', plays_count: '42', title: 'Good Enough').plays_count).to eq(42)
103
- end
104
-
105
- it 'is nil if invalid' do
106
- expect(Notu::Track.new(artist: 'Serial Killaz', plays_count: 'foo', title: 'Good Enough').plays_count).to be_nil
107
- end
108
-
109
- it 'is 0 if negatve' do
110
- expect(Notu::Track.new(artist: 'Serial Killaz', plays_count: -1, title: 'Good Enough').plays_count).to eq(0)
111
- end
112
-
113
- end
114
-
115
- describe '#title' do
116
-
117
- it 'is value set at initialization' do
118
- expect(track.title).to eq('Good Enough')
119
- end
120
-
121
- it 'is squished' do
122
- expect(Notu::Track.new(artist: 'Serial Killaz', title: ' Good Enough').title).to eq('Good Enough')
123
- end
124
-
125
- it 'raise an error if blank' do
126
- expect {
127
- Notu::Track.new(artist: 'Serial Killaz', title: ' ')
128
- }.to raise_error(Notu::Error, 'Notu::Track#title must be specified, " " given')
129
- end
130
-
131
- end
132
-
133
- describe '#to_s' do
134
-
135
- it 'is "artist - title"' do
136
- expect(track.to_s).to eq('Serial Killaz - Good Enough')
137
- end
138
-
139
- end
140
-
141
- end
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require File.expand_path("#{__dir__}/../lib/notu")
2
- require 'byebug'
3
-
4
- # Requires supporting ruby files with custom matchers and macros, etc,
5
- # in spec/support/ and its subdirectories.
6
- Dir["#{File.expand_path(File.dirname(__FILE__))}/support/**/*.rb"].each { |f| require f }
7
-
8
- RSpec.configure do |config|
9
- config.raise_errors_for_deprecations!
10
- end
data/spec/support/vcr.rb DELETED
@@ -1,8 +0,0 @@
1
- require 'vcr'
2
-
3
- VCR.configure do |config|
4
- config.cassette_library_dir = 'spec/cassettes'
5
- config.hook_into :webmock
6
- config.allow_http_connections_when_no_cassette = false
7
- config.configure_rspec_metadata!
8
- end