Class: FacebookAds::Test::Base
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- FacebookAds::Test::Base
show all
- Includes:
- Fixtures
- Defined in:
- lib/facebook_ads/test/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Fixtures
#ad_account, #create_ad, #create_ad_set, #create_adlabel, #create_campaign, #create_creative, #create_image, #randomize
Instance Attribute Details
#cleanup_queue ⇒ Object
Returns the value of attribute cleanup_queue.
20
21
22
|
# File 'lib/facebook_ads/test/base.rb', line 20
def cleanup_queue
@cleanup_queue
end
|
#config ⇒ Object
Returns the value of attribute config.
20
21
22
|
# File 'lib/facebook_ads/test/base.rb', line 20
def config
@config
end
|
Instance Method Details
#after_teardown ⇒ Object
53
54
55
56
|
# File 'lib/facebook_ads/test/base.rb', line 53
def after_teardown
FacebookAds::Test.failures.concat(self.failures)
end
|
#before_setup ⇒ Object
24
25
26
|
# File 'lib/facebook_ads/test/base.rb', line 24
def before_setup
load_config!
end
|
#generate(type, *args) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/facebook_ads/test/base.rb', line 28
def generate(type, *args)
method = "create_#{type}".to_sym
if respond_to?(method)
send(method, *args) do |generated_obj|
cleanup_later(generated_obj)
end.tap do |obj|
cleanup_later(obj)
end
else
raise TestRuntimeError, "#{type} is not a supported generator"
end
end
|
#teardown ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/facebook_ads/test/base.rb', line 41
def teardown
return unless cleanup_queue
cleanup_queue.reverse.each do |obj_or_id|
if obj_or_id.is_a?(FacebookAds::AdObject)
obj_or_id.destroy
elsif obj_or_id.is_a?(String) || obj_or_id.is_a?(Numeric)
FacebookAds::AdObject.get(obj_or_id).destroy
end
end
end
|