oxford_learners_dictionaries 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe OxfordLearnersDictionaries::WordOfTheDay do
4
+
5
+ let(:word) { 'election' }
6
+ let(:short_definition) { 'the process of choosing a person or a group of people' }
7
+
8
+ let(:url) { 'http://www.oxfordlearnersdictionaries.com' }
9
+ let(:word_url) { "http://www.oxfordlearnersdictionaries.com/definition/english/#{word}" }
10
+ let(:fixture_wotd) { './spec/fixtures/wotd.html' }
11
+ let(:fixture) { './spec/fixtures/election.html' }
12
+
13
+ let(:wotd) { described_class.new }
14
+
15
+ describe '.initialize' do
16
+ before do
17
+ stub_request(:any, url).to_return(body: File.new(fixture_wotd))
18
+ end
19
+
20
+ it 'matches word of the day' do
21
+ expect(wotd.word).to eq word
22
+ end
23
+
24
+ it 'gets short definition for wotd' do
25
+ expect(wotd.short_definition).to match short_definition
26
+ end
27
+ end
28
+
29
+ describe '.look_up' do
30
+ context 'when word is nil' do
31
+ before do
32
+ stub_request(:any, url).to_return(body: nil)
33
+ wotd.look_up
34
+ end
35
+
36
+ it 'does not instantiate English class' do
37
+ expect(OxfordLearnersDictionaries::English).to_not receive(:new)
38
+ end
39
+
40
+ it 'keeps english attribute as nil' do
41
+ expect(wotd.english).to be_nil
42
+ end
43
+ end
44
+
45
+ context 'when word is valid' do
46
+ before do
47
+ stub_request(:any, url).to_return(body: File.new(fixture_wotd))
48
+ stub_request(:any, word_url).to_return(body: File.new(fixture))
49
+ wotd.look_up
50
+ end
51
+
52
+ let(:definition) { 'the process of choosing a person or a group of people for a position' }
53
+
54
+ it 'matches description count' do
55
+ expect(wotd.english.definition.count).to eq 2
56
+ expect(wotd.english.definition.to_s).to match definition
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/spec/"
4
+ end
5
+
6
+ require 'webmock/rspec'
7
+ require 'oxford_learners_dictionaries'
8
+
9
+ RSpec.configure do |config|
10
+ config.filter_run :focus
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ if config.files_to_run.one?
14
+ config.default_formatter = 'doc'
15
+ end
16
+
17
+ config.order = :random
18
+ Kernel.srand config.seed
19
+
20
+ config.expect_with :rspec do |expectations|
21
+ expectations.syntax = :expect
22
+ end
23
+
24
+ config.mock_with :rspec do |mocks|
25
+ mocks.syntax = :expect
26
+ mocks.verify_partial_doubles = true
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oxford_learners_dictionaries
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Felipe Pelizaro Gentil
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.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.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.19'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.19'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.3
97
+ description: "Implementation of a Oxford Learner's Dictionaries API, \n it
98
+ parses the website and formats the meaning of the word"
99
+ email:
100
+ - cdigentil@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".ruby-gemset"
108
+ - ".ruby-version"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - lib/oxford_learners_dictionaries.rb
115
+ - lib/oxford_learners_dictionaries/english.rb
116
+ - lib/oxford_learners_dictionaries/oxford_learners_dictionaries.rb
117
+ - lib/oxford_learners_dictionaries/version.rb
118
+ - lib/oxford_learners_dictionaries/word_of_the_day.rb
119
+ - oxford_learners_dictionaries.gemspec
120
+ - spec/fixtures/car.html
121
+ - spec/fixtures/election.html
122
+ - spec/fixtures/get.html
123
+ - spec/fixtures/however.html
124
+ - spec/fixtures/lion.html
125
+ - spec/fixtures/live.html
126
+ - spec/fixtures/take.html
127
+ - spec/fixtures/wotd.html
128
+ - spec/oxford_learners_dictionaries/english_spec.rb
129
+ - spec/oxford_learners_dictionaries/word_of_the_day_spec.rb
130
+ - spec/spec_helper.rb
131
+ homepage: ''
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.2.2
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Oxford Learner's Dictionaries API
155
+ test_files:
156
+ - spec/fixtures/car.html
157
+ - spec/fixtures/election.html
158
+ - spec/fixtures/get.html
159
+ - spec/fixtures/however.html
160
+ - spec/fixtures/lion.html
161
+ - spec/fixtures/live.html
162
+ - spec/fixtures/take.html
163
+ - spec/fixtures/wotd.html
164
+ - spec/oxford_learners_dictionaries/english_spec.rb
165
+ - spec/oxford_learners_dictionaries/word_of_the_day_spec.rb
166
+ - spec/spec_helper.rb