storify 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/storify/client.rb +7 -4
- data/spec/client_auth_spec.rb +1 -1
- data/spec/client_noauth_spec.rb +1 -1
- data/spec/client_spec.rb +33 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a597b9c43e8afeeac84225326bb2cd5feae00ff6
|
4
|
+
data.tar.gz: 599b496edc23eaf9f8d3cd97b1560ec67d64c269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d374aa18d1df960a68c30ba93933656699a44b547170d30334067d0d2093cf75b69d271f738530225cbb2b25e3a93af7ee64003bc3b489707014ea7842023c
|
7
|
+
data.tar.gz: bd950c0efe4e478c0815ed9a38f49a22a9df4e006965329a7d12f89e57ab21ad3f7e7b8ebbee7d41ce5f5653a6deb73b8997b8e842cbff8ca1714f538ff7c070
|
data/lib/storify/client.rb
CHANGED
@@ -7,11 +7,14 @@ module Storify
|
|
7
7
|
# define end of content example
|
8
8
|
EOC = {'content' => {'stories' => [], 'elements' => []}}
|
9
9
|
|
10
|
-
|
10
|
+
attr_accessor :api_key, :username, :token
|
11
11
|
|
12
|
-
def initialize(
|
13
|
-
|
14
|
-
|
12
|
+
def initialize(options = {})
|
13
|
+
options.each do |k, v|
|
14
|
+
send(:"#{k}=", v)
|
15
|
+
end
|
16
|
+
|
17
|
+
yield self if block_given?
|
15
18
|
end
|
16
19
|
|
17
20
|
def auth(password, options: {})
|
data/spec/client_auth_spec.rb
CHANGED
data/spec/client_noauth_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
|
6
6
|
describe "Storify::Client -- Unauthenticated" do
|
7
7
|
before(:each) do
|
8
|
-
@client = Storify::Client.new(@api_key, @username)
|
8
|
+
@client = Storify::Client.new(:api_key => @api_key, :username => @username)
|
9
9
|
@options = {:version => :v1, :protocol => :insecure}
|
10
10
|
end
|
11
11
|
|
data/spec/client_spec.rb
CHANGED
@@ -2,11 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Storify::Client do
|
4
4
|
before(:all) do
|
5
|
-
@client = Storify::Client.new(@api_key, @username)
|
5
|
+
@client = Storify::Client.new(:api_key => @api_key, :username => @username)
|
6
6
|
@client.auth(get_password)
|
7
|
+
end
|
8
|
+
|
9
|
+
context ".new" do
|
10
|
+
it "should accept a hash of credentials (api_key, username, token)" do
|
11
|
+
clients = [Storify::Client.new(:api_key => 'k', :username => 'u', :token => 't'),
|
12
|
+
Storify::Client.new('api_key' => 'k', 'username' => 'u', 'token' => 't')]
|
13
|
+
|
14
|
+
clients.each do |c|
|
15
|
+
c.api_key.should == 'k'
|
16
|
+
c.username.should == 'u'
|
17
|
+
c.token.should == 't'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should accept a configuration block of credentials" do
|
22
|
+
client = Storify::Client.new do |config|
|
23
|
+
config.api_key = 'YOUR API KEY'
|
24
|
+
config.username = 'YOUR USERNAME'
|
25
|
+
config.token = 'YOUR AUTH TOKEN'
|
26
|
+
end
|
7
27
|
|
8
|
-
|
9
|
-
|
28
|
+
client.api_key.should == 'YOUR API KEY'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should raise an exception for unknown credentials" do
|
32
|
+
expect {Storify::Client.new(:unknown => 'value')}.to raise_exception
|
33
|
+
expect {Storify::Client.new {|config| config.unknown = ''}}.to raise_exception
|
34
|
+
end
|
10
35
|
end
|
11
36
|
|
12
37
|
context "GET /stories/:username" do
|
@@ -27,6 +52,11 @@ describe Storify::Client do
|
|
27
52
|
end
|
28
53
|
|
29
54
|
context "GET /stories/:username/:slug" do
|
55
|
+
before(:all) do
|
56
|
+
puts "Enter a Story Id for your Account:"
|
57
|
+
@story = STDIN.gets.chomp
|
58
|
+
end
|
59
|
+
|
30
60
|
it "should get a specific story for a user (all pages)" do
|
31
61
|
@client.story(@story).elements.length.should == 3
|
32
62
|
end
|