oxford_learners_dictionaries 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -5
  3. data/lib/oxford_learners_dictionaries/english.rb +15 -8
  4. data/lib/oxford_learners_dictionaries/version.rb +1 -1
  5. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/getting_type_from_words/when_its_a_noun/matches_noun.yml +4 -4
  6. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/getting_type_from_words/when_its_a_verb/matches_verb.yml +9 -9
  7. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/getting_type_from_words/when_its_an_adverb/matches_adverb.yml +3 -3
  8. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/important_words/_get/counts_3_definitions.yml +4 -4
  9. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/important_words/_get/matches_noun.yml +3 -3
  10. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/important_words/_take/counts_3_definitions.yml +9 -8
  11. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/important_words/_take/matches_noun.yml +8 -8
  12. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_more_than_one_definitions/counts_3_definitions.yml +3 -3
  13. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_more_than_one_definitions/shows_all_definitions_in_Hash.yml +4 -4
  14. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/counts_1_definition.yml +4 -4
  15. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/shows_definition_in_Hash.yml +3 -3
  16. data/spec/fixtures/vcr/OxfordLearnersDictionaries_English/when_the_word_is_not_found/returns_empty.yml +283 -0
  17. data/spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/gets_short_definition_for_wotd.yml +313 -314
  18. data/spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/matches_word_of_the_day.yml +313 -314
  19. data/spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_look_up/when_word_is_valid/matches_description_count.yml +1403 -1204
  20. data/spec/oxford_learners_dictionaries/english_spec.rb +9 -6
  21. data/spec/oxford_learners_dictionaries/word_of_the_day_spec.rb +3 -3
  22. metadata +4 -2
@@ -4,9 +4,12 @@ describe OxfordLearnersDictionaries::English, :vcr do
4
4
 
5
5
  let(:word) { "word" }
6
6
  let(:formatted_word) { word.strip.gsub(' ', '-') }
7
- let(:param_word) { formatted_word.gsub('-', '+') }
7
+ let(:param_word) { formatted_word.gsub('-', '+') }
8
+
8
9
  let(:dictionary) { described_class.new(word) }
9
- let(:url) { "http://www.oxfordlearnersdictionaries.com/definition/english/#{formatted_word}?q=#{param_word}" }
10
+ let(:url_1) { "http://www.oxfordlearnersdictionaries.com/definition/english/#{formatted_word}?q=#{param_word}" }
11
+ let(:url_2) { "http://www.oxfordlearnersdictionaries.com/definition/english/#{formatted_word}1?q=#{param_word}" }
12
+ let(:urls) { [ url_1, url_2 ] }
10
13
 
11
14
  describe '.initialize' do
12
15
 
@@ -14,8 +17,8 @@ describe OxfordLearnersDictionaries::English, :vcr do
14
17
  expect(dictionary.word).to eq word
15
18
  end
16
19
 
17
- it 'initializes @url' do
18
- expect(dictionary.url).to eq url
20
+ it 'initializes @urls' do
21
+ expect(dictionary.urls).to eq urls
19
22
  end
20
23
 
21
24
  it 'initializes @definition' do
@@ -25,7 +28,7 @@ describe OxfordLearnersDictionaries::English, :vcr do
25
28
 
26
29
  describe '#look_up' do
27
30
  it 'open url and parse data' do
28
- stub_request(:any, url).to_return(body: "fpgentil")
31
+ stub_request(:any, url_1).to_return(body: "fpgentil")
29
32
  expect(dictionary).to receive(:parse).and_return(true)
30
33
  dictionary.look_up
31
34
  end
@@ -128,7 +131,7 @@ describe OxfordLearnersDictionaries::English, :vcr do
128
131
 
129
132
  describe 'when the word is not found' do
130
133
  before :each do
131
- stub_request(:any, url).to_raise(OpenURI::HTTPError.new('', nil))
134
+ stub_request(:any, url_1).to_raise(OpenURI::HTTPError.new('', nil))
132
135
  end
133
136
  let(:word) { 'asdf' }
134
137
 
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe OxfordLearnersDictionaries::WordOfTheDay, :vcr do
4
4
 
5
- let(:word) { 'intangible' }
5
+ let(:word) { 'surpass' }
6
6
  let(:wotd) { described_class.new }
7
7
 
8
8
  let(:formatted_word) { word.strip.gsub(' ', '-') }
9
9
  let(:param_word) { formatted_word.gsub('-', '+') }
10
- let(:short_definition) { 'that exists but that is difficult to describe' }
10
+ let(:short_definition) { 'to do or be better than someone or' }
11
11
 
12
12
  let(:url) { 'http://www.oxfordlearnersdictionaries.com' }
13
13
  let(:word_url) { "http://www.oxfordlearnersdictionaries.com/definition/english/#{formatted_word}?q=#{param_word}" }
@@ -45,7 +45,7 @@ describe OxfordLearnersDictionaries::WordOfTheDay, :vcr do
45
45
  wotd.look_up
46
46
  end
47
47
 
48
- let(:definition) { 'something that does not exist as a physical thing but is still valuable to a company' }
48
+ let(:definition) { 'to do or be better than somebody/something' }
49
49
 
50
50
  it 'matches description count' do
51
51
  expect(wotd.english.count).to eq 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxford_learners_dictionaries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Pelizaro Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-28 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,6 +156,7 @@ files:
156
156
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_more_than_one_definitions/shows_all_definitions_in_Hash.yml
157
157
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/counts_1_definition.yml
158
158
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/shows_definition_in_Hash.yml
159
+ - spec/fixtures/vcr/OxfordLearnersDictionaries_English/when_the_word_is_not_found/returns_empty.yml
159
160
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/gets_short_definition_for_wotd.yml
160
161
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/matches_word_of_the_day.yml
161
162
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_look_up/when_word_is_valid/matches_description_count.yml
@@ -198,6 +199,7 @@ test_files:
198
199
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_more_than_one_definitions/shows_all_definitions_in_Hash.yml
199
200
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/counts_1_definition.yml
200
201
  - spec/fixtures/vcr/OxfordLearnersDictionaries_English/looking_up_a_word/when_a_word_has_only_one_definition/shows_definition_in_Hash.yml
202
+ - spec/fixtures/vcr/OxfordLearnersDictionaries_English/when_the_word_is_not_found/returns_empty.yml
201
203
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/gets_short_definition_for_wotd.yml
202
204
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_initialize/matches_word_of_the_day.yml
203
205
  - spec/fixtures/vcr/OxfordLearnersDictionaries_WordOfTheDay/_look_up/when_word_is_valid/matches_description_count.yml