gosquared 3.0.7 → 3.0.8

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.
@@ -1,112 +1,118 @@
1
1
  describe Gosquared::People do
2
- subject(:gs) { described_class.new("demo", "GSN-106863-S") }
3
-
4
- Gosquared::People::DIMENSIONS.each do |dimension|
5
- before do
6
- data = '{"a": [{"test": "response"}]}'
7
- stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S"
8
- ).
9
- with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
10
- to_return(status: 200, body: data, headers: {})
11
- end
12
- end
13
-
14
- Gosquared::People::DIMENSIONS.each do |dimension|
15
- it "fetches a request from the GoSquared People API with #{dimension} dimension" do
16
- next if dimension == "people"
17
- gs.send "#{dimension}"
18
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
19
- end
20
- end
21
-
22
- before do
23
- data = '{"a": [{"test": "response"}, {"with": "params"}]}'
24
- stub_request(:get, "https://api.gosquared.com/people/v1/people/example.email@example.com/devices?api_key=demo&site_token=GSN-106863-S").
25
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
26
- to_return(:status => 200, :body => data, :headers => {})
27
- end
2
+ subject(:gs) { described_class.new('demo', 'GSN-106863-S') }
3
+
4
+ Gosquared::People::DIMENSIONS.each do |dimension|
5
+ before do
6
+ data = '{"a": [{"test": "response"}]}'
7
+ stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S")
8
+ .with(headers: { 'Accept' => '*/*', 'User-Agent' => 'Ruby' })
9
+ .to_return(status: 200, body: data, headers: {})
10
+ end
11
+ end
28
12
 
29
- it "fetches a request from the GoSquared People API with a person_id and paramaters" do
30
- gs.people.person_id('example.email@example.com','devices')
31
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"params"}])
32
- end
13
+ Gosquared::People::DIMENSIONS.each do |dimension|
14
+ it "fetches a request from the GoSquared People API with #{dimension} dimension" do
15
+ next if dimension == 'people'
33
16
 
17
+ gs.send dimension.to_s
18
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }])
19
+ end
20
+ end
34
21
 
35
- Gosquared::People::DIMENSIONS.each do |dimension|
36
- before do
37
- data = '{"a": [{"test": "response"}, {"with": "params"}]}'
38
- stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S&limit=5").
39
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
40
- to_return(:status => 200, :body => data, :headers => {})
41
- end
42
- end
22
+ before do
23
+ data = '{"a": [{"test": "response"}, {"with": "params"}]}'
24
+ stub_request(:get, 'https://api.gosquared.com/people/v1/people/example.email@example.com/devices?api_key=demo&site_token=GSN-106863-S')
25
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
26
+ .to_return(status: 200, body: data, headers: {})
27
+ end
43
28
 
44
- Gosquared::People::DIMENSIONS.each do |dimension|
45
- it "fetches a request from the GoSquared People API with dimension and paramaters" do
46
- gs.send("#{dimension}").limit(5)
47
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"params"}])
48
- end
49
- end
29
+ it 'fetches a request from the GoSquared People API with a person_id and paramaters' do
30
+ gs.people.person_id('example.email@example.com', 'devices')
31
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }, { 'with' => 'params' }])
32
+ end
50
33
 
51
- before do
52
- data = '{"a": [{"test": "response"}, {"with": "filters"}]}'
53
- stub_request(:get, "https://api.gosquared.com/people/v1/people?api_key=demo&filters=%5B%7B%22key%22:%22property%22,%22path%22:%22last.location.city%22,%22operator%22:%22contains%22,%22value%22:%22london%22%7D,%7B%22key%22:%22and%22,%22filters%22:%5B%7B%22key%22:%22property%22,%22path%22:%22totals.visits%22,%22operator%22:%22%3E%22,%22value%22:%221000%22%7D%5D%7D%5D&site_token=GSN-106863-S").
54
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
55
- to_return(:status => 200, :body => data, :headers => {})
34
+ Gosquared::People::DIMENSIONS.each do |dimension|
35
+ before do
36
+ data = '{"a": [{"test": "response"}, {"with": "params"}]}'
37
+ stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S&limit=5")
38
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
39
+ .to_return(status: 200, body: data, headers: {})
40
+ end
56
41
  end
57
42
 
58
- it "fetches a request from the GoSquared People API with filtering on properties" do
59
- array=[
60
- {
61
- key: "property",
62
- path: "last.location.city",
63
- operator: "contains",
64
- value: "london"
65
- },
66
- {
67
- key: "and",
68
- filters: [
69
- {
70
- "key": "property",
71
- "path": "totals.visits",
72
- "operator": ">",
73
- "value": "1000"
74
- }
75
- ]
76
- }
77
- ]
78
- gs.people.people.filters(array)
79
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"filters"}])
80
- end
43
+ Gosquared::People::DIMENSIONS.each do |dimension|
44
+ it 'fetches a request from the GoSquared People API with dimension and paramaters' do
45
+ gs.send(dimension.to_s).limit(5)
46
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }, { 'with' => 'params' }])
47
+ end
48
+ end
81
49
 
50
+ before do
51
+ data = '{"a": [{"test": "response"}, {"with": "filters"}]}'
52
+ stub_request(:get, 'https://api.gosquared.com/people/v1/people?api_key=demo&filters=%5B%7B%22key%22:%22property%22,%22path%22:%22last.location.city%22,%22operator%22:%22contains%22,%22value%22:%22london%22%7D,%7B%22key%22:%22and%22,%22filters%22:%5B%7B%22key%22:%22property%22,%22path%22:%22totals.visits%22,%22operator%22:%22%3E%22,%22value%22:%221000%22%7D%5D%7D%5D&site_token=GSN-106863-S')
53
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
54
+ .to_return(status: 200, body: data, headers: {})
55
+ end
82
56
 
83
- it "fetches the people in a smartgroup from the GoSquared People API" do
84
- data = '{"a": [{"test": "response"}]}'
85
- stub_request(:get, "https://api.gosquared.com/people/v1/smartgroups/wat/people?api_key=demo&site_token=GSN-106863-S").
86
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
87
- to_return(:status => 200, :body => data, :headers => {})
88
- gs.people.smartgroups('wat','people')
89
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
90
- end
57
+ it 'fetches a request from the GoSquared People API with filtering on properties' do
58
+ array = [
59
+ {
60
+ key: 'property',
61
+ path: 'last.location.city',
62
+ operator: 'contains',
63
+ value: 'london'
64
+ },
65
+ {
66
+ key: 'and',
67
+ filters: [
68
+ {
69
+ "key": 'property',
70
+ "path": 'totals.visits',
71
+ "operator": '>',
72
+ "value": '1000'
73
+ }
74
+ ]
75
+ }
76
+ ]
77
+ gs.people.people.filters(array)
78
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }, { 'with' => 'filters' }])
79
+ end
91
80
 
81
+ it 'fetches the people in a smartgroup from the GoSquared People API' do
82
+ data = '{"a": [{"test": "response"}]}'
83
+ stub_request(:get, 'https://api.gosquared.com/people/v1/smartgroups/wat/people?api_key=demo&site_token=GSN-106863-S')
84
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
85
+ .to_return(status: 200, body: data, headers: {})
86
+ gs.people.smartgroups('wat', 'people')
87
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }])
88
+ end
92
89
 
93
- it "fetches the people in a smartgroup from the GoSquared People API" do
94
- data = '{"a": [{"test": "response"}]}'
95
- stub_request(:get, "https://api.gosquared.com/people/v1/smartgroups/wat/count/latest?api_key=demo&site_token=GSN-106863-S").
96
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
97
- to_return(:status => 200, :body => data, :headers => {})
98
- gs.people.smartgroups('wat','count')
99
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
100
- end
90
+ it 'fetches the people in a smartgroup from the GoSquared People API' do
91
+ data = '{"a": [{"test": "response"}]}'
92
+ stub_request(:get, 'https://api.gosquared.com/people/v1/smartgroups/wat/count/latest?api_key=demo&site_token=GSN-106863-S')
93
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
94
+ .to_return(status: 200, body: data, headers: {})
95
+ gs.people.smartgroups('wat', 'count')
96
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }])
97
+ end
101
98
 
102
- it "fetches smartgroups from the GoSquared People API" do
103
- data = '{"a": [{"test": "response"}]}'
104
- stub_request(:get, "https://api.gosquared.com/people/v1/smartgroups?api_key=demo&site_token=GSN-106863-S").
105
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
106
- to_return(:status => 200, :body => data, :headers => {})
107
- gs.people.smartgroups
108
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
109
- end
99
+ it 'fetches smartgroups from the GoSquared People API' do
100
+ data = '{"a": [{"test": "response"}]}'
101
+ stub_request(:get, 'https://api.gosquared.com/people/v1/smartgroups?api_key=demo&site_token=GSN-106863-S')
102
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
103
+ .to_return(status: 200, body: data, headers: {})
104
+ gs.people.smartgroups
105
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }])
106
+ end
110
107
 
108
+ it 'deletes a person from a project' do
109
+ stub_request(:delete, "https://api.gosquared.com/people/v1/people/1?api_key=demo&site_token=GSN-106863-S").
110
+ with(:body => "[{}]",
111
+ :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
112
+ to_return(:status => 200, :body => "", :headers => {})
113
+ gs.people.people.person_id('1')
114
+ response = gs.people.delete
115
+ expect(response.code).to eq("200")
116
+ end
111
117
 
112
- end
118
+ end
@@ -49,57 +49,55 @@ RSpec.configure do |config|
49
49
  mocks.verify_partial_doubles = true
50
50
  end
51
51
 
52
- # The settings below are suggested to provide a good initial experience
53
- # with RSpec, but feel free to customize to your heart's content.
54
- =begin
55
- # These two settings work together to allow you to limit a spec run
56
- # to individual examples or groups you care about by tagging them with
57
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
58
- # get run.
59
- config.filter_run :focus
60
- config.run_all_when_everything_filtered = true
61
-
62
- # Allows RSpec to persist some state between runs in order to support
63
- # the `--only-failures` and `--next-failure` CLI options. We recommend
64
- # you configure your source control system to ignore this file.
65
- config.example_status_persistence_file_path = "spec/examples.txt"
66
-
67
- # Limits the available syntax to the non-monkey patched syntax that is
68
- # recommended. For more details, see:
69
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
70
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
72
- config.disable_monkey_patching!
73
-
74
- # This setting enables warnings. It's recommended, but in some cases may
75
- # be too noisy due to issues in dependencies.
76
- config.warnings = true
77
-
78
- # Many RSpec users commonly either run the entire suite or an individual
79
- # file, and it's useful to allow more verbose output when running an
80
- # individual spec file.
81
- if config.files_to_run.one?
82
- # Use the documentation formatter for detailed output,
83
- # unless a formatter has already been configured
84
- # (e.g. via a command-line flag).
85
- config.default_formatter = 'doc'
86
- end
87
-
88
- # Print the 10 slowest examples and example groups at the
89
- # end of the spec run, to help surface which specs are running
90
- # particularly slow.
91
- config.profile_examples = 10
92
-
93
- # Run specs in random order to surface order dependencies. If you find an
94
- # order dependency and want to debug it, you can fix the order by providing
95
- # the seed, which is printed after each run.
96
- # --seed 1234
97
- config.order = :random
98
-
99
- # Seed global randomization in this process using the `--seed` CLI option.
100
- # Setting this allows you to use `--seed` to deterministically reproduce
101
- # test failures related to randomization by passing the same `--seed` value
102
- # as the one that triggered the failure.
103
- Kernel.srand config.seed
104
- =end
52
+ # The settings below are suggested to provide a good initial experience
53
+ # with RSpec, but feel free to customize to your heart's content.
54
+ # # These two settings work together to allow you to limit a spec run
55
+ # # to individual examples or groups you care about by tagging them with
56
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
57
+ # # get run.
58
+ # config.filter_run :focus
59
+ # config.run_all_when_everything_filtered = true
60
+ #
61
+ # # Allows RSpec to persist some state between runs in order to support
62
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
63
+ # # you configure your source control system to ignore this file.
64
+ # config.example_status_persistence_file_path = "spec/examples.txt"
65
+ #
66
+ # # Limits the available syntax to the non-monkey patched syntax that is
67
+ # # recommended. For more details, see:
68
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
69
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
71
+ # config.disable_monkey_patching!
72
+ #
73
+ # # This setting enables warnings. It's recommended, but in some cases may
74
+ # # be too noisy due to issues in dependencies.
75
+ # config.warnings = true
76
+ #
77
+ # # Many RSpec users commonly either run the entire suite or an individual
78
+ # # file, and it's useful to allow more verbose output when running an
79
+ # # individual spec file.
80
+ # if config.files_to_run.one?
81
+ # # Use the documentation formatter for detailed output,
82
+ # # unless a formatter has already been configured
83
+ # # (e.g. via a command-line flag).
84
+ # config.default_formatter = 'doc'
85
+ # end
86
+ #
87
+ # # Print the 10 slowest examples and example groups at the
88
+ # # end of the spec run, to help surface which specs are running
89
+ # # particularly slow.
90
+ # config.profile_examples = 10
91
+ #
92
+ # # Run specs in random order to surface order dependencies. If you find an
93
+ # # order dependency and want to debug it, you can fix the order by providing
94
+ # # the seed, which is printed after each run.
95
+ # # --seed 1234
96
+ # config.order = :random
97
+ #
98
+ # # Seed global randomization in this process using the `--seed` CLI option.
99
+ # # Setting this allows you to use `--seed` to deterministically reproduce
100
+ # # test failures related to randomization by passing the same `--seed` value
101
+ # # as the one that triggered the failure.
102
+ # Kernel.srand config.seed
105
103
  end
@@ -1,52 +1,49 @@
1
1
  describe Gosquared::Tracking do
2
- subject(:gs) { described_class.new("demo", "GSN-2194840-F") }
3
-
4
- VERSION = "3.0.6"
5
-
6
- Gosquared::Tracking::DIMENSIONS.each do |dimension|
7
- before do
8
- stub_request(:post, "https://api.gosquared.com/tracking/v1/#{dimension}?api_key=demo&site_token=GSN-2194840-F").
9
- with(:body => "[{\"person_id\":\"email:test@example.com\",\"properties\":{\"email\":\"test@example.com\"}}]",
10
- :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'ruby-client/'+VERSION }).
11
- to_return(:status => 200, :body => "", :headers => {response: "success"})
12
- end
13
- end
14
-
15
- Gosquared::Tracking::DIMENSIONS.each do |dimension|
16
- it "posts a request to the GoSquared Track API with #{dimension} dimension" do
17
- gs.send "#{dimension}", ({person_id: "email:test@example.com",
18
- properties:{email: "test@example.com"}})
19
- expect(gs.post.code).to eq('200')
20
- end
21
- end
22
-
23
- describe "#event" do
24
- before do
25
- stub_request(:post, "https://api.gosquared.com/tracking/v1/event?api_key=demo&site_token=GSN-2194840-F").
26
- with(:body => "[{\"event\":{\"name\":\"event\"}}]",
27
- :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'ruby-client/'+VERSION}).
28
- to_return(:status => 200, :body => "", :headers => {})
29
- @data = {person_id: nil, event: { name: 'event' } }
30
- end
31
-
32
- it 'Tracks an anonymous event when a person_id is nil' do
33
- gs.event(@data)
34
- expect(gs.post.code).to eq('200')
35
- end
36
-
37
- before do
38
- stub_request(:post, "https://api.gosquared.com/tracking/v1/event?api_key=demo&site_token=GSN-2194840-F").
39
- with(:body => "[{\"person_id\":\"12345\",\"event\":{\"name\":\"event\"}}]",
40
- :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/json', 'User-Agent'=>'ruby-client/'+VERSION}).
41
- to_return(:status => 200, :body => "", :headers => {})
42
- @data = {person_id: '12345', event: { name: 'event' } }
43
- end
44
-
45
- it 'Tracks an anonymous event when a person_id is not nil' do
46
- gs.event(@data)
47
- expect(gs.post.code).to eq('200')
48
- end
49
-
50
- end
51
-
2
+ subject(:gs) { described_class.new('demo', 'GSN-2194840-F') }
3
+
4
+ VERSION = '3.0.7'.freeze
5
+
6
+ Gosquared::Tracking::DIMENSIONS.each do |dimension|
7
+ before do
8
+ stub_request(:post, "https://api.gosquared.com/tracking/v1/#{dimension}?api_key=demo&site_token=GSN-2194840-F")
9
+ .with(body: '[{"person_id":"email:test@example.com","properties":{"email":"test@example.com"}}]',
10
+ headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'User-Agent' => 'ruby-client/' + VERSION })
11
+ .to_return(status: 200, body: '', headers: { response: 'success' })
12
+ end
13
+ end
14
+
15
+ Gosquared::Tracking::DIMENSIONS.each do |dimension|
16
+ it "posts a request to the GoSquared Track API with #{dimension} dimension" do
17
+ gs.send dimension.to_s, person_id: 'email:test@example.com', properties: { email: 'test@example.com' }
18
+ expect(gs.post.code).to eq('200')
19
+ end
20
+ end
21
+
22
+ describe '#event' do
23
+ before do
24
+ stub_request(:post, 'https://api.gosquared.com/tracking/v1/event?api_key=demo&site_token=GSN-2194840-F')
25
+ .with(body: '[{"event":{"name":"event"}}]',
26
+ headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'User-Agent' => 'ruby-client/' + VERSION })
27
+ .to_return(status: 200, body: '', headers: {})
28
+ @data = { person_id: nil, event: { name: 'event' } }
29
+ end
30
+
31
+ it 'Tracks an anonymous event when a person_id is nil' do
32
+ gs.event(@data)
33
+ expect(gs.post.code).to eq('200')
34
+ end
35
+
36
+ before do
37
+ stub_request(:post, 'https://api.gosquared.com/tracking/v1/event?api_key=demo&site_token=GSN-2194840-F')
38
+ .with(body: '[{"person_id":"12345","event":{"name":"event"}}]',
39
+ headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'User-Agent' => 'ruby-client/' + VERSION })
40
+ .to_return(status: 200, body: '', headers: {})
41
+ @data = { person_id: '12345', event: { name: 'event' } }
42
+ end
43
+
44
+ it 'Tracks an anonymous event when a person_id is not nil' do
45
+ gs.event(@data)
46
+ expect(gs.post.code).to eq('200')
47
+ end
48
+ end
52
49
  end
@@ -1,37 +1,36 @@
1
1
  describe Gosquared::Trends do
2
- subject(:gs) { described_class.new("demo","GSN-106863-S") }
2
+ subject(:gs) { described_class.new('demo', 'GSN-106863-S') }
3
3
 
4
- Gosquared::Trends::DIMENSIONS.each do |dimension|
5
- before do
6
- data = '{"a": [{"test": "response"}]}'
7
- stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S").
8
- with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
9
- to_return(status: 200, body: data, headers: {})
10
- end
11
- end
4
+ Gosquared::Trends::DIMENSIONS.each do |dimension|
5
+ before do
6
+ data = '{"a": [{"test": "response"}]}'
7
+ stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S")
8
+ .with(headers: { 'Accept' => '*/*', 'User-Agent' => 'Ruby' })
9
+ .to_return(status: 200, body: data, headers: {})
10
+ end
11
+ end
12
12
 
13
- Gosquared::Trends::DIMENSIONS.each do |dimension|
14
- it "fetches a request from the GoSquared Trends API with #{dimension} dimension" do
15
- gs.send "#{dimension}"
16
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
17
- end
18
- end
13
+ Gosquared::Trends::DIMENSIONS.each do |dimension|
14
+ it "fetches a request from the GoSquared Trends API with #{dimension} dimension" do
15
+ gs.send dimension.to_s
16
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }])
17
+ end
18
+ end
19
19
 
20
- Gosquared::Trends::DIMENSIONS.each do |dimension|
21
- before do
22
- data = '{"a": [{"test": "response"}, {"with": "params"}]}'
23
- stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S&dateFormat=yyyy-mm-dd&format=json&from=2016-06-20&group=true&limit=5&site_token=GSN-106863-S&sort=visits&to=2016-06-30").
24
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
25
- to_return(:status => 200, :body => data, :headers => {})
26
- end
27
- end
28
-
29
- Gosquared::Trends::DIMENSIONS.each do |dimension|
30
- it "fetches a request from the GoSquared Trends API with #{dimension} dimension and paramaters" do
31
- gs.send("#{dimension}").from('2016-06-20').to('2016-06-30')
32
- .date_format('yyyy-mm-dd').sort('visits').group(true).format('json').limit(5)
33
- expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"params"}])
34
- end
35
- end
20
+ Gosquared::Trends::DIMENSIONS.each do |dimension|
21
+ before do
22
+ data = '{"a": [{"test": "response"}, {"with": "params"}]}'
23
+ stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S&dateFormat=yyyy-mm-dd&format=json&from=2016-06-20&group=true&limit=5&site_token=GSN-106863-S&sort=visits&to=2016-06-30")
24
+ .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host' => 'api.gosquared.com', 'User-Agent' => 'Ruby' })
25
+ .to_return(status: 200, body: data, headers: {})
26
+ end
27
+ end
36
28
 
29
+ Gosquared::Trends::DIMENSIONS.each do |dimension|
30
+ it "fetches a request from the GoSquared Trends API with #{dimension} dimension and paramaters" do
31
+ gs.send(dimension.to_s).from('2016-06-20').to('2016-06-30')
32
+ .date_format('yyyy-mm-dd').sort('visits').group(true).format('json').limit(5)
33
+ expect(gs.fetch).to eq('a' => [{ 'test' => 'response' }, { 'with' => 'params' }])
34
+ end
35
+ end
37
36
  end