et 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/et/api.rb +11 -3
- data/lib/et/version.rb +1 -1
- data/spec/lib/api_spec.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 878c7e0d9b0502f6a7d4e1b74eac6f3b74fd37d8
|
4
|
+
data.tar.gz: 9de9207f81b70fc88e79b3789535c65852fa7946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 855269fa8bf46ca3e373da7364b35872a73356cd973098eaceabb535be52f7381cfc11347403d45f403a5887b6f41f912536cc442d70fcb2a4e5502e9c617cb3
|
7
|
+
data.tar.gz: af29f4894062f35784fceb19e0316f7134208b53c3048591090a48ceff3eabf715d63b7f816cb1c4c7129af73335e5debf944b59cae35f92d0e221098e2e159f
|
data/Gemfile.lock
CHANGED
data/lib/et/api.rb
CHANGED
@@ -27,8 +27,16 @@ module ET
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def get_lesson(slug)
|
30
|
-
|
31
|
-
|
30
|
+
request = Net::HTTP::Get.new(lesson_url(slug))
|
31
|
+
request["Authorization"] = auth_header
|
32
|
+
|
33
|
+
response = nil
|
34
|
+
Net::HTTP.start(lessons_url.host, lessons_url.port,
|
35
|
+
use_ssl: lessons_url.scheme == "https") do |http|
|
36
|
+
|
37
|
+
response = http.request(request)
|
38
|
+
end
|
39
|
+
body = JSON.parse(response.body, symbolize_names: true)
|
32
40
|
body[:lesson]
|
33
41
|
end
|
34
42
|
|
@@ -69,7 +77,7 @@ module ET
|
|
69
77
|
private
|
70
78
|
|
71
79
|
def lesson_url(slug)
|
72
|
-
URI.join(host, "lessons/#{slug}.json")
|
80
|
+
URI.join(host, "lessons/#{slug}.json?submittable=1")
|
73
81
|
end
|
74
82
|
|
75
83
|
def lessons_url
|
data/lib/et/version.rb
CHANGED
data/spec/lib/api_spec.rb
CHANGED
@@ -35,9 +35,20 @@ describe ET::API do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "queries for a single lesson" do
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
request = {}
|
39
|
+
response = double
|
40
|
+
http = double
|
41
|
+
lesson_uri = URI("http://localhost:3000/lessons/rock-paper-scissors.json?submittable=1")
|
42
|
+
expect(Net::HTTP::Get).to receive(:new).
|
43
|
+
with(lesson_uri).
|
44
|
+
and_return(request)
|
45
|
+
expect(Net::HTTP).to receive(:start).with(
|
46
|
+
lesson_uri.host,
|
47
|
+
lesson_uri.port,
|
48
|
+
use_ssl: lesson_uri.scheme == "https").
|
49
|
+
and_yield(http)
|
50
|
+
expect(http).to receive(:request).and_return(response)
|
51
|
+
expect(response).to receive(:body).and_return(lesson_response)
|
41
52
|
|
42
53
|
result = api.get_lesson("rock-paper-scissors")
|
43
54
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: et
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Sheehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|