fog 0.0.40 → 0.0.41
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/Rakefile +12 -0
- data/VERSION +1 -1
- data/bin/fog +28 -40
- data/fog.gemspec +16 -3
- data/lib/fog.rb +27 -3
- data/lib/fog/aws/ec2.rb +7 -3
- data/lib/fog/aws/models/ec2/security_group.rb +1 -1
- data/lib/fog/aws/models/ec2/server.rb +8 -3
- data/lib/fog/aws/models/ec2/servers.rb +1 -1
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +10 -10
- data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
- data/lib/fog/aws/s3.rb +6 -2
- data/lib/fog/rackspace.rb +8 -2
- data/lib/fog/slicehost.rb +3 -1
- data/spec/aws/models/ec2/address_spec.rb +8 -8
- data/spec/aws/models/ec2/addresses_spec.rb +10 -10
- data/spec/aws/models/ec2/key_pair_spec.rb +8 -8
- data/spec/aws/models/ec2/key_pairs_spec.rb +10 -10
- data/spec/aws/models/ec2/security_group_spec.rb +8 -8
- data/spec/aws/models/ec2/security_groups_spec.rb +10 -10
- data/spec/aws/models/ec2/server_spec.rb +1 -4
- data/spec/aws/models/ec2/servers_spec.rb +1 -1
- data/spec/aws/models/ec2/snapshot_spec.rb +12 -10
- data/spec/aws/models/ec2/snapshots_spec.rb +20 -20
- data/spec/aws/models/ec2/volume_spec.rb +10 -10
- data/spec/aws/models/ec2/volumes_spec.rb +10 -10
- data/spec/aws/models/s3/directories_spec.rb +8 -8
- data/spec/aws/models/s3/directory_spec.rb +11 -11
- data/spec/aws/models/s3/file_spec.rb +2 -2
- data/spec/aws/models/s3/files_spec.rb +2 -2
- data/spec/aws/requests/ec2/allocate_address_spec.rb +2 -2
- data/spec/aws/requests/ec2/associate_address_spec.rb +15 -13
- data/spec/aws/requests/ec2/attach_volume_spec.rb +12 -12
- data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +3 -3
- data/spec/aws/requests/ec2/create_key_pair_spec.rb +5 -5
- data/spec/aws/requests/ec2/create_security_group_spec.rb +5 -5
- data/spec/aws/requests/ec2/create_snapshot_spec.rb +5 -5
- data/spec/aws/requests/ec2/create_volume_spec.rb +2 -2
- data/spec/aws/requests/ec2/delete_key_pair_spec.rb +3 -3
- data/spec/aws/requests/ec2/delete_security_group_spec.rb +3 -3
- data/spec/aws/requests/ec2/delete_snapshot_spec.rb +5 -5
- data/spec/aws/requests/ec2/delete_volume_spec.rb +3 -3
- data/spec/aws/requests/ec2/describe_addresses_spec.rb +5 -5
- data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +2 -2
- data/spec/aws/requests/ec2/describe_images_spec.rb +2 -2
- data/spec/aws/requests/ec2/describe_instances_spec.rb +5 -5
- data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +5 -5
- data/spec/aws/requests/ec2/describe_regions_spec.rb +2 -2
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +5 -5
- data/spec/aws/requests/ec2/describe_snapshots_spec.rb +7 -7
- data/spec/aws/requests/ec2/describe_volumes_spec.rb +5 -5
- data/spec/aws/requests/ec2/detach_volume_spec.rb +7 -7
- data/spec/aws/requests/ec2/disassociate_address_spec.rb +9 -7
- data/spec/aws/requests/ec2/get_console_output_spec.rb +4 -4
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +4 -4
- data/spec/aws/requests/ec2/release_address_spec.rb +3 -3
- data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +4 -4
- data/spec/aws/requests/ec2/run_instances_spec.rb +2 -2
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +7 -7
- data/spec/aws/requests/s3/copy_object_spec.rb +11 -11
- data/spec/aws/requests/s3/delete_bucket_spec.rb +8 -8
- data/spec/aws/requests/s3/delete_object_spec.rb +8 -8
- data/spec/aws/requests/s3/get_bucket_location_spec.rb +4 -4
- data/spec/aws/requests/s3/get_bucket_spec.rb +12 -12
- data/spec/aws/requests/s3/get_object_spec.rb +9 -9
- data/spec/aws/requests/s3/get_request_payment_spec.rb +4 -4
- data/spec/aws/requests/s3/get_service_spec.rb +4 -4
- data/spec/aws/requests/s3/head_object_spec.rb +5 -5
- data/spec/aws/requests/s3/put_bucket_spec.rb +3 -3
- data/spec/aws/requests/s3/put_object_spec.rb +11 -11
- data/spec/aws/requests/s3/put_request_payment_spec.rb +4 -4
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +4 -4
- data/spec/aws/requests/simpledb/create_domain_spec.rb +4 -4
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +8 -8
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +3 -3
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +6 -6
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +9 -9
- data/spec/aws/requests/simpledb/list_domains_spec.rb +4 -4
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +4 -4
- data/spec/compact_progress_bar_formatter.rb +195 -0
- data/spec/rackspace/models/servers/server_spec.rb +1 -1
- data/spec/rackspace/requests/files/delete_container_spec.rb +3 -3
- data/spec/rackspace/requests/files/delete_object_spec.rb +8 -8
- data/spec/rackspace/requests/files/get_container_spec.rb +6 -6
- data/spec/rackspace/requests/files/get_containers_spec.rb +3 -3
- data/spec/rackspace/requests/files/head_container_spec.rb +6 -6
- data/spec/rackspace/requests/files/head_containers_spec.rb +3 -3
- data/spec/rackspace/requests/files/put_container_spec.rb +2 -2
- data/spec/rackspace/requests/files/put_object_spec.rb +4 -4
- data/spec/rackspace/requests/servers/create_image_spec.rb +4 -4
- data/spec/rackspace/requests/servers/create_server_spec.rb +2 -2
- data/spec/rackspace/requests/servers/delete_image_spec.rb +5 -5
- data/spec/rackspace/requests/servers/delete_server_spec.rb +3 -3
- data/spec/rackspace/requests/servers/get_flavor_details_spec.rb +1 -1
- data/spec/rackspace/requests/servers/get_server_details_spec.rb +4 -4
- data/spec/rackspace/requests/servers/list_addresses_spec.rb +4 -4
- data/spec/rackspace/requests/servers/list_flavors_detail_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_flavors_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_images_detail_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_images_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_private_addresses_spec.rb +4 -4
- data/spec/rackspace/requests/servers/list_public_addresses_spec.rb +4 -4
- data/spec/rackspace/requests/servers/list_servers_detail_spec.rb +3 -3
- data/spec/rackspace/requests/servers/list_servers_spec.rb +3 -3
- data/spec/rackspace/requests/servers/reboot_server_spec.rb +4 -4
- data/spec/rackspace/requests/servers/update_server_spec.rb +4 -4
- data/spec/slicehost/requests/create_slice_spec.rb +2 -2
- data/spec/slicehost/requests/delete_slice_spec.rb +2 -2
- data/spec/slicehost/requests/get_backups_spec.rb +1 -1
- data/spec/slicehost/requests/get_flavors_spec.rb +1 -1
- data/spec/slicehost/requests/get_images_spec.rb +1 -1
- data/spec/slicehost/requests/get_slices_spec.rb +1 -1
- data/spec/spec_helper.rb +60 -38
- metadata +16 -3
- data/spec/spec.opts +0 -1
@@ -5,15 +5,15 @@ describe 'SimpleDB.domain_metadata' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@domain_name = "fog_domain_#{Time.now.to_i}"
|
8
|
-
sdb.create_domain(@domain_name)
|
8
|
+
AWS[:sdb].create_domain(@domain_name)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
sdb.delete_domain(@domain_name)
|
12
|
+
AWS[:sdb].delete_domain(@domain_name)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should return proper attributes when there are no items' do
|
16
|
-
results = sdb.domain_metadata(@domain_name)
|
16
|
+
results = AWS[:sdb].domain_metadata(@domain_name)
|
17
17
|
results.body['AttributeNameCount'].should == 0
|
18
18
|
results.body['AttributeNamesSizeBytes'].should == 0
|
19
19
|
results.body['AttributeValueCount'].should == 0
|
@@ -26,8 +26,8 @@ describe 'SimpleDB.domain_metadata' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should return proper attributes with items' do
|
29
|
-
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
30
|
-
results = sdb.domain_metadata(@domain_name)
|
29
|
+
AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => :baz })
|
30
|
+
results = AWS[:sdb].domain_metadata(@domain_name)
|
31
31
|
results.body['AttributeNameCount'].should == 1
|
32
32
|
results.body['AttributeNamesSizeBytes'].should == 3
|
33
33
|
results.body['AttributeValueCount'].should == 1
|
@@ -44,7 +44,7 @@ describe 'SimpleDB.domain_metadata' do
|
|
44
44
|
|
45
45
|
it 'should raise a BadRequest error if the domain does not exist' do
|
46
46
|
lambda {
|
47
|
-
sdb.domain_metadata('notadomain')
|
47
|
+
AWS[:sdb].domain_metadata('notadomain')
|
48
48
|
}.should raise_error(Excon::Errors::BadRequest)
|
49
49
|
end
|
50
50
|
|
@@ -5,24 +5,24 @@ describe 'SimpleDB.get_attributes' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@domain_name = "fog_domain_#{Time.now.to_i}"
|
8
|
-
sdb.create_domain(@domain_name)
|
8
|
+
AWS[:sdb].create_domain(@domain_name)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
sdb.delete_domain(@domain_name)
|
12
|
+
AWS[:sdb].delete_domain(@domain_name)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have no attributes for foo before put_attributes' do
|
16
16
|
eventually do
|
17
|
-
actual = sdb.get_attributes(@domain_name, 'foo')
|
17
|
+
actual = AWS[:sdb].get_attributes(@domain_name, 'foo')
|
18
18
|
actual.body['Attributes'].should be_empty
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should have attributes for foo after put_attributes' do
|
23
|
-
sdb.put_attributes(@domain_name, 'foo', { :bar => :baz })
|
23
|
+
AWS[:sdb].put_attributes(@domain_name, 'foo', { :bar => :baz })
|
24
24
|
eventually do
|
25
|
-
actual = sdb.get_attributes(@domain_name, 'foo')
|
25
|
+
actual = AWS[:sdb].get_attributes(@domain_name, 'foo')
|
26
26
|
actual.body['Attributes'].should == { 'bar' => ['baz'] }
|
27
27
|
end
|
28
28
|
end
|
@@ -32,15 +32,15 @@ describe 'SimpleDB.get_attributes' do
|
|
32
32
|
|
33
33
|
it 'should raise a BadRequest error if the domain does not exist' do
|
34
34
|
lambda {
|
35
|
-
sdb.get_attributes('notadomain', 'notanattribute')
|
35
|
+
AWS[:sdb].get_attributes('notadomain', 'notanattribute')
|
36
36
|
}.should raise_error(Excon::Errors::BadRequest)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should not raise an error if the attribute does not exist' do
|
40
40
|
@domain_name = "fog_domain_#{Time.now.to_i}"
|
41
|
-
sdb.create_domain(@domain_name)
|
42
|
-
sdb.get_attributes(@domain_name, 'notanattribute')
|
43
|
-
sdb.delete_domain(@domain_name)
|
41
|
+
AWS[:sdb].create_domain(@domain_name)
|
42
|
+
AWS[:sdb].get_attributes(@domain_name, 'notanattribute')
|
43
|
+
AWS[:sdb].delete_domain(@domain_name)
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|
@@ -8,20 +8,20 @@ describe 'SimpleDB.list_domains' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
after(:each) do
|
11
|
-
sdb.delete_domain(@domain_name)
|
11
|
+
AWS[:sdb].delete_domain(@domain_name)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should return proper attributes' do
|
15
|
-
results = sdb.list_domains
|
15
|
+
results = AWS[:sdb].list_domains
|
16
16
|
results.body['BoxUsage'].should be_a(Float)
|
17
17
|
results.body['Domains'].should be_an(Array)
|
18
18
|
results.body['RequestId'].should be_a(String)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should include created domains' do
|
22
|
-
sdb.create_domain(@domain_name)
|
22
|
+
AWS[:sdb].create_domain(@domain_name)
|
23
23
|
eventually do
|
24
|
-
actual = sdb.list_domains
|
24
|
+
actual = AWS[:sdb].list_domains
|
25
25
|
actual.body['Domains'].should include(@domain_name)
|
26
26
|
end
|
27
27
|
end
|
@@ -5,15 +5,15 @@ describe 'SimpleDB.put_attributes' do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
@domain_name = "fog_domain_#{Time.now.to_i}"
|
8
|
-
sdb.create_domain(@domain_name)
|
8
|
+
AWS[:sdb].create_domain(@domain_name)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
sdb.delete_domain(@domain_name)
|
12
|
+
AWS[:sdb].delete_domain(@domain_name)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should return proper attributes from put_attributes' do
|
16
|
-
actual = sdb.put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
|
16
|
+
actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'bar' => 'baz' })
|
17
17
|
actual.body['RequestId'].should be_a(String)
|
18
18
|
actual.body['BoxUsage'].should be_a(Float)
|
19
19
|
end
|
@@ -23,7 +23,7 @@ describe 'SimpleDB.put_attributes' do
|
|
23
23
|
|
24
24
|
it 'should raise a BadRequest error if the domain does not exist' do
|
25
25
|
lambda {
|
26
|
-
sdb.put_attributes(@domain_name, 'notadomain', { 'notanattribute' => 'value' })
|
26
|
+
AWS[:sdb].put_attributes(@domain_name, 'notadomain', { 'notanattribute' => 'value' })
|
27
27
|
}.should raise_error(Excon::Errors::BadRequest)
|
28
28
|
end
|
29
29
|
|
@@ -0,0 +1,195 @@
|
|
1
|
+
# Copyright (c) 2008 Nicholas A. Evans
|
2
|
+
# http://ekenosen.net/nick/devblog/2008/12/better-progress-bar-for-rspec/
|
3
|
+
#
|
4
|
+
# With some tweaks (slow spec profiler, growl support)
|
5
|
+
# By Nick Zadrozny
|
6
|
+
# http://gist.github.com/71340
|
7
|
+
#
|
8
|
+
# Further tweaks (formatador, elapsed time instead of eta)
|
9
|
+
# By geemus (Wesley Beary)
|
10
|
+
# http://gist.github.com/266221
|
11
|
+
#
|
12
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
13
|
+
# a copy of this software and associated documentation files (the
|
14
|
+
# "Software"), to deal in the Software without restriction, including
|
15
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
16
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
17
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
18
|
+
# the following conditions:
|
19
|
+
#
|
20
|
+
# The above copyright notice and this permission notice shall be
|
21
|
+
# included in all copies or substantial portions of the Software.
|
22
|
+
#
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
25
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
27
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
28
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
29
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
|
+
|
31
|
+
require 'spec/runner/formatter/base_text_formatter'
|
32
|
+
require "rubygems"
|
33
|
+
require 'formatador'
|
34
|
+
|
35
|
+
module Spec
|
36
|
+
module Runner
|
37
|
+
module Formatter
|
38
|
+
class CompactProgressBarFormatter < BaseTextFormatter
|
39
|
+
# Threshold for slow specs, in seconds.
|
40
|
+
# Anything that takes longer than this will be printed out
|
41
|
+
# It would be great to get this down to 0.5 or less...
|
42
|
+
SLOW_SPEC_THRESHOLD = 2.0
|
43
|
+
|
44
|
+
# Keep track the slowest specs and print a report at the end
|
45
|
+
SLOW_SPEC_REPORT = 3
|
46
|
+
|
47
|
+
attr_reader :total, :current
|
48
|
+
|
49
|
+
def start(example_count)
|
50
|
+
@current = 0
|
51
|
+
@started_at = Time.now
|
52
|
+
@total = example_count
|
53
|
+
@error_state = :all_passing
|
54
|
+
@slow_specs = []
|
55
|
+
@formatador = Formatador.new
|
56
|
+
@formatador.display_line
|
57
|
+
end
|
58
|
+
|
59
|
+
def example_started(example)
|
60
|
+
super
|
61
|
+
@start_time = Time.now
|
62
|
+
end
|
63
|
+
|
64
|
+
def example_passed(example)
|
65
|
+
elapsed = Time.now - @start_time
|
66
|
+
profile_example(example_group.description, example.description, elapsed)
|
67
|
+
increment
|
68
|
+
end
|
69
|
+
|
70
|
+
# third param is optional, because earlier versions of rspec sent only two args
|
71
|
+
def example_pending(example, message, pending_caller=nil)
|
72
|
+
immediately_dump_pending(example.description, message, pending_caller)
|
73
|
+
mark_error_state_pending
|
74
|
+
increment
|
75
|
+
end
|
76
|
+
|
77
|
+
def example_failed(example, counter, failure)
|
78
|
+
immediately_dump_failure(counter, failure)
|
79
|
+
notify_failure(counter, failure)
|
80
|
+
mark_error_state_failed
|
81
|
+
increment
|
82
|
+
end
|
83
|
+
|
84
|
+
def start_dump
|
85
|
+
@formatador.display_line("\n")
|
86
|
+
report_slow_specs
|
87
|
+
end
|
88
|
+
|
89
|
+
def dump_failure(*args)
|
90
|
+
# no-op; we summarized failures as we were running
|
91
|
+
end
|
92
|
+
|
93
|
+
def method_missing(sym, *args)
|
94
|
+
# ignore
|
95
|
+
end
|
96
|
+
|
97
|
+
def notify(title, message, priority)
|
98
|
+
title = title.gsub(/\s+/, ' ').gsub(/"/,'\"').gsub(/'/, "\'")
|
99
|
+
message = message.gsub(/\s+/, ' ').gsub(/"/,'\"').gsub(/'/, "\'").gsub(/`/,'\`')
|
100
|
+
notify_command = case RUBY_PLATFORM
|
101
|
+
when /darwin/
|
102
|
+
"test -x `which growlnotify` && growlnotify -n autotest -p #{priority} -m \"#{message}\" \"#{title}\""
|
103
|
+
when /linux/
|
104
|
+
"test -x `which notify-send` && notify-send \"#{title}\" \"#{message}\""
|
105
|
+
end
|
106
|
+
# puts notify_command # use this for debugging purposes
|
107
|
+
system notify_command if notify_command
|
108
|
+
end
|
109
|
+
|
110
|
+
def notify_failure(counter, failure)
|
111
|
+
notify failure.header, failure.exception.message, 2
|
112
|
+
end
|
113
|
+
|
114
|
+
# stolen and slightly modified from BaseTextFormatter#dump_failure
|
115
|
+
def immediately_dump_failure(counter, failure)
|
116
|
+
@formatador.redisplay("#{' ' * progress_bar.length}\n")
|
117
|
+
@formatador.redisplay("[red]#{counter.to_s})[/]")
|
118
|
+
@formatador.display_line("[red]#{failure.header}[/]")
|
119
|
+
@formatador.indent do
|
120
|
+
@formatador.display_line("[red]#{failure.exception.message}[/]")
|
121
|
+
@formatador.display_line
|
122
|
+
failure.exception.backtrace.each do |line|
|
123
|
+
@formatador.display_line("[red]#{line}[/]")
|
124
|
+
end
|
125
|
+
@formatador.display_line
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# stolen and modified from BaseTextFormatter#dump_pending
|
130
|
+
def immediately_dump_pending(desc, msg, called_from)
|
131
|
+
@formatador.indent do
|
132
|
+
@formatador.redisplay("#{' ' * progress_bar.length}\r")
|
133
|
+
@formatador.display_line("[yellow]PENDING SPEC:[/] #{desc} (#{msg})\n")
|
134
|
+
end
|
135
|
+
# output.puts " Called from #{called_from}" if called_from
|
136
|
+
end
|
137
|
+
|
138
|
+
def increment
|
139
|
+
@current += 1
|
140
|
+
@formatador.redisplay(progress_bar)
|
141
|
+
end
|
142
|
+
|
143
|
+
def mark_error_state_failed
|
144
|
+
@error_state = :some_failed
|
145
|
+
end
|
146
|
+
|
147
|
+
def mark_error_state_pending
|
148
|
+
@error_state = :some_pending unless @error_state == :some_failed
|
149
|
+
end
|
150
|
+
|
151
|
+
def progress_bar
|
152
|
+
color = case @error_state
|
153
|
+
when :some_failed
|
154
|
+
'red'
|
155
|
+
when :some_pending
|
156
|
+
'yellow'
|
157
|
+
else
|
158
|
+
'green'
|
159
|
+
end
|
160
|
+
ratio = "#{(' ' * (@total.to_s.size - @current.to_s.size))}#{@current}/#{@total}"
|
161
|
+
fraction = "[#{color}]#{(' ' * (@total.to_s.size - @current.to_s.size))}#{@current}/#{@total}[/]"
|
162
|
+
percent = @current.to_f / @total.to_f
|
163
|
+
progress = "[_white_]|[/][#{color}][_#{color}_]#{'*' * (percent * 50).ceil}[/]#{' ' * (50 - (percent * 50).ceil)}[_white_]|[/]"
|
164
|
+
microseconds = Time.now - @started_at
|
165
|
+
minutes = (microseconds / 60).round.to_s
|
166
|
+
seconds = (microseconds % 60).round.to_s
|
167
|
+
elapsed = "#{minutes}:#{'0' if seconds.size < 2}#{seconds}"
|
168
|
+
[fraction, progress, elapsed, ''].join(' ')
|
169
|
+
end
|
170
|
+
|
171
|
+
def profile_example(group, example, elapsed)
|
172
|
+
@slow_specs = (@slow_specs + [[elapsed, group, example]]).sort.reverse[0, SLOW_SPEC_REPORT]
|
173
|
+
print_warning_if_really_slow(group, example, elapsed)
|
174
|
+
end
|
175
|
+
|
176
|
+
def print_warning_if_really_slow(group, example, elapsed)
|
177
|
+
if elapsed > SLOW_SPEC_THRESHOLD
|
178
|
+
@formatador.indent do
|
179
|
+
@formatador.redisplay("#{' ' * progress_bar.length}\r")
|
180
|
+
@formatador.display_line("[yellow]SLOW SPEC (#{sprintf("%.4f", elapsed)})[/]: #{group} #{example}\n")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def report_slow_specs
|
186
|
+
@formatador.display_line("[yellow]Top #{@slow_specs.size} slowest specs:[/]")
|
187
|
+
@slow_specs.each do |elapsed, group, example|
|
188
|
+
@formatador.display_line("[yellow] #{yellow(sprintf('%.4f', elapsed))} #{group} #{example}[/]")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
@@ -4,11 +4,11 @@ describe 'Rackspace::Files.delete_container' do
|
|
4
4
|
describe 'success' do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
files.put_container('container_name')
|
7
|
+
Rackspace[:files].put_container('container_name')
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should return proper attributes" do
|
11
|
-
files.delete_container('container_name')
|
11
|
+
Rackspace[:files].delete_container('container_name')
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -16,7 +16,7 @@ describe 'Rackspace::Files.delete_container' do
|
|
16
16
|
|
17
17
|
it "should raise a NotFound error if the container does not exist" do
|
18
18
|
lambda do
|
19
|
-
files.delete_container('container_name')
|
19
|
+
Rackspace[:files].delete_container('container_name')
|
20
20
|
end.should raise_error(Excon::Errors::NotFound)
|
21
21
|
end
|
22
22
|
|
@@ -4,16 +4,16 @@ describe 'Rackspace::Files.delete_object' do
|
|
4
4
|
describe 'success' do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
files.put_container('container_name')
|
8
|
-
files.put_object('container_name', 'object_name', lorem_file)
|
7
|
+
Rackspace[:files].put_container('container_name')
|
8
|
+
Rackspace[:files].put_object('container_name', 'object_name', lorem_file)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
files.delete_container('container_name')
|
12
|
+
Rackspace[:files].delete_container('container_name')
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return proper attributes" do
|
16
|
-
files.delete_object('container_name', 'object_name')
|
16
|
+
Rackspace[:files].delete_object('container_name', 'object_name')
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -21,16 +21,16 @@ describe 'Rackspace::Files.delete_object' do
|
|
21
21
|
|
22
22
|
it "should raise a NotFound error if the container does not exist" do
|
23
23
|
lambda do
|
24
|
-
files.delete_object('container_name', 'object_name')
|
24
|
+
Rackspace[:files].delete_object('container_name', 'object_name')
|
25
25
|
end.should raise_error(Excon::Errors::NotFound)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should raise a NotFound error if the object does not exist" do
|
29
|
-
files.put_container('container_name')
|
29
|
+
Rackspace[:files].put_container('container_name')
|
30
30
|
lambda do
|
31
|
-
files.delete_object('container_name', 'object_name')
|
31
|
+
Rackspace[:files].delete_object('container_name', 'object_name')
|
32
32
|
end.should raise_error(Excon::Errors::NotFound)
|
33
|
-
files.delete_container('container_name')
|
33
|
+
Rackspace[:files].delete_container('container_name')
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -4,17 +4,17 @@ describe 'Rackspace::Files.get_container' do
|
|
4
4
|
describe 'success' do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
files.put_container('container_name')
|
8
|
-
files.put_object('container_name', 'object_name', lorem_file)
|
7
|
+
Rackspace[:files].put_container('container_name')
|
8
|
+
Rackspace[:files].put_object('container_name', 'object_name', lorem_file)
|
9
9
|
end
|
10
10
|
|
11
11
|
after(:each) do
|
12
|
-
files.delete_object('container_name', 'object_name')
|
13
|
-
files.delete_container('container_name')
|
12
|
+
Rackspace[:files].delete_object('container_name', 'object_name')
|
13
|
+
Rackspace[:files].delete_container('container_name')
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return proper attributes" do
|
17
|
-
actual = files.get_container('container_name').body
|
17
|
+
actual = Rackspace[:files].get_container('container_name').body
|
18
18
|
actual.first['bytes'].should be_an(Integer)
|
19
19
|
actual.first['content_type'].should be_a(String)
|
20
20
|
actual.first['hash'].should be_a(String)
|
@@ -26,7 +26,7 @@ describe 'Rackspace::Files.get_container' do
|
|
26
26
|
describe 'failure' do
|
27
27
|
|
28
28
|
it "should not raise an if the container does not exist" do
|
29
|
-
files.get_container('container_name')
|
29
|
+
Rackspace[:files].get_container('container_name')
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
@@ -4,15 +4,15 @@ describe 'Rackspace::Files.get_containers' do
|
|
4
4
|
describe 'success' do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
files.put_container('container_name')
|
7
|
+
Rackspace[:files].put_container('container_name')
|
8
8
|
end
|
9
9
|
|
10
10
|
after(:each) do
|
11
|
-
files.delete_container('container_name')
|
11
|
+
Rackspace[:files].delete_container('container_name')
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return proper attributes" do
|
15
|
-
actual = files.get_containers.body
|
15
|
+
actual = Rackspace[:files].get_containers.body
|
16
16
|
actual.first['bytes'].should be_an(Integer)
|
17
17
|
actual.first['count'].should be_an(Integer)
|
18
18
|
actual.first['name'].should be_a(String)
|