printfection 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df2530b52193d375b092ef18d0a041f4d0e95d31
4
- data.tar.gz: e081c979924eaf867731944e006cbaf07b2447fc
3
+ metadata.gz: f0414ab06691d47a946d01a8039d9d4a0f92d712
4
+ data.tar.gz: b4c82dc44b019602de2e4d6f62341e5201635e7c
5
5
  SHA512:
6
- metadata.gz: 0fcf583914ea0fd6ab5e2ec67ccb0e8359a45b20d59d659d4b79e31b8e84d6c75ebca6874934f1608a3116910b1bc5bda7b0801dc393d48e2d9ac580b7030a4d
7
- data.tar.gz: d01295d9c27c1d95535253c3289ad6ca1b08e6a4ba531803987e356c2bb97287a2c60978fd6cabc0c996148b7c5444ccef9a4e7b2aa7d04dbb319f225a17f77f
6
+ metadata.gz: c63dbf8fc171be25f5cd453260541192bf05c54eb1e525ff78f4c56ac909d02133d9f633238054a6469e489024574cd0b31d3c39d66eb917cce170ce157b3044
7
+ data.tar.gz: 1235cde3ea6e349ae632e14d0287a1db5a858c928f805b3cfec88a5ba4149364f60a333098bca97936f450ef526b5347ddceeafa125cd140150804d05ac53e59
@@ -2,9 +2,17 @@ module Printfection
2
2
  module API
3
3
  ENDPOINT = "api.printfection.com/v2/"
4
4
 
5
- attr_accessor :api_token
5
+ attr_writer :api_token
6
6
  attr_accessor :logger
7
7
 
8
+ def api_token
9
+ if @api_token.nil? || @api_token.strip.to_s.empty?
10
+ raise Error, "Missing API Key."
11
+ else
12
+ return @api_token
13
+ end
14
+ end
15
+
8
16
  def get(uri="/", params={})
9
17
  request :get, uri, params
10
18
  end
@@ -1,4 +1,4 @@
1
1
  module Printfection
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
4
4
 
data/spec/api_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'printfection'
2
2
 
3
3
  module Printfection
4
- describe API, ".api_token=" do
4
+ describe API, "#api_token=" do
5
5
  let(:client) { Object.new.extend(API) }
6
6
 
7
7
  it "sets the api token" do
@@ -10,6 +10,39 @@ module Printfection
10
10
  end
11
11
  end
12
12
 
13
+ describe API, "#api_token" do
14
+ context "when the API token has been set" do
15
+ it "returns the API token" do
16
+ client = Object.new.extend(API)
17
+ client.api_token = "MY-API-TOKEN"
18
+ expect(client.api_token).to eql "MY-API-TOKEN"
19
+ end
20
+ end
21
+
22
+ context "when the API token has not been set" do
23
+ it "raises an error" do
24
+ client = Object.new.extend(API)
25
+ expect { client.api_token }.to raise_error Printfection::Error, "Missing API Key."
26
+ end
27
+ end
28
+
29
+ context "when the API token is nil" do
30
+ it "raises an error" do
31
+ client = Object.new.extend(API)
32
+ client.api_token = nil
33
+ expect { client.api_token }.to raise_error Printfection::Error, "Missing API Key."
34
+ end
35
+ end
36
+
37
+ context "when the API token is empty" do
38
+ it "raises an error" do
39
+ client = Object.new.extend(API)
40
+ client.api_token = " "
41
+ expect { client.api_token }.to raise_error Printfection::Error, "Missing API Key."
42
+ end
43
+ end
44
+ end
45
+
13
46
  describe API, "#get" do
14
47
  let(:client) { Object.new.extend(API) }
15
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: printfection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey O'Hara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie