lyrics_finder 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/bin/lyricsfinder +1 -1
- data/lib/lyrics_finder/cli.rb +7 -9
- data/lib/lyrics_finder/dependencies.rb +0 -1
- data/lib/lyrics_finder/providers/azlyrics.rb +10 -15
- data/lib/lyrics_finder/providers/lyrics_wikia.rb +10 -19
- data/lib/lyrics_finder/providers/song_lyrics.rb +10 -15
- data/lib/lyrics_finder/providers.rb +17 -4
- data/lib/lyrics_finder/song.rb +21 -0
- data/lib/lyrics_finder/version.rb +1 -1
- data/lib/lyrics_finder.rb +42 -42
- data/lyrics_finder.gemspec +8 -8
- data/spec/{lyrics_finder_spec.rb → lyrics_finder/lyrics_finder_spec.rb} +23 -24
- data/spec/{providers → lyrics_finder/providers}/azlyrics_spec.rb +4 -5
- data/spec/lyrics_finder/providers/lyrics_wikia_spec.rb +43 -0
- data/spec/{providers → lyrics_finder/providers}/song_lyrics_spec.rb +4 -5
- data/spec/lyrics_finder/providers_spec.rb +19 -0
- data/spec/vcr_cassettes/Azlyrics_200_search.yml +2 -2
- data/spec/vcr_cassettes/LyricsWikia_200_search.yml +324 -328
- data/spec/vcr_cassettes/LyricsWikia_Song_does_not_exist_search.yml +50 -50
- data/spec/vcr_cassettes/Nonexistent_Song_404_search.yml +1727 -1692
- data/spec/vcr_cassettes/SongLyrics_200_search.yml +397 -397
- metadata +29 -28
- data/spec/providers/lyrics_wikia_spec.rb +0 -34
- data/spec/providers_spec.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57cc0f1e4ad122a9fde9703f7a422db906bda1b2
|
|
4
|
+
data.tar.gz: ec34c7b3f0598f39dcd1073bfb42d086df8cc629
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04d13064bd6d959785a314df9fa1943aa6b77c9d22887040addb62014ca7fa82311d3c6d78b7321ace0e24500e495f247d1354a0f8a341ca8f767197ae51b98e
|
|
7
|
+
data.tar.gz: f5c787f0727f686cafaf6611b6208a29d8d72c6ef262e8a2d9e10ac624eb17134e0dbe79bfef04ebdf4e824f29feca7c21419d1a6afc9aeba160b3a21e106200
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# LyricsFinder [](https://travis-ci.org/dnlR/lyrics_finder) [](https://coveralls.io/r/dnlR/lyrics_finder?branch=master) [](https://coderwall.com/dnlr)
|
|
1
|
+
# LyricsFinder [](http://badge.fury.io/rb/lyrics_finder) [](https://travis-ci.org/dnlR/lyrics_finder) [](https://coveralls.io/r/dnlR/lyrics_finder?branch=master) [](https://coderwall.com/dnlr)
|
|
2
2
|
|
|
3
3
|
Simple library to search for song lyrics
|
|
4
4
|
|
|
@@ -18,28 +18,28 @@ Or install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
## Hello World!
|
|
20
20
|
|
|
21
|
-
Create an instance of `
|
|
21
|
+
Create an instance of `Finder`:
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
|
-
|
|
24
|
+
finder = Finder.new
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
You can specify which websites are you going to get the lyrics from:
|
|
28
28
|
|
|
29
29
|
```ruby
|
|
30
|
-
|
|
30
|
+
finder = Finder.new(:song_lyrics, :azlyrics)
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
You can choose among the following:
|
|
34
34
|
|
|
35
|
-
- LyricsWikia
|
|
36
|
-
- SongLyrics
|
|
37
|
-
- AZLyrics
|
|
35
|
+
- LyricsWikia (`:lyrics_wikia`)
|
|
36
|
+
- SongLyrics (`:song_lyrics`)
|
|
37
|
+
- AZLyrics (`:azlyrics`)
|
|
38
38
|
|
|
39
|
-
And search passing the author and the song title as parameters to `
|
|
39
|
+
And search passing the author and the song title as parameters to `Finder#search`:
|
|
40
40
|
|
|
41
41
|
```ruby
|
|
42
|
-
|
|
42
|
+
finder.search 'idina menzel', 'let it go'
|
|
43
43
|
```
|
|
44
44
|
Which will return and array with all the verses of the song as strings, or `nil` if it cannot found the song in any of the websites.
|
|
45
45
|
|
|
@@ -49,8 +49,8 @@ In your ruby apps:
|
|
|
49
49
|
```ruby
|
|
50
50
|
require 'lyrics_finder'
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
@song =
|
|
52
|
+
finder = Finder.new
|
|
53
|
+
@song = finder.search 'idina menzel', 'let it go'
|
|
54
54
|
puts @song
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -62,9 +62,15 @@ LyricsFinder is also available as a command-line tool.
|
|
|
62
62
|
|
|
63
63
|
## Changelog
|
|
64
64
|
|
|
65
|
+
v 0.0.2
|
|
66
|
+
|
|
67
|
+
- Changed the app interface `LyricsFinder::Fetcher` is now `Finder`.
|
|
68
|
+
- Now using [Contracts](https://github.com/egonSchiele/contracts.ruby).
|
|
69
|
+
- Simplified providers code.
|
|
70
|
+
|
|
65
71
|
v 0.0.1
|
|
66
72
|
|
|
67
|
-
- Initial release
|
|
73
|
+
- Initial release.
|
|
68
74
|
|
|
69
75
|
## Contributing
|
|
70
76
|
|
|
@@ -72,8 +78,4 @@ v 0.0.1
|
|
|
72
78
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
73
79
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
74
80
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
75
|
-
5. Create a new Pull Request
|
|
76
|
-
|
|
77
|
-
## Credits
|
|
78
|
-
|
|
79
|
-
Inspired by [Lyricfy](https://github.com/javichito/Lyricfy).
|
|
81
|
+
5. Create a new Pull Request
|
data/bin/lyricsfinder
CHANGED
data/lib/lyrics_finder/cli.rb
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
require 'thor'
|
|
2
2
|
require 'lyrics_finder'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
puts fetcher.search(options[:author], options[:title])
|
|
12
|
-
end
|
|
4
|
+
class CLI < Thor
|
|
5
|
+
desc 'search -a Author -t Song Title', 'Search the lyrics for the specified author and title'
|
|
6
|
+
method_option 'author', :aliases => '-a', :type => :string
|
|
7
|
+
method_option 'title', :aliases => '-t', :type => :string
|
|
8
|
+
def search
|
|
9
|
+
finder = Finder.new
|
|
10
|
+
puts finder.search(options[:author], options[:title])
|
|
13
11
|
end
|
|
14
12
|
end
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
module Providers::Azlyrics
|
|
2
|
+
include Contracts
|
|
3
|
+
|
|
4
|
+
Contract Song => String
|
|
5
|
+
def self.format_url(song)
|
|
6
|
+
song.format_attributes_with_separator!("")
|
|
7
|
+
"http://www.azlyrics.com/lyrics/#{song.author}/#{song.title}.html"
|
|
6
8
|
end
|
|
7
|
-
module_function :format_url
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
unless lyrics_container.nil?
|
|
13
|
-
elements = lyrics_container.children.to_a
|
|
14
|
-
phrases = elements.select { |el| el.text? && el.text != "\n" && !el.blank? }
|
|
15
|
-
phrases.map! { |element| element.text.strip }
|
|
16
|
-
end
|
|
10
|
+
Contract Tempfile => Or[Array, nil]
|
|
11
|
+
def self.extract_lyric(data)
|
|
12
|
+
Providers.extract_lyrics_at_css_from_data('div:nth-child(7)', data)
|
|
17
13
|
end
|
|
18
|
-
module_function :extract_lyric
|
|
19
14
|
end
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"http://lyrics.wikia.com/#{author}:#{title}"
|
|
1
|
+
module Providers::LyricsWikia
|
|
2
|
+
include Contracts
|
|
3
|
+
|
|
4
|
+
Contract Song => String
|
|
5
|
+
def self.format_url(song)
|
|
6
|
+
song.format_attributes_with_separator!("_")
|
|
7
|
+
"http://lyrics.wikia.com/#{song.author}:#{song.title}"
|
|
8
8
|
end
|
|
9
|
-
module_function :format_url
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
html = Nokogiri::HTML(data)
|
|
15
|
-
lyrics_container = html.css('.lyricbox').first
|
|
16
|
-
unless lyrics_container.nil?
|
|
17
|
-
elements = lyrics_container.children.to_a
|
|
18
|
-
phrases = elements.select { |el| el.text? && el.text != "\n" && !el.blank? }
|
|
19
|
-
phrases.map! { |element| element.text.strip }
|
|
20
|
-
end
|
|
10
|
+
Contract Tempfile => Or[Array, nil]
|
|
11
|
+
def self.extract_lyric(data)
|
|
12
|
+
Providers.extract_lyrics_at_css_from_data('.lyricbox', data)
|
|
21
13
|
end
|
|
22
|
-
module_function :extract_lyric
|
|
23
14
|
end
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
module Providers::SongLyrics
|
|
2
|
+
include Contracts
|
|
3
|
+
|
|
4
|
+
Contract Song => String
|
|
5
|
+
def self.format_url(song)
|
|
6
|
+
song.format_attributes_with_separator!("-")
|
|
7
|
+
"http://www.songlyrics.com/#{song.author}/#{song.title}-lyrics/"
|
|
6
8
|
end
|
|
7
|
-
module_function :format_url
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
unless lyrics_container.nil?
|
|
13
|
-
elements = lyrics_container.children.to_a
|
|
14
|
-
phrases = elements.select { |el| el.text? && el.text != "\n" && !el.blank? }
|
|
15
|
-
phrases.map! { |element| element.text.strip }
|
|
16
|
-
end
|
|
10
|
+
Contract Tempfile => Or[Array, nil]
|
|
11
|
+
def self.extract_lyric(data)
|
|
12
|
+
Providers.extract_lyrics_at_css_from_data('#songLyricsDiv', data)
|
|
17
13
|
end
|
|
18
|
-
module_function :extract_lyric
|
|
19
14
|
end
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'song'
|
|
2
|
+
|
|
3
|
+
module Providers
|
|
4
|
+
include Contracts
|
|
5
|
+
|
|
2
6
|
Contract Symbol => Module
|
|
3
|
-
def build_klass(provider)
|
|
4
|
-
klass = "
|
|
7
|
+
def self.build_klass(provider)
|
|
8
|
+
klass = "Providers::" + provider.to_s.camelize
|
|
5
9
|
klass.constantize
|
|
6
10
|
end
|
|
7
|
-
|
|
11
|
+
|
|
12
|
+
def self.extract_lyrics_at_css_from_data(css_element, data)
|
|
13
|
+
html = Nokogiri::HTML(data)
|
|
14
|
+
lyrics_container = html.css(css_element).first
|
|
15
|
+
unless lyrics_container.nil?
|
|
16
|
+
elements = lyrics_container.children.to_a
|
|
17
|
+
phrases = elements.select { |el| el.text? && el.text != "\n" && !el.blank? }
|
|
18
|
+
phrases.map! { |element| element.text.strip }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
8
21
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class Song
|
|
2
|
+
attr_accessor :author, :title
|
|
3
|
+
|
|
4
|
+
def initialize(author, title)
|
|
5
|
+
@author = author
|
|
6
|
+
@title = title
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.valid?(val)
|
|
10
|
+
val.is_a?(Song) && !val.author.blank? && !val.title.blank?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.to_s
|
|
14
|
+
"a valid author and song title please"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def format_attributes_with_separator!(separator)
|
|
18
|
+
self.author = I18n.transliterate(@author.strip.gsub(" ", separator))
|
|
19
|
+
self.title = I18n.transliterate(@title.strip.gsub(" ", separator))
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/lyrics_finder.rb
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
require_relative 'lyrics_finder/dependencies'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
UsageError = Class.new(StandardError)
|
|
7
|
-
attr_reader :providers
|
|
8
|
-
|
|
9
|
-
def initialize(*args)
|
|
10
|
-
@providers = filter_providers(args)
|
|
11
|
-
end
|
|
3
|
+
class Finder
|
|
4
|
+
include Contracts
|
|
5
|
+
PROVIDERS_LIST = [:lyrics_wikia, :song_lyrics, :azlyrics]
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@providers.each do |provider|
|
|
17
|
-
klass = Providers.build_klass(provider)
|
|
18
|
-
url = klass.format_url(author, title)
|
|
19
|
-
|
|
20
|
-
data = perform_request(url)
|
|
21
|
-
result = klass.extract_lyric(data) if data
|
|
22
|
-
throw :song_lyric, result unless result.nil?
|
|
23
|
-
end
|
|
24
|
-
}
|
|
25
|
-
# because if it doesn't find anything returns @providers by default
|
|
26
|
-
song_lyric != @providers ? song_lyric : nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
7
|
+
def initialize(*args)
|
|
8
|
+
@providers = filter_providers(args)
|
|
9
|
+
end
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
def selected_providers
|
|
12
|
+
@providers
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def search(author, title)
|
|
16
|
+
song = Song.new(author, title)
|
|
17
|
+
perform_search(song)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
Contract Song => Or[Array, nil]
|
|
21
|
+
def perform_search(song)
|
|
22
|
+
song_lyric = catch(:song_lyric) {
|
|
23
|
+
@providers.each do |provider|
|
|
24
|
+
klass = Providers.build_klass(provider)
|
|
25
|
+
url = klass.format_url(song)
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
data = perform_request(url)
|
|
28
|
+
result = klass.extract_lyric(data) if data
|
|
29
|
+
throw :song_lyric, result unless result.nil?
|
|
42
30
|
end
|
|
31
|
+
}
|
|
32
|
+
# because if it doesn't find anything returns @providers by default
|
|
33
|
+
song_lyric != @providers ? song_lyric : nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def filter_providers(providers)
|
|
39
|
+
valid_providers = []
|
|
40
|
+
providers.each do |provider|
|
|
41
|
+
valid_providers << provider if PROVIDERS_LIST.include?(provider)
|
|
43
42
|
end
|
|
43
|
+
valid_providers.any? ? valid_providers : PROVIDERS_LIST
|
|
44
|
+
end
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
|
46
|
+
def perform_request(url)
|
|
47
|
+
begin
|
|
48
|
+
open(url)
|
|
49
|
+
rescue Exception => ex
|
|
50
|
+
# puts "ERROR: " + ex.message
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
data/lyrics_finder.gemspec
CHANGED
|
@@ -22,14 +22,14 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.add_development_dependency 'rake'
|
|
23
23
|
|
|
24
24
|
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
|
25
|
-
spec.add_development_dependency 'rspec-nc', '0.0.6'
|
|
26
|
-
spec.add_development_dependency 'vcr', '2.9.2'
|
|
27
|
-
spec.add_development_dependency 'webmock', '1.18.0'
|
|
28
|
-
spec.add_development_dependency 'coveralls', '0.7.0'
|
|
25
|
+
spec.add_development_dependency 'rspec-nc', '~> 0.0.6'
|
|
26
|
+
spec.add_development_dependency 'vcr', '~> 2.9.2'
|
|
27
|
+
spec.add_development_dependency 'webmock', '~> 1.18.0'
|
|
28
|
+
spec.add_development_dependency 'coveralls', '~> 0.7.0'
|
|
29
29
|
|
|
30
|
-
spec.add_dependency 'nokogiri', '1.6.1'
|
|
31
|
-
spec.add_dependency 'activesupport', '4.1.1'
|
|
32
|
-
spec.add_dependency 'i18n', '0.6.9'
|
|
30
|
+
spec.add_dependency 'nokogiri', '~> 1.6.1'
|
|
31
|
+
spec.add_dependency 'activesupport', '~> 4.1.1'
|
|
32
|
+
spec.add_dependency 'i18n', '~> 0.6.9'
|
|
33
33
|
spec.add_dependency 'contracts', '0.4'
|
|
34
|
-
spec.add_dependency 'thor', '0.19.1'
|
|
34
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
|
35
35
|
end
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
describe
|
|
1
|
+
describe Finder do
|
|
2
2
|
describe 'sets @providers properly on initialization' do
|
|
3
3
|
context 'without specifying providers' do
|
|
4
|
-
let(:
|
|
4
|
+
let(:finder) { Finder.new }
|
|
5
5
|
|
|
6
6
|
it 'sets @providers to default PROVIDERS_LIST' do
|
|
7
|
-
expect(
|
|
7
|
+
expect(finder.selected_providers).to eq Finder::PROVIDERS_LIST
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
context 'specifying providers' do
|
|
12
12
|
context 'some providers are invalid' do
|
|
13
|
-
let(:
|
|
13
|
+
let(:finder) { Finder.new(:lyrics_wikia, :bad_songs) }
|
|
14
14
|
|
|
15
15
|
it 'filters invalid providers' do
|
|
16
|
-
expect(
|
|
16
|
+
expect(finder.selected_providers).to match_array [:lyrics_wikia]
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
context 'all providers are invalid' do
|
|
21
|
-
let(:
|
|
21
|
+
let(:finder) { Finder.new(:bad_songs, :invalid_songs) }
|
|
22
22
|
|
|
23
23
|
it 'sets @providers to default PROVIDERS_LIST' do
|
|
24
|
-
expect(
|
|
24
|
+
expect(finder.selected_providers).to eq Finder::PROVIDERS_LIST
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -31,9 +31,9 @@ describe LyricsFinder::Fetcher do
|
|
|
31
31
|
describe 'using LyricsWikia as the provider' do
|
|
32
32
|
context 'with a song that can be found' do
|
|
33
33
|
before :each do
|
|
34
|
-
@
|
|
34
|
+
@finder = Finder.new(:lyrics_wikia)
|
|
35
35
|
VCR.use_cassette 'LyricsWikia 200 search' do
|
|
36
|
-
@song = @
|
|
36
|
+
@song = @finder.search("american authors", "best day of my life")
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -49,9 +49,9 @@ describe LyricsFinder::Fetcher do
|
|
|
49
49
|
# Searching for a song that exist but it's not yet on this website.
|
|
50
50
|
context 'with a song that cannot be found' do
|
|
51
51
|
before :each do
|
|
52
|
-
@
|
|
52
|
+
@finder = Finder.new(:lyrics_wikia)
|
|
53
53
|
VCR.use_cassette 'LyricsWikia Song does not exist search' do
|
|
54
|
-
@song = @
|
|
54
|
+
@song = @finder.search("arctic monkeys", "do i wanna know")
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -63,9 +63,9 @@ describe LyricsFinder::Fetcher do
|
|
|
63
63
|
|
|
64
64
|
describe 'using Azlyrics as the provider' do
|
|
65
65
|
before :each do
|
|
66
|
-
@
|
|
66
|
+
@finder = Finder.new(:azlyrics)
|
|
67
67
|
VCR.use_cassette 'Azlyrics 200 search' do
|
|
68
|
-
@song = @
|
|
68
|
+
@song = @finder.search("american authors", "best day of my life")
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -80,9 +80,9 @@ describe LyricsFinder::Fetcher do
|
|
|
80
80
|
|
|
81
81
|
describe 'using SongLyrics as the provider' do
|
|
82
82
|
before :each do
|
|
83
|
-
@
|
|
83
|
+
@finder = Finder.new(:song_lyrics)
|
|
84
84
|
VCR.use_cassette 'SongLyrics 200 search' do
|
|
85
|
-
@song = @
|
|
85
|
+
@song = @finder.search("american authors", "best day of my life")
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
@@ -99,9 +99,9 @@ describe LyricsFinder::Fetcher do
|
|
|
99
99
|
# it just redirect to the root url www.lyricsmania.com
|
|
100
100
|
# describe 'using LyricsMania as the provider' do
|
|
101
101
|
# before :each do
|
|
102
|
-
# @
|
|
102
|
+
# @finder = Finder.new(:lyrics_mania)
|
|
103
103
|
# VCR.use_cassette 'LyricsMania 200 search' do
|
|
104
|
-
# @song = @
|
|
104
|
+
# @song = @finder.search("american authors", "best day of my life")
|
|
105
105
|
# end
|
|
106
106
|
# end
|
|
107
107
|
#
|
|
@@ -116,9 +116,9 @@ describe LyricsFinder::Fetcher do
|
|
|
116
116
|
|
|
117
117
|
describe 'with a song that cannot be found' do
|
|
118
118
|
before :each do
|
|
119
|
-
@
|
|
119
|
+
@finder = Finder.new
|
|
120
120
|
VCR.use_cassette 'Nonexistent Song 404 search' do
|
|
121
|
-
@song = @
|
|
121
|
+
@song = @finder.search("the foobar band", "rubynation")
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
|
|
@@ -128,13 +128,12 @@ describe LyricsFinder::Fetcher do
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
describe 'with invalid parameters' do
|
|
131
|
-
let(:
|
|
131
|
+
let(:finder) { Finder.new }
|
|
132
132
|
|
|
133
|
-
it 'fails with
|
|
133
|
+
it 'fails with ContractError' do
|
|
134
134
|
expect{
|
|
135
|
-
|
|
136
|
-
}.to raise_error
|
|
137
|
-
"You must supply a valid author and title")
|
|
135
|
+
finder.search("","")
|
|
136
|
+
}.to raise_error ContractError
|
|
138
137
|
end
|
|
139
138
|
end
|
|
140
139
|
end # '#search'
|