hubspot-api-ruby 0.8.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -154
  3. data/Rakefile +0 -2
  4. data/hubspot-api-ruby.gemspec +5 -7
  5. data/lib/hubspot/association.rb +106 -0
  6. data/lib/hubspot/company.rb +2 -13
  7. data/lib/hubspot/config.rb +14 -9
  8. data/lib/hubspot/connection.rb +20 -14
  9. data/lib/hubspot/contact.rb +5 -1
  10. data/lib/hubspot/contact_list.rb +0 -7
  11. data/lib/hubspot/custom_event.rb +25 -0
  12. data/lib/hubspot/deal.rb +53 -32
  13. data/lib/hubspot/engagement.rb +0 -1
  14. data/lib/hubspot/exceptions.rb +2 -0
  15. data/lib/hubspot/file.rb +2 -2
  16. data/lib/hubspot/meeting.rb +44 -0
  17. data/lib/hubspot/properties.rb +1 -1
  18. data/lib/hubspot/railtie.rb +0 -4
  19. data/lib/hubspot/resource.rb +4 -4
  20. data/lib/hubspot/utils.rb +0 -30
  21. data/lib/hubspot-api-ruby.rb +3 -0
  22. data/spec/lib/hubspot/association_spec.rb +165 -0
  23. data/spec/lib/hubspot/blog_spec.rb +10 -21
  24. data/spec/lib/hubspot/company_properties_spec.rb +8 -11
  25. data/spec/lib/hubspot/company_spec.rb +18 -36
  26. data/spec/lib/hubspot/config_spec.rb +24 -14
  27. data/spec/lib/hubspot/connection_spec.rb +44 -55
  28. data/spec/lib/hubspot/contact_list_spec.rb +82 -71
  29. data/spec/lib/hubspot/contact_properties_spec.rb +5 -34
  30. data/spec/lib/hubspot/contact_spec.rb +2 -4
  31. data/spec/lib/hubspot/custom_event_spec.rb +28 -0
  32. data/spec/lib/hubspot/deal_pipeline_spec.rb +4 -15
  33. data/spec/lib/hubspot/deal_properties_spec.rb +11 -58
  34. data/spec/lib/hubspot/deal_spec.rb +46 -47
  35. data/spec/lib/hubspot/engagement_spec.rb +21 -40
  36. data/spec/lib/hubspot/event_spec.rb +3 -2
  37. data/spec/lib/hubspot/file_spec.rb +16 -30
  38. data/spec/lib/hubspot/form_spec.rb +34 -34
  39. data/spec/lib/hubspot/meeting_spec.rb +81 -0
  40. data/spec/lib/hubspot/owner_spec.rb +2 -3
  41. data/spec/lib/hubspot/resource_spec.rb +41 -1
  42. data/spec/lib/hubspot/utils_spec.rb +6 -39
  43. data/spec/lib/hubspot-ruby_spec.rb +1 -1
  44. data/spec/spec_helper.rb +13 -4
  45. data/spec/support/vcr.rb +4 -6
  46. metadata +11 -27
  47. data/lib/tasks/hubspot.rake +0 -53
  48. data/spec/lib/hubspot/topic_spec.rb +0 -23
  49. data/spec/lib/tasks/hubspot_spec.rb +0 -119
  50. data/spec/support/capture_output.rb +0 -21
  51. data/spec/support/rake.rb +0 -46
  52. data/spec/support/tests_helper.rb +0 -17
@@ -1,4 +1,6 @@
1
1
  describe Hubspot::Utils do
2
+ API_HEADERS = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" }.freeze
3
+
2
4
  describe ".properties_to_hash" do
3
5
  let(:properties) do
4
6
  {
@@ -32,13 +34,13 @@ describe Hubspot::Utils do
32
34
  describe '.compare_property_lists for ContactProperties' do
33
35
  let(:example_groups) do
34
36
  VCR.use_cassette('contact_properties/groups_example') do
35
- HTTParty.get('https://api.hubapi.com/contacts/v2/groups?hapikey=demo').parsed_response
37
+ HTTParty.get('https://api.hubapi.com/contacts/v2/groups', headers: API_HEADERS).parsed_response
36
38
  end
37
39
  end
38
40
 
39
41
  let(:example_properties) do
40
42
  VCR.use_cassette('contact_properties/properties_example') do
41
- HTTParty.get('https://api.hubapi.com/contacts/v2/properties?hapikey=demo').parsed_response
43
+ HTTParty.get('https://api.hubapi.com/contacts/v2/properties', headers: API_HEADERS).parsed_response
42
44
  end
43
45
  end
44
46
 
@@ -81,13 +83,13 @@ describe Hubspot::Utils do
81
83
  describe '.compare_property_lists for DealProperties' do
82
84
  let(:example_groups) do
83
85
  VCR.use_cassette('deal_groups_example') do
84
- HTTParty.get('https://api.hubapi.com/deals/v1/groups?hapikey=demo').parsed_response
86
+ HTTParty.get('https://api.hubapi.com/deals/v1/groups', headers: API_HEADERS).parsed_response
85
87
  end
86
88
  end
87
89
 
88
90
  let(:example_properties) do
89
91
  VCR.use_cassette('deal_properties_example') do
90
- HTTParty.get('https://api.hubapi.com/deals/v1/properties?hapikey=demo').parsed_response
92
+ HTTParty.get('https://api.hubapi.com/deals/v1/properties', headers: API_HEADERS).parsed_response
91
93
  end
92
94
  end
93
95
 
@@ -126,39 +128,4 @@ describe Hubspot::Utils do
126
128
  end
127
129
  end
128
130
  end
129
-
130
- describe ".dump_properties" do
131
- it "prints a deprecation warning" do
132
- VCR.use_cassette("dump_deal_properties_and_groups") do
133
- api_key = "demo"
134
-
135
- output = capture_stderr do
136
- Hubspot::Utils.dump_properties(Hubspot::DealProperties, api_key)
137
- end
138
-
139
- expected_warning = "Hubspot::Utils.dump_properties is deprecated"
140
- expect(output).to include(expected_warning)
141
- end
142
- end
143
- end
144
-
145
- describe ".restore_properties" do
146
- it "prints a deprecation warning" do
147
- VCR.use_cassette("restore_deal_properties_and_groups") do
148
- api_key = "demo"
149
- properties = {"groups" => {}, "properties" => {}}
150
-
151
- output = capture_stderr do
152
- Hubspot::Utils.restore_properties(
153
- Hubspot::DealProperties,
154
- api_key,
155
- properties
156
- )
157
- end
158
-
159
- expected_warning = "Hubspot::Utils.restore_properties is deprecated"
160
- expect(output).to include(expected_warning)
161
- end
162
- end
163
- end
164
131
  end
@@ -1,7 +1,7 @@
1
1
  RSpec.describe Hubspot do
2
2
  describe ".configure" do
3
3
  it "delegates .configure to Hubspot::Config.configure" do
4
- options = { hapikey: "demo" }
4
+ options = { access_token: "demo" }
5
5
  allow(Hubspot::Config).to receive(:configure).with(options)
6
6
 
7
7
  Hubspot.configure(options)
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ SimpleCov.start do
10
10
  add_filter "/.bundle/"
11
11
  end
12
12
 
13
- require 'dotenv/load'
13
+ require 'dotenv'
14
14
  require 'rspec'
15
15
  require 'rspec/its'
16
16
  require 'webmock/rspec'
@@ -19,6 +19,8 @@ require 'faker'
19
19
  require 'byebug'
20
20
  require 'hubspot-api-ruby'
21
21
 
22
+ Dotenv.load('.env.test')
23
+
22
24
  # Requires supporting files with custom matchers and macros, etc,
23
25
  # in ./support/ and its subdirectories.
24
26
  Dir["#{RSPEC_ROOT}/support/**/*.rb"].each {|f| require f}
@@ -27,10 +29,18 @@ Dir["#{RSPEC_ROOT}/support/**/*.rb"].each {|f| require f}
27
29
  Dir["#{RSPEC_ROOT}/shared_examples/**/*.rb"].each {|f| require f}
28
30
 
29
31
  RSpec.configure do |config|
30
- config.after(:each) do
31
- Hubspot::Config.reset!
32
+ config.before(:all) do
33
+ Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"))
34
+ end
35
+
36
+ config.before(:each) do
37
+ Hubspot.configure(access_token: ENV.fetch("HUBSPOT_ACCESS_TOKEN"))
32
38
  end
33
39
 
40
+ # config.after(:each) do
41
+ # Hubspot::Config.reset!
42
+ # end
43
+
34
44
  config.filter_run_when_matching :focus
35
45
 
36
46
  # Setup FactoryBot
@@ -40,5 +50,4 @@ RSpec.configure do |config|
40
50
  end
41
51
 
42
52
  config.extend CassetteHelper
43
- config.extend TestsHelper
44
53
  end
data/spec/support/vcr.rb CHANGED
@@ -1,16 +1,14 @@
1
1
  require "vcr"
2
2
 
3
3
  def vcr_record_mode
4
- if ENV["VCR_RECORD"] == "1"
5
- :new_episodes
6
- else
7
- :none
8
- end
4
+ ENV["VCR_RECORD_MODE"]&.to_sym || :none
9
5
  end
10
6
 
11
7
  VCR.configure do |c|
12
8
  c.cassette_library_dir = "#{RSPEC_ROOT}/fixtures/vcr_cassettes"
13
9
  c.hook_into :webmock
14
10
  c.default_cassette_options = { record: vcr_record_mode }
15
- c.filter_sensitive_data("<HAPI_KEY>") { ENV.fetch("HUBSPOT_HAPI_KEY", "demo") }
11
+ c.filter_sensitive_data("<HAPI_KEY>") { ENV.fetch("HUBSPOT_HAPI_KEY") }
12
+ c.filter_sensitive_data("<PORTAL_ID>") { ENV.fetch("HUBSPOT_PORTAL_ID") }
13
+ c.filter_sensitive_data("<ACCESS_TOKEN>") { ENV.fetch("HUBSPOT_ACCESS_TOKEN") }
16
14
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubspot-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan
8
- - Juliette
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2019-12-11 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -39,20 +38,6 @@ dependencies:
39
38
  - - ">="
40
39
  - !ruby/object:Gem::Version
41
40
  version: '0.10'
42
- - !ruby/object:Gem::Dependency
43
- name: appraisal
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '2.2'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '2.2'
56
41
  - !ruby/object:Gem::Dependency
57
42
  name: dotenv
58
43
  requirement: !ruby/object:Gem::Requirement
@@ -266,7 +251,6 @@ dependencies:
266
251
  description: hubspot-api-ruby is a wrapper for the HubSpot REST API
267
252
  email:
268
253
  - jonathan@hoggo.com
269
- - juliette@hoggo.com
270
254
  executables: []
271
255
  extensions: []
272
256
  extra_rdoc_files: []
@@ -280,6 +264,7 @@ files:
280
264
  - Rakefile
281
265
  - hubspot-api-ruby.gemspec
282
266
  - lib/hubspot-api-ruby.rb
267
+ - lib/hubspot/association.rb
283
268
  - lib/hubspot/blog.rb
284
269
  - lib/hubspot/collection.rb
285
270
  - lib/hubspot/company.rb
@@ -289,6 +274,7 @@ files:
289
274
  - lib/hubspot/contact.rb
290
275
  - lib/hubspot/contact_list.rb
291
276
  - lib/hubspot/contact_properties.rb
277
+ - lib/hubspot/custom_event.rb
292
278
  - lib/hubspot/deal.rb
293
279
  - lib/hubspot/deal_pipeline.rb
294
280
  - lib/hubspot/deal_properties.rb
@@ -298,6 +284,7 @@ files:
298
284
  - lib/hubspot/exceptions.rb
299
285
  - lib/hubspot/file.rb
300
286
  - lib/hubspot/form.rb
287
+ - lib/hubspot/meeting.rb
301
288
  - lib/hubspot/oauth.rb
302
289
  - lib/hubspot/owner.rb
303
290
  - lib/hubspot/paged_collection.rb
@@ -307,10 +294,10 @@ files:
307
294
  - lib/hubspot/subscription.rb
308
295
  - lib/hubspot/topic.rb
309
296
  - lib/hubspot/utils.rb
310
- - lib/tasks/hubspot.rake
311
297
  - spec/factories/companies.rb
312
298
  - spec/factories/contacts.rb
313
299
  - spec/lib/hubspot-ruby_spec.rb
300
+ - spec/lib/hubspot/association_spec.rb
314
301
  - spec/lib/hubspot/blog_spec.rb
315
302
  - spec/lib/hubspot/company_properties_spec.rb
316
303
  - spec/lib/hubspot/company_spec.rb
@@ -319,6 +306,7 @@ files:
319
306
  - spec/lib/hubspot/contact_list_spec.rb
320
307
  - spec/lib/hubspot/contact_properties_spec.rb
321
308
  - spec/lib/hubspot/contact_spec.rb
309
+ - spec/lib/hubspot/custom_event_spec.rb
322
310
  - spec/lib/hubspot/deal_pipeline_spec.rb
323
311
  - spec/lib/hubspot/deal_properties_spec.rb
324
312
  - spec/lib/hubspot/deal_spec.rb
@@ -327,26 +315,22 @@ files:
327
315
  - spec/lib/hubspot/event_spec.rb
328
316
  - spec/lib/hubspot/file_spec.rb
329
317
  - spec/lib/hubspot/form_spec.rb
318
+ - spec/lib/hubspot/meeting_spec.rb
330
319
  - spec/lib/hubspot/owner_spec.rb
331
320
  - spec/lib/hubspot/properties_spec.rb
332
321
  - spec/lib/hubspot/resource_spec.rb
333
- - spec/lib/hubspot/topic_spec.rb
334
322
  - spec/lib/hubspot/utils_spec.rb
335
- - spec/lib/tasks/hubspot_spec.rb
336
323
  - spec/shared_examples/saveable_resource.rb
337
324
  - spec/shared_examples/updateable_resource.rb
338
325
  - spec/spec_helper.rb
339
- - spec/support/capture_output.rb
340
326
  - spec/support/cassette_helper.rb
341
327
  - spec/support/hubspot_api_helpers.rb
342
- - spec/support/rake.rb
343
- - spec/support/tests_helper.rb
344
328
  - spec/support/vcr.rb
345
- homepage: http://github.com/lounna-sas/hubspot-api-ruby
329
+ homepage: https://github.com/captaincontrat/hubspot-api-ruby
346
330
  licenses:
347
331
  - MIT
348
332
  metadata:
349
- changelog_uri: https://github.com/lounna-sas/hubspot-api-ruby/blob/master/History.md
333
+ changelog_uri: https://github.com/captaincontrat/hubspot-api-ruby/blob/master/History.md
350
334
  post_install_message:
351
335
  rdoc_options: []
352
336
  require_paths:
@@ -362,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
346
  - !ruby/object:Gem::Version
363
347
  version: '0'
364
348
  requirements: []
365
- rubygems_version: 3.0.1
349
+ rubygems_version: 3.2.32
366
350
  signing_key:
367
351
  specification_version: 4
368
352
  summary: hubspot-api-ruby is a wrapper for the HubSpot REST API
@@ -1,53 +0,0 @@
1
- require 'hubspot-api-ruby'
2
-
3
- namespace :hubspot do
4
- desc 'Dump properties to file'
5
- task :dump_properties, [:kind, :file, :hapikey, :include, :exclude] do |_, args|
6
- Hubspot::Deprecator.build.deprecation_warning("hubspot:dump_properties")
7
-
8
- hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
9
- kind = args[:kind]
10
- unless %w(contact deal).include?(kind)
11
- raise ArgumentError, ':kind must be either "contact" or "deal"'
12
- end
13
- klass = kind == 'contact' ? Hubspot::ContactProperties : Hubspot::DealProperties
14
- props = Hubspot::Utils::dump_properties(klass, hapikey, build_filter(args))
15
- if args[:file].blank?
16
- puts JSON.pretty_generate(props)
17
- else
18
- File.open(args[:file], 'w') do |f|
19
- f.write(JSON.pretty_generate(props))
20
- end
21
- end
22
- end
23
-
24
- desc 'Restore properties from file'
25
- task :restore_properties, [:kind, :file, :hapikey, :dry_run] do |_, args|
26
- Hubspot::Deprecator.build.deprecation_warning("hubspot:restore_properties")
27
-
28
- hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
29
- if args[:file].blank?
30
- raise ArgumentError, ':file is a required parameter'
31
- end
32
- kind = args[:kind]
33
- unless %w(contact deal).include?(kind)
34
- raise ArgumentError, ':kind must be either "contact" or "deal"'
35
- end
36
- klass = kind == 'contact' ? Hubspot::ContactProperties : Hubspot::DealProperties
37
- file = File.read(args[:file])
38
- props = JSON.parse(file)
39
- Hubspot::Utils.restore_properties(klass, hapikey, props, args[:dry_run] != 'false')
40
- end
41
-
42
- private
43
-
44
- def build_filter(args)
45
- { include: val_to_array(args[:include]),
46
- exclude: val_to_array(args[:exclude])
47
- }
48
- end
49
-
50
- def val_to_array(val)
51
- val.blank? ? val : val.split(/\W+/)
52
- end
53
- end
@@ -1,23 +0,0 @@
1
- describe Hubspot::Topic do
2
- before do
3
- Hubspot.configure(hapikey: "demo")
4
- end
5
-
6
- describe ".list" do
7
- cassette "topics_list"
8
- let(:topics) { Hubspot::Topic.list }
9
-
10
- it "should have a list of topics" do
11
- topics.count.should be(3)
12
- end
13
- end
14
-
15
- describe ".find_by_topic_id" do
16
- cassette "topics_list"
17
-
18
- it "should find a specific topic" do
19
- topic = Hubspot::Topic.find_by_topic_id(349001328)
20
- topic['id'].should eq(349001328)
21
- end
22
- end
23
- end
@@ -1,119 +0,0 @@
1
- require "rake"
2
- require "stringio"
3
- require "tempfile"
4
-
5
- RSpec.describe "hubspot rake tasks", type: :rake do
6
- let(:hapikey) { "demo" }
7
-
8
- describe "hubspot:dump_properties" do
9
- it "writes the class properties and groups to the given file" do
10
- VCR.use_cassette("dump_contact_properties_and_groups") do
11
- file = Tempfile.new
12
-
13
- invoke_rake_task("hubspot:dump_properties", ["contact", file, hapikey])
14
-
15
- result = JSON.parse(File.read(file))
16
-
17
- expect(result.count).to be > 0
18
- expect(result['groups'].count).to be > 0
19
- expect(result['properties'].count).to be > 0
20
- end
21
- end
22
-
23
- it "prints a deprecation warning" do
24
- VCR.use_cassette("dump_contact_properties_and_groups") do
25
- file = Tempfile.new ""
26
-
27
- output = capture_stderr do
28
- invoke_rake_task("hubspot:dump_properties", ["contact", file, hapikey])
29
- end
30
-
31
- expect(output).to include("hubspot:dump_properties is deprecated")
32
- end
33
- end
34
-
35
- context "given an unknown class" do
36
- it "raises an error" do
37
- file = Tempfile.new
38
-
39
- expected_error_msg = ':kind must be either "contact" or "deal"'
40
-
41
- expect do
42
- invoke_rake_task(
43
- "hubspot:dump_properties",
44
- ["unknown_class", file, hapikey]
45
- )
46
- end.to raise_error(ArgumentError, expected_error_msg)
47
- end
48
- end
49
- end
50
-
51
- describe "hubspot:restore_properties" do
52
- context "when the class properties match the existing properties" do
53
- it "should not need to make any changes" do
54
- VCR.use_cassette("restore_contact_properties_and_groups") do
55
- file = build_file_with_matching_properties("contact")
56
-
57
- results = capture_stdout do
58
- invoke_rake_task(
59
- "hubspot:restore_properties",
60
- ["contact", file, hapikey]
61
- )
62
- end
63
-
64
- expect(results).not_to include("Created: ")
65
- expect(results).not_to include("Updated: ")
66
- end
67
- end
68
- end
69
-
70
- it "prints a deprecation warning" do
71
- VCR.use_cassette("restore_contact_properties_and_groups") do
72
- file = build_file_with_matching_properties("contact")
73
-
74
- output = capture_stderr do
75
- invoke_rake_task(
76
- "hubspot:restore_properties",
77
- ["contact", file, hapikey]
78
- )
79
- end
80
-
81
- expect(output).to include("hubspot:restore_properties is deprecated")
82
- end
83
- end
84
-
85
- context "when a file is not provided" do
86
- it "raises an error" do
87
- missing_file = ""
88
- expected_error_msg = ":file is a required parameter"
89
-
90
- expect do
91
- invoke_rake_task(
92
- "hubspot:restore_properties",
93
- ["contact", missing_file, hapikey]
94
- )
95
- end.to raise_error(ArgumentError, expected_error_msg)
96
- end
97
- end
98
-
99
- context "given an unknown class" do
100
- it "raises an error" do
101
- file = Tempfile.new
102
- expected_error_msg = ':kind must be either "contact" or "deal"'
103
-
104
- expect do
105
- invoke_rake_task(
106
- "hubspot:restore_properties",
107
- ["unknown_class", file, hapikey]
108
- )
109
- end.to raise_error(ArgumentError, expected_error_msg)
110
- end
111
- end
112
- end
113
-
114
- def build_file_with_matching_properties(klass)
115
- file = Tempfile.new
116
- invoke_rake_task("hubspot:dump_properties", ["contact", file, hapikey])
117
- file
118
- end
119
- end
@@ -1,21 +0,0 @@
1
- module CaptureOutput
2
- def capture_stderr
3
- previous, $stderr = $stderr, StringIO.new
4
- yield
5
- $stderr.string
6
- ensure
7
- $stderr = previous
8
- end
9
-
10
- def capture_stdout
11
- previous, $stdout = $stdout, StringIO.new
12
- yield
13
- $stdout.string
14
- ensure
15
- $stdout = previous
16
- end
17
- end
18
-
19
- RSpec.configure do |config|
20
- config.include CaptureOutput
21
- end
data/spec/support/rake.rb DELETED
@@ -1,46 +0,0 @@
1
- require "rake"
2
-
3
- module RakeHelpers
4
- def invoke_rake_task(name, args = [])
5
- RakeTask.new(name).invoke(*args)
6
- end
7
- end
8
-
9
- class RakeTask
10
- def initialize(name)
11
- @task_name = name
12
- prep_environment
13
- end
14
-
15
- delegate :invoke, to: :task
16
-
17
- private
18
-
19
- attr_reader :task_name
20
-
21
- def prep_environment
22
- Rake.application = rake
23
- Rake.load_rakefile(full_task_path)
24
- Rake::Task.define_task(:environment)
25
- end
26
-
27
- def full_task_path
28
- "#{root_path}/lib/tasks/#{task_name.split(':').first}.rake"
29
- end
30
-
31
- def root_path
32
- File.expand_path('../..', __dir__)
33
- end
34
-
35
- def task
36
- rake[task_name]
37
- end
38
-
39
- def rake
40
- @_rake ||= Rake::Application.new
41
- end
42
- end
43
-
44
- RSpec.configure do |config|
45
- config.include RakeHelpers, type: :rake
46
- end
@@ -1,17 +0,0 @@
1
- module TestsHelper
2
- def expect_count_and_offset(&block)
3
- it 'returns only the number of objects specified by count' do
4
- result = block.call(count: 2)
5
- expect(result.size).to eql 2
6
-
7
- result = block.call(count: 4)
8
- expect(result.size).to eql 4
9
- end
10
-
11
- it 'returns objects by a specified offset' do
12
- non_offset_objects = block.call(count: 2)
13
- objects_with_offset = block.call(count: 2, offset: 2)
14
- expect(non_offset_objects).to_not eql objects_with_offset
15
- end
16
- end
17
- end