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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee651fbc8ced627f9d5711d772ac0d998c4cea5f
4
- data.tar.gz: de03b76abd522d5992ac684e6446222a299bf2cc
3
+ metadata.gz: a597b9c43e8afeeac84225326bb2cd5feae00ff6
4
+ data.tar.gz: 599b496edc23eaf9f8d3cd97b1560ec67d64c269
5
5
  SHA512:
6
- metadata.gz: b15afc86cbfda8cda37ca17da233df0b68065e8f0f107f445fc8f495747e77fa3fd49de10ef21629729460b3c372ea24da2074d2fea2e8f420442ec969e38dd0
7
- data.tar.gz: ca3fff59c7a87850892817b60603dfbb26663a8516a1a0806d7b8b887a81d1eca198656dc5bff6f94f39aafbcc3508f9bb5d35dfdfad8f48509a40c0adb31096
6
+ metadata.gz: 58d374aa18d1df960a68c30ba93933656699a44b547170d30334067d0d2093cf75b69d271f738530225cbb2b25e3a93af7ee64003bc3b489707014ea7842023c
7
+ data.tar.gz: bd950c0efe4e478c0815ed9a38f49a22a9df4e006965329a7d12f89e57ab21ad3f7e7b8ebbee7d41ce5f5653a6deb73b8997b8e842cbff8ca1714f538ff7c070
@@ -7,11 +7,14 @@ module Storify
7
7
  # define end of content example
8
8
  EOC = {'content' => {'stories' => [], 'elements' => []}}
9
9
 
10
- attr_reader :api_key, :username, :token
10
+ attr_accessor :api_key, :username, :token
11
11
 
12
- def initialize(api_key, username)
13
- @api_key = api_key
14
- @username = username
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: {})
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Storify::Client do
4
4
  before(:each) do
5
- @client = Storify::Client.new(@api_key, @username)
5
+ @client = Storify::Client.new(:api_key => @api_key, :username => @username)
6
6
  end
7
7
 
8
8
  context "Authentication" do
@@ -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
- puts "Enter a Story Id for your Account:"
9
- @story = STDIN.gets.chomp
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rizwan Tejpar