uniara_virtual_parser 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,9 @@ module UniaraVirtualParser
9
9
  let(:client) { double(:client, post: true) }
10
10
 
11
11
  describe '.client' do
12
- it 'create only one hurley_client object' do
12
+ it 'creates only one hurley_client object' do
13
13
  expect(Hurley::Client).to receive(:new).once { client }
14
+
14
15
  described_class.post '/batman'
15
16
  described_class.post '/batman'
16
17
  end
@@ -20,6 +21,7 @@ module UniaraVirtualParser
20
21
  it 'calls hurley_client and send the post' do
21
22
  expect(client).to receive(:post).with('/batman')
22
23
  allow(Hurley::Client).to receive(:new) { client }
24
+
23
25
  described_class.post '/batman'
24
26
  end
25
27
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module UniaraVirtualParser
4
+ module Services
5
+ describe Files do
6
+ describe '.files' do
7
+ let(:files) { described_class.files 'batman' }
8
+ before :each do
9
+ stub_request(:get, "http://virtual.uniara.com.br/alunos/consultas/arquivos/").
10
+ to_return(:status => 200, body: body, headers: {})
11
+ end
12
+ context 'when has 3 types of files' do
13
+ let(:body) { uniara_virtual_fixture('files_model_1.html').read }
14
+ it 'fetches the content of uniara virtual and brings the array with all files' do
15
+ expect(files.length).to eq 3
16
+ expect(files["COORDENAÇÃO"].first.name).to eq "REGULAMENTO TCC 2015"
17
+ end
18
+ end
19
+
20
+ context 'when has 2 types of files' do
21
+ let(:body) { uniara_virtual_fixture('files_model_2.html').read }
22
+ it 'fetches the content of uniara virtual and brings the array with all files' do
23
+ expect(files.length).to eq 8
24
+ expect(files["COORDENAÇÃO"].first.name).to eq "REGULAMENTO TCC 2015"
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -4,10 +4,13 @@ module UniaraVirtualParser
4
4
  module Services
5
5
  describe Grades do
6
6
  describe '.grades' do
7
- it 'fetch the content of uniara virtual and bring the array with grades' do
7
+ let(:grades) { described_class.grades 'batman' }
8
+ before do
8
9
  stub_request(:get, "http://virtual.uniara.com.br/alunos/consultas/notas/").
9
10
  to_return(:status => 200, body: uniara_virtual_fixture("grades.html").read, headers: {})
10
- grades = described_class.grades 'batman'
11
+ end
12
+
13
+ it 'fetches the content of uniara virtual and brings the array with grades' do
11
14
  expect(grades.first.name).to eq "ADMINISTRAÇÃO E ECONOMIA"
12
15
  expect(grades.length).to eq 14
13
16
  end
@@ -6,42 +6,34 @@ module UniaraVirtualParser
6
6
  let(:body) do
7
7
  { 'senha' => 'wayne', 'username' => 'bruce' }
8
8
  end
9
+ let(:response_headers) do
10
+ {
11
+ 'Set-Cookie' => 'PHPSESSID=64sbv9srm10tove94kn7nutfb2;'\
12
+ 'path=/, UVXS233E3=N; expires=Wed, 20-May-2015 02:32:01 GMT,'\
13
+ 'tipoAcesso=virtual; expires=Thu, 21-May-2015 04:32:01 GMT;'\
14
+ "path=/; domain=.uniara.com.br, #{logged_session}"\
15
+ 'expires=Wed, 20-May-2015 05:32:01 GMT; path=/'
16
+ }
17
+ end
18
+
19
+ before do
20
+ stub_request(:post, 'http://virtual.uniara.com.br/login')
21
+ .with(body: body)
22
+ .to_return(status: 200, body: '', headers: response_headers)
23
+ end
9
24
 
10
25
  context 'with a valid login' do
11
- let(:response_headers) do
12
- {
13
- 'Set-Cookie' => 'PHPSESSID=64sbv9srm10tove94kn7nutfb2;'\
14
- 'path=/, UVXS233E3=N; expires=Wed, 20-May-2015 02:32:01 GMT,'\
15
- 'tipoAcesso=virtual; expires=Thu, 21-May-2015 04:32:01 GMT;'\
16
- 'path=/; domain=.uniara.com.br, UVXS233E3=S;'\
17
- 'expires=Wed, 20-May-2015 05:32:01 GMT; path=/'
18
- }
19
- end
26
+ let(:logged_session) { 'UVXS233E3=S;' }
20
27
 
21
28
  it 'returns the token in the Client' do
22
- stub_request(:post, 'http://virtual.uniara.com.br/login')
23
- .with(body: body)
24
- .to_return(status: 200, body: '', headers: response_headers)
25
-
26
29
  expect(described_class.login 'bruce', 'wayne').to be
27
30
  end
28
31
  end
29
32
 
30
33
  context 'with an invalid login' do
31
- let(:response_headers) do
32
- {
33
- 'Set-Cookie' => 'PHPSESSID=64sbv9srm10tove94kn7nutfb2;'\
34
- 'path=/, UVXS233E3=N; expires=Wed, 20-May-2015 02:32:01 GMT,'\
35
- 'tipoAcesso=virtual; expires=Thu, 21-May-2015 04:32:01 GMT;'\
36
- 'path=/; domain=.uniara.com.br,'\
37
- 'expires=Wed, 20-May-2015 05:32:01 GMT; path=/'
38
- }
39
- end
40
- it 'raises InvalidLogin error' do
41
- stub_request(:post, 'http://virtual.uniara.com.br/login')
42
- .with(body: body)
43
- .to_return(status: 200, body: '', headers: response_headers)
34
+ let(:logged_session) { '' }
44
35
 
36
+ it 'raises InvalidLogin error' do
45
37
  expect { described_class.login 'bruce', 'wayne' }
46
38
  .to raise_error(UniaraVirtualParser::InvalidLogin)
47
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniara_virtual_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Ribeiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hurley
@@ -111,7 +111,8 @@ dependencies:
111
111
  description: A Gem to parse the Uniara Virtual system
112
112
  email:
113
113
  - mail@carlosribeiro.me
114
- executables: []
114
+ executables:
115
+ - rake
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
@@ -125,16 +126,22 @@ files:
125
126
  - LICENSE.txt
126
127
  - README.md
127
128
  - Rakefile
129
+ - bin/rake
128
130
  - lib/uniara_virtual_parser.rb
129
131
  - lib/uniara_virtual_parser/client.rb
132
+ - lib/uniara_virtual_parser/models/file.rb
130
133
  - lib/uniara_virtual_parser/models/subject.rb
134
+ - lib/uniara_virtual_parser/services/files.rb
131
135
  - lib/uniara_virtual_parser/services/grades.rb
132
136
  - lib/uniara_virtual_parser/services/login.rb
133
137
  - lib/uniara_virtual_parser/version.rb
138
+ - spec/fixtures/uniara_virtual/files_model_1.html
139
+ - spec/fixtures/uniara_virtual/files_model_2.html
134
140
  - spec/fixtures/uniara_virtual/grades.html
135
141
  - spec/spec_helper.rb
136
142
  - spec/support/fixture_helper.rb
137
143
  - spec/uniara_virtual_parser/client_spec.rb
144
+ - spec/uniara_virtual_parser/services/files_spec.rb
138
145
  - spec/uniara_virtual_parser/services/grades_spec.rb
139
146
  - spec/uniara_virtual_parser/services/login_spec.rb
140
147
  - uniara_virtual_parser.gemspec
@@ -163,9 +170,12 @@ signing_key:
163
170
  specification_version: 4
164
171
  summary: A Gem to parse the Uniara Virtual system
165
172
  test_files:
173
+ - spec/fixtures/uniara_virtual/files_model_1.html
174
+ - spec/fixtures/uniara_virtual/files_model_2.html
166
175
  - spec/fixtures/uniara_virtual/grades.html
167
176
  - spec/spec_helper.rb
168
177
  - spec/support/fixture_helper.rb
169
178
  - spec/uniara_virtual_parser/client_spec.rb
179
+ - spec/uniara_virtual_parser/services/files_spec.rb
170
180
  - spec/uniara_virtual_parser/services/grades_spec.rb
171
181
  - spec/uniara_virtual_parser/services/login_spec.rb