librato-metrics 1.6.2 → 2.0.0.beta

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.
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+
3
+ module Librato
4
+ module Metrics
5
+
6
+ describe SmartJSON do
7
+
8
+ describe ".read" do
9
+ context "with MultiJSON" do
10
+ before do
11
+ $".delete_if {|s| s.include?("multi_json")}
12
+ require "multi_json"
13
+ load "lib/librato/metrics/smart_json.rb"
14
+ end
15
+
16
+ after do
17
+ Object.send(:remove_const, :MultiJson)
18
+ load "lib/librato/metrics/smart_json.rb"
19
+ end
20
+
21
+ it "uses .load or .decode" do
22
+ actual = SmartJSON.read("{\"abc\":\"def\"}")
23
+
24
+ expect(SmartJSON.handler).to eq(:multi_json)
25
+ expect(actual).to be_a(Hash)
26
+ expect(actual).to have_key("abc")
27
+ expect(actual["abc"]).to eq("def")
28
+ end
29
+ end
30
+
31
+ context "with JSON" do
32
+ it "uses .parse" do
33
+ actual = SmartJSON.read("{\"abc\":\"def\"}")
34
+
35
+ expect(SmartJSON.handler).to eq(:json)
36
+ expect(actual).to be_a(Hash)
37
+ expect(actual).to have_key("abc")
38
+ expect(actual["abc"]).to eq("def")
39
+ end
40
+ end
41
+ end
42
+
43
+ describe ".write" do
44
+ context "with MultiJSON" do
45
+ before do
46
+ $".delete_if {|s| s.include?("multi_json")}
47
+ require "multi_json"
48
+ load "lib/librato/metrics/smart_json.rb"
49
+ end
50
+
51
+ after do
52
+ Object.send(:remove_const, :MultiJson)
53
+ load "lib/librato/metrics/smart_json.rb"
54
+ end
55
+
56
+ it "uses .dump or .decode" do
57
+ actual = SmartJSON.write({abc: 'def'})
58
+
59
+ expect(SmartJSON.handler).to eq(:multi_json)
60
+ expect(actual).to be_a(String)
61
+ expect(actual).to eq("{\"abc\":\"def\"}")
62
+ end
63
+ end
64
+
65
+ context "with JSON" do
66
+ it "uses .generate" do
67
+ actual = SmartJSON.write({abc: 'def'})
68
+
69
+ expect(SmartJSON.handler).to eq(:json)
70
+ expect(actual).to be_a(String)
71
+ expect(actual).to eq("{\"abc\":\"def\"}")
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -6,36 +6,36 @@ module Librato
6
6
 
7
7
  describe "#authorize" do
8
8
  context "when given two arguments" do
9
- it "should store them on simple" do
9
+ it "stores them on simple" do
10
10
  Metrics.authenticate 'tester@librato.com', 'api_key'
11
- Metrics.client.email.should == 'tester@librato.com'
12
- Metrics.client.api_key.should == 'api_key'
11
+ expect(Metrics.client.email).to eq('tester@librato.com')
12
+ expect(Metrics.client.api_key).to eq('api_key')
13
13
  end
14
14
  end
15
15
  end
16
-
16
+
17
17
  describe "#faraday_adapter" do
18
- it "should return current default adapter" do
19
- Metrics.faraday_adapter.should_not be nil
18
+ it "returns current default adapter" do
19
+ expect(Metrics.faraday_adapter).not_to be_nil
20
20
  end
21
21
  end
22
-
22
+
23
23
  describe "#faraday_adapter=" do
24
24
  before(:all) { @current_adapter = Metrics.faraday_adapter }
25
25
  after(:all) { Metrics.faraday_adapter = @current_adapter }
26
-
27
- it "should allow setting of faraday adapter" do
26
+
27
+ it "allows setting of faraday adapter" do
28
28
  Metrics.faraday_adapter = :excon
29
- Metrics.faraday_adapter.should == :excon
29
+ expect(Metrics.faraday_adapter).to eq(:excon)
30
30
  Metrics.faraday_adapter = :patron
31
- Metrics.faraday_adapter.should == :patron
31
+ expect(Metrics.faraday_adapter).to eq(:patron)
32
32
  end
33
33
  end
34
34
 
35
35
  describe "#persistence" do
36
- it "should allow configuration of persistence method" do
36
+ it "allows configuration of persistence method" do
37
37
  Metrics.persistence = :test
38
- Metrics.persistence.should == :test
38
+ expect(Metrics.persistence).to eq(:test)
39
39
  end
40
40
  end
41
41
 
@@ -46,19 +46,19 @@ module Librato
46
46
  end
47
47
  after(:all) { Librato::Metrics.client.flush_authentication }
48
48
 
49
- it "should persist metrics immediately" do
49
+ it "persists metrics immediately" do
50
50
  Metrics.persistence = :test
51
- Metrics.submit(:foo => 123).should eql true
52
- Metrics.persister.persisted.should == {:gauges => [{:name => 'foo', :value => 123}]}
51
+ expect(Metrics.submit(foo: 123)).to be true
52
+ expect(Metrics.persister.persisted).to eq({gauges: [{name: 'foo', value: 123}]})
53
53
  end
54
54
 
55
- it "should tolerate multiple metrics" do
56
- lambda{ Librato::Metrics.submit :foo => 123, :bar => 456 }.should_not raise_error
57
- expected = {:gauges => [{:name => 'foo', :value => 123}, {:name => 'bar', :value => 456}]}
58
- Librato::Metrics.persister.persisted.should equal_unordered(expected)
55
+ it "tolerates multiple metrics" do
56
+ expect { Librato::Metrics.submit foo: 123, bar: 456 }.not_to raise_error
57
+ expected = {gauges: [{name: 'foo', value: 123}, {name: 'bar', value: 456}]}
58
+ expect(Librato::Metrics.persister.persisted).to equal_unordered(expected)
59
59
  end
60
60
  end
61
61
 
62
62
  end
63
63
 
64
- end
64
+ end
metadata CHANGED
@@ -1,62 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librato-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 2.0.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Sanders
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
- - certs/librato-public.pem
12
- date: 2020-08-19 00:00:00.000000000 Z
11
+ - !binary |-
12
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURMakNDQWhhZ0F3SUJB
13
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE5TVEwd0N3WURWUVFEREFSdFlY
14
+ UjAKTVJjd0ZRWUtDWkltaVpQeUxHUUJHUllIYkdsaWNtRjBiekVUTUJFR0Nn
15
+ bVNKb21UOGl4a0FSa1dBMk52YlRBZQpGdzB4TlRFd01USXlNakEwTXpWYUZ3
16
+ MHhOakV3TVRFeU1qQTBNelZhTUQweERUQUxCZ05WQkFNT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
33
+ UEZVZU1TaEgvSC9GRVlyZXhSdmFNSG8vNTJCZzB6UDB5U1NBUURvdG0rcWdN
34
+ ZHJ1MlhSRGpFNU1zCjlCaGVBbm95Z0dIcG9LV3RFeHBza2xDcHBMMXEyWGx6
35
+ dzJsaG9DTUxDU1NqOVQvWXlSVEwzVVFZb0s1cFBBNzYKaHZqeDBXSlA4cHpa
36
+ TUpQS0pCUlpRWEpPNWlmRVB5S2paeU1pNVhNSG1ydERjbEhMajNzeDRSQXZF
37
+ WmpHV2tSUApKU1E9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
38
+ date: 2016-08-24 00:00:00.000000000 Z
13
39
  dependencies:
14
40
  - !ruby/object:Gem::Dependency
15
41
  name: faraday
16
42
  requirement: !ruby/object:Gem::Requirement
17
43
  requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0.7'
21
- - - "<"
22
- - !ruby/object:Gem::Version
23
- version: '2.0'
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- version: '0.7'
31
- - - "<"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- - !ruby/object:Gem::Dependency
35
- name: multi_json
36
- requirement: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
44
+ - - ! '>='
39
45
  - !ruby/object:Gem::Version
40
46
  version: '0'
41
47
  type: :runtime
42
48
  prerelease: false
43
49
  version_requirements: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  - !ruby/object:Gem::Dependency
49
55
  name: aggregate
50
56
  requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ~>
53
59
  - !ruby/object:Gem::Version
54
60
  version: 0.2.2
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ~>
60
66
  - !ruby/object:Gem::Version
61
67
  version: 0.2.2
62
68
  description: An easy to use ruby wrapper for Librato's Metrics API
@@ -66,9 +72,9 @@ extensions: []
66
72
  extra_rdoc_files:
67
73
  - LICENSE
68
74
  files:
69
- - ".gitignore"
70
- - ".rspec"
71
- - ".travis.yml"
75
+ - .gitignore
76
+ - .rspec
77
+ - .travis.yml
72
78
  - CHANGELOG.md
73
79
  - Gemfile
74
80
  - LICENSE
@@ -97,7 +103,6 @@ files:
97
103
  - lib/librato/metrics/smart_json.rb
98
104
  - lib/librato/metrics/version.rb
99
105
  - librato-metrics.gemspec
100
- - spec/integration/deprecated_methods_spec.rb
101
106
  - spec/integration/metrics/annotator_spec.rb
102
107
  - spec/integration/metrics/connection_spec.rb
103
108
  - spec/integration/metrics/middleware/count_requests_spec.rb
@@ -110,34 +115,34 @@ files:
110
115
  - spec/unit/metrics/connection_spec.rb
111
116
  - spec/unit/metrics/queue/autosubmission_spec.rb
112
117
  - spec/unit/metrics/queue_spec.rb
118
+ - spec/unit/metrics/smart_json_spec.rb
113
119
  - spec/unit/metrics_spec.rb
114
120
  homepage: https://github.com/librato/librato-metrics
115
121
  licenses:
116
122
  - BSD 3-clause
117
123
  metadata: {}
118
- post_install_message:
124
+ post_install_message:
119
125
  rdoc_options:
120
- - "--charset=UTF-8"
126
+ - --charset=UTF-8
121
127
  require_paths:
122
128
  - lib
123
129
  required_ruby_version: !ruby/object:Gem::Requirement
124
130
  requirements:
125
- - - ">="
131
+ - - ! '>='
126
132
  - !ruby/object:Gem::Version
127
- version: '0'
133
+ version: '1.9'
128
134
  required_rubygems_version: !ruby/object:Gem::Requirement
129
135
  requirements:
130
- - - ">="
136
+ - - ! '>'
131
137
  - !ruby/object:Gem::Version
132
- version: '0'
138
+ version: 1.3.1
133
139
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.6.14
136
- signing_key:
140
+ rubyforge_project:
141
+ rubygems_version: 2.6.6
142
+ signing_key:
137
143
  specification_version: 2
138
144
  summary: Ruby wrapper for Librato's Metrics API
139
145
  test_files:
140
- - spec/integration/deprecated_methods_spec.rb
141
146
  - spec/integration/metrics/annotator_spec.rb
142
147
  - spec/integration/metrics/connection_spec.rb
143
148
  - spec/integration/metrics/middleware/count_requests_spec.rb
@@ -150,4 +155,5 @@ test_files:
150
155
  - spec/unit/metrics/connection_spec.rb
151
156
  - spec/unit/metrics/queue/autosubmission_spec.rb
152
157
  - spec/unit/metrics/queue_spec.rb
158
+ - spec/unit/metrics/smart_json_spec.rb
153
159
  - spec/unit/metrics_spec.rb
Binary file
@@ -1,85 +0,0 @@
1
- require 'spec_helper'
2
-
3
- DEPRECATED_METHODS = %w[fetch list update delete]
4
- describe Librato::Metrics do
5
-
6
- DEPRECATED_METHODS.each do |deprecated_method|
7
- it { should respond_to(deprecated_method) }
8
- end
9
-
10
- describe "Client" do
11
- let(:client) { Librato::Metrics.client }
12
- subject { client }
13
-
14
- before(:all) { prep_integration_tests }
15
-
16
- before do
17
- client.submit :test_metric => 123.0
18
- end
19
-
20
- DEPRECATED_METHODS.each do |deprecated_method|
21
- it { should respond_to(deprecated_method) }
22
- end
23
-
24
- describe "#fetch" do
25
- context "with no measurements attributes" do
26
- let(:metric) { client.fetch(:test_metric) }
27
- subject { metric }
28
-
29
- it { should_not be_nil }
30
-
31
- it "should return a metric" do
32
- metric["name"].should == "test_metric"
33
- end
34
- end
35
-
36
- context "with measurements attributes" do
37
- let(:measurements) { client.fetch(:test_metric, :count => 1) }
38
- subject { measurements }
39
-
40
- it { should_not be_nil }
41
- it { should_not be_empty }
42
-
43
- it "should return the measurements" do
44
- measurements.should have_key("unassigned")
45
- measurements["unassigned"].should be_an(Array)
46
- measurements["unassigned"].first["value"].should == 123.0
47
- end
48
- end
49
- end
50
-
51
- describe "#list" do
52
- let(:metrics) { client.list }
53
- subject { metrics }
54
-
55
- it { should_not be_nil }
56
- it { should_not be_empty }
57
-
58
- it "should return the list of metrics" do
59
- metric = metrics.find { |m| m["name"] == "test_metric" }
60
- metric.should_not be_nil
61
- end
62
- end
63
-
64
- describe "#update" do
65
- before do
66
- client.update("test_metric", :display_name => "Test Deprecated Update")
67
- end
68
-
69
- let(:updated_metric) { client.get_metric("test_metric") }
70
-
71
- it "should update the metric" do
72
- updated_metric["display_name"].should == "Test Deprecated Update"
73
- end
74
- end
75
-
76
- describe "#delete" do
77
- it "should delete the metric" do
78
- client.metrics(:name => "test_metric").should_not be_empty
79
- client.delete("test_metric")
80
- client.metrics(:name => "test_metric").should be_empty
81
- end
82
- end
83
-
84
- end
85
- end