hubspot-api-ruby 0.9.0 → 0.10.0
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 +4 -4
- data/README.md +27 -9
- data/Rakefile +0 -2
- data/hubspot-api-ruby.gemspec +1 -2
- data/lib/hubspot/config.rb +4 -0
- data/lib/hubspot/engagement.rb +0 -1
- data/lib/hubspot/file.rb +2 -2
- data/lib/hubspot/railtie.rb +0 -4
- data/lib/hubspot/utils.rb +0 -30
- data/spec/lib/hubspot/blog_spec.rb +2 -7
- data/spec/lib/hubspot/config_spec.rb +24 -14
- data/spec/lib/hubspot/connection_spec.rb +44 -55
- data/spec/lib/hubspot/contact_list_spec.rb +21 -33
- data/spec/lib/hubspot/contact_spec.rb +1 -1
- data/spec/lib/hubspot/custom_event_spec.rb +5 -4
- data/spec/lib/hubspot/engagement_spec.rb +3 -11
- data/spec/lib/hubspot/event_spec.rb +3 -2
- data/spec/lib/hubspot/file_spec.rb +20 -9
- data/spec/lib/hubspot/form_spec.rb +8 -11
- data/spec/lib/hubspot/meeting_spec.rb +7 -1
- data/spec/lib/hubspot/owner_spec.rb +2 -3
- data/spec/lib/hubspot/utils_spec.rb +6 -39
- data/spec/lib/hubspot-ruby_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/vcr.rb +1 -0
- metadata +5 -9
- data/lib/tasks/hubspot.rake +0 -53
- data/spec/lib/tasks/hubspot_spec.rb +0 -119
- data/spec/support/capture_output.rb +0 -21
- data/spec/support/rake.rb +0 -46
@@ -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
|