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.
32
33
34
|
# File 'lib/facebook_ads/test/base.rb', line 32
def cleanup_queue
@cleanup_queue
end
|
#config ⇒ Object
Returns the value of attribute config.
32
33
34
|
# File 'lib/facebook_ads/test/base.rb', line 32
def config
@config
end
|
Instance Method Details
#after_teardown ⇒ Object
65
66
67
68
|
# File 'lib/facebook_ads/test/base.rb', line 65
def after_teardown
FacebookAds::Test.failures.concat(self.failures)
end
|
#before_setup ⇒ Object
36
37
38
|
# File 'lib/facebook_ads/test/base.rb', line 36
def before_setup
load_config!
end
|
#generate(type, *args) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/facebook_ads/test/base.rb', line 40
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
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/facebook_ads/test/base.rb', line 53
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
|