Skip to content

Commit 48e7438

Browse files
authored
Merge pull request #573 from zendesk/fvilela/spec_tests
[RED-2215] Fix/Improve Live Specs
2 parents 951ccdc + 26f5277 commit 48e7438

File tree

12 files changed

+44
-55
lines changed

12 files changed

+44
-55
lines changed

spec/core/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def stub_json_request(verb, path_matcher, body = json, options = {})
156156
c.default_cassette_options = { :record => :new_episodes, :decode_compressed_response => true, :serialize_with => :json, :preserve_exact_body_bytes => true }
157157
c.hook_into :webmock
158158
c.configure_rspec_metadata!
159+
160+
# In CI this doesn't matter, since we start by deleting all the cassettes.
161+
# In development, this helps debugging.
162+
c.allow_http_connections_when_no_cassette = true
159163
end
160164

161165
include WebMock::API

spec/fixtures/zendesk.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def find_or_create_user(role)
3030

3131
def topic
3232
VCR.use_cassette('valid_topic') do
33+
@topic ||= client.topics.fetch.find { |t| t.name == "Test Topic" }
3334
@topic ||= client.topics.create(
3435
:name => "Test Topic",
3536
:description => "This is the body of a topic."

spec/live/automation_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe ZendeskAPI::Automation, :delete_after do
44
def valid_attributes
55
{
6-
:title => "my test automation",
6+
:title => "my test automation_ruby_sdk_test",
77
:conditions => {
88
:all => [{ :field => "status", :operator => "is", :value => "open" }]
99
},

spec/live/brand_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
describe ZendeskAPI::Brand, :delete_after do
44
def valid_attributes
5-
{ :name => "awesomesauce", :subdomain => "zendeskapi#{SecureRandom.hex(3)}" }
5+
{ :name => "awesomesauce_ruby_sdk_test", :subdomain => "zendeskapi#{SecureRandom.hex(3)}" }
66
end
77

88
it_should_be_creatable
9-
it_should_be_updatable :name
9+
it_should_be_updatable :name, "awesomesauce_ruby_sdk_updated_name"
1010
it_should_be_readable :brands
1111

1212
# Deleted brands are still findable by id, but in the index action

spec/live/custom_status_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def valid_attributes
1414
end
1515

1616
it_should_be_creatable
17-
it_should_be_updatable :agent_label, 'New Agent Label'
17+
it_should_be_updatable :agent_label, "ruby_sdk_test_agent_label_updated"
1818
it_should_be_updatable :end_user_label, 'New End User Label'
1919
it_should_be_updatable :description, 'New Description'
2020
it_should_be_updatable :end_user_description, 'New End User Description'

spec/live/dynamic_content/item_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
describe ZendeskAPI::DynamicContent::Item, :delete_after do
44
def valid_attributes
55
{
6-
:name => "Snowboard Problem",
6+
:name => "Dynamic Content Item name Ruby SDK test",
77
:default_locale_id => 1,
8-
:content => "Snowboard Problem variant"
8+
:content => "Ruby SDK test content"
99
}
1010
end
1111

1212
it_should_be_readable :dynamic_content, :items, :create => true
1313
it_should_be_creatable
14-
it_should_be_updatable :name
14+
it_should_be_updatable :name, 'Updated Dynamic Content Item name Ruby SDK test'
1515
it_should_be_deletable
1616
end

spec/live/dynamic_content/variant_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def valid_attributes
66
:locale_id => 2,
77
:active => true,
88
:default => false,
9-
:content => 'Mon dieu!'
9+
:content => 'Ruby SDK Test Variant Content'
1010
}
1111
end
1212

spec/live/identity_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe ZendeskAPI::User::Identity, :delete_after do
44
def valid_attributes
5-
{ :type => "email", :value => "abcdef@example.com" }
5+
{ :type => "email", :value => "ruby_sdk_test@example.com" }
66
end
77

88
under current_user do

spec/live/organization_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
describe ZendeskAPI::Organization, :delete_after do
44
def valid_attributes
5-
{ :name => "Awesome-O" }
5+
{ :name => 'organization_name_ruby_sdk_test' }
66
end
77

88
it_should_be_creatable
9-
it_should_be_updatable :name
9+
it_should_be_updatable :name, 'organization_name_ruby_sdk_test_updated'
1010
it_should_be_deletable
1111
it_should_be_readable :organizations, :create => true
1212

spec/live/topic_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
require 'core/spec_helper'
22

33
RSpec.describe ZendeskAPI::Topic do
4-
# Cleanup topics (:delete_after doesn't work here)
5-
before :all do
6-
VCR.configure do |c|
7-
@previous_allow_http_connections = c.allow_http_connections_when_no_cassette?
8-
c.allow_http_connections_when_no_cassette = true
9-
end
10-
client.topics.fetch!.reject { |t| t == @topic }.map(&:destroy!)
11-
ensure
12-
VCR.configure do |c|
13-
c.allow_http_connections_when_no_cassette = @previous_allow_http_connections
14-
end
15-
end
16-
174
def valid_attributes
185
{
196
:name => "My Topic",

0 commit comments

Comments
 (0)