nephophobia 0.0.9 → 0.1.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.
- data/lib/nephophobia.rb +1 -0
- data/lib/nephophobia/client.rb +8 -0
- data/lib/nephophobia/compute.rb +11 -15
- data/lib/nephophobia/credential.rb +80 -0
- data/lib/nephophobia/image.rb +6 -7
- data/lib/nephophobia/project.rb +3 -3
- data/lib/nephophobia/user.rb +0 -17
- data/lib/nephophobia/version.rb +1 -1
- data/test/cassettes/compute_all.yml +58 -4
- data/test/cassettes/compute_all_with_filter.yml +57 -3
- data/test/cassettes/compute_create.yml +31 -4
- data/test/cassettes/compute_create_with_optional_params.yml +31 -4
- data/test/cassettes/compute_destroy.yml +59 -3
- data/test/cassettes/compute_find.yml +81 -0
- data/test/cassettes/compute_reboot.yml +57 -3
- data/test/cassettes/credential_all.yml +98 -0
- data/test/cassettes/credential_all_without_keys.yml +28 -0
- data/test/cassettes/credential_create.yml +71 -0
- data/test/cassettes/credential_destroy.yml +71 -0
- data/test/cassettes/image_all.yml +4 -4
- data/test/cassettes/image_all_with_filter.yml +27 -0
- data/test/cassettes/image_find.yml +31 -4
- data/test/cassettes/project_add_member.yml +84 -3
- data/test/cassettes/project_all.yml +4 -114
- data/test/cassettes/project_all_with_user_name.yml +190 -0
- data/test/cassettes/project_create.yml +85 -4
- data/test/cassettes/project_destroy.yml +84 -3
- data/test/cassettes/project_find.yml +4 -4
- data/test/cassettes/project_find_with_invalid_project_name.yml +3 -3
- data/test/cassettes/project_member.yml +136 -0
- data/test/cassettes/project_members.yml +58 -4
- data/test/cassettes/project_members_with_invalid_project_name.yml +3 -3
- data/test/cassettes/project_remove_member.yml +84 -3
- data/test/cassettes/role_all.yml +112 -4
- data/test/cassettes/role_all_with_project_name.yml +111 -3
- data/test/cassettes/role_all_without_roles.yml +109 -0
- data/test/cassettes/role_create.yml +84 -3
- data/test/cassettes/role_create_with_project_name.yml +84 -3
- data/test/cassettes/role_create_with_project_name_and_role_name.yml +84 -3
- data/test/cassettes/role_destroy.yml +84 -3
- data/test/cassettes/role_destroy_with_project_name.yml +60 -6
- data/test/cassettes/role_destroy_with_project_name_and_role_name.yml +60 -6
- data/test/cassettes/user_create.yml +31 -4
- data/test/cassettes/user_destroy.yml +30 -3
- data/test/cassettes/user_find.yml +58 -4
- data/test/cassettes/user_find_with_invalid_user_name.yml +3 -3
- data/test/cassettes/user_register.yml +67 -13
- data/test/cassettes/{user_register_assert.yml → user_register_asserts.yml} +10 -10
- data/test/lib/hashify_test.rb +3 -3
- data/test/lib/nephophobia/compute_test.rb +85 -69
- data/test/lib/nephophobia/credential_test.rb +91 -0
- data/test/lib/nephophobia/image_test.rb +29 -29
- data/test/lib/nephophobia/project_test.rb +115 -51
- data/test/lib/nephophobia/role_test.rb +151 -42
- data/test/lib/nephophobia/user_test.rb +48 -28
- data/test/test_helper.rb +9 -8
- metadata +21 -22
- data/test/cassettes/compute_all_with_string_into_int_error.yml +0 -28
- data/test/cassettes/image_all_with_string_into_int_error.yml +0 -28
- data/test/cassettes/project_all_with_string_into_int_error.yml +0 -55
- data/test/cassettes/project_all_with_with_user_name.yml +0 -136
- data/test/cassettes/project_members_with_no_members.yml +0 -28
- data/test/cassettes/project_members_with_string_into_int_error.yml +0 -28
- data/test/cassettes/role_all_with_no_roles.yml +0 -28
- data/test/cassettes/role_all_with_string_into_int_error.yml +0 -28
- data/test/cassettes/user_credentials.yml +0 -30
data/test/lib/hashify_test.rb
CHANGED
@@ -5,11 +5,11 @@ describe Hashify do
|
|
5
5
|
|
6
6
|
describe "::convert" do
|
7
7
|
it "creates a hash from a Nokogiri::XML::Document" do
|
8
|
-
xml = cassette_for "compute_all"
|
8
|
+
xml = cassette_for "compute_all", 1
|
9
9
|
hash = Hashify.convert xml.root
|
10
10
|
|
11
|
-
assert_equal "Server
|
12
|
-
assert_equal "
|
11
|
+
assert_equal "Server 42", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].first['displayName']
|
12
|
+
assert_equal "Server 46", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].last['displayName']
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,20 +1,48 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Compute do
|
4
|
+
##
|
5
|
+
# Note:
|
6
|
+
# Assumes there is always at least one valid project.
|
7
|
+
# Projects are core functionality to nova networking.
|
8
|
+
# We will always have at least one project configured.
|
9
|
+
|
4
10
|
before do
|
5
|
-
@
|
6
|
-
|
7
|
-
:
|
8
|
-
:project => "vcr_project"
|
9
|
-
).compute
|
11
|
+
@project_name = "sandbox"
|
12
|
+
@image_id = "ami-00000002"
|
13
|
+
@compute = ::Client.with(:user).compute
|
10
14
|
end
|
11
15
|
|
12
16
|
describe "#all" do
|
13
|
-
|
17
|
+
before do
|
14
18
|
VCR.use_cassette "compute_all" do
|
15
|
-
|
19
|
+
@instance_id = @compute.create(@image_id).instance_id
|
16
20
|
|
17
|
-
response.
|
21
|
+
@response = @compute.all
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
VCR.use_cassette "compute_all" do
|
27
|
+
@compute.destroy @instance_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns all instances" do
|
32
|
+
@response.size.must_be :>=, 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#all with filter" do
|
37
|
+
before do
|
38
|
+
VCR.use_cassette "compute_all_with_filter" do
|
39
|
+
@instance_id = @compute.create(@image_id).instance_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
VCR.use_cassette "compute_all_with_filter" do
|
45
|
+
@compute.destroy @instance_id
|
18
46
|
end
|
19
47
|
end
|
20
48
|
|
@@ -28,22 +56,15 @@ describe Nephophobia::Compute do
|
|
28
56
|
lambda { @compute.all filter }.must_raise Hugs::Errors::BadRequest
|
29
57
|
end
|
30
58
|
end
|
31
|
-
|
32
|
-
it "has a 'TypeError: can't convert String into Integer' error" do
|
33
|
-
VCR.use_cassette "compute_all_with_string_into_int_error" do
|
34
|
-
response = @compute.all
|
35
|
-
|
36
|
-
response.size.must_equal 1
|
37
|
-
end
|
38
|
-
end
|
39
59
|
end
|
40
60
|
|
41
61
|
describe "#create" do
|
42
|
-
before { @image_id = "ami-usc3oydl" }
|
43
|
-
|
44
62
|
it "create an instance with given 'image_id'" do
|
45
63
|
VCR.use_cassette "compute_create" do
|
46
|
-
response
|
64
|
+
response = @compute.create @image_id
|
65
|
+
instance_id = response.instance_id
|
66
|
+
|
67
|
+
@compute.destroy instance_id
|
47
68
|
|
48
69
|
response.image_id.must_equal @image_id
|
49
70
|
end
|
@@ -56,7 +77,10 @@ describe Nephophobia::Compute do
|
|
56
77
|
}
|
57
78
|
|
58
79
|
VCR.use_cassette "compute_create_with_optional_params" do
|
59
|
-
response
|
80
|
+
response = @compute.create @image_id, params
|
81
|
+
instance_id = response.instance_id
|
82
|
+
|
83
|
+
@compute.destroy instance_id
|
60
84
|
|
61
85
|
response.name.must_equal "testserver1"
|
62
86
|
response.description.must_equal "test description"
|
@@ -65,80 +89,72 @@ describe Nephophobia::Compute do
|
|
65
89
|
end
|
66
90
|
|
67
91
|
describe "#destroy" do
|
68
|
-
before
|
69
|
-
|
70
|
-
it "destroy the given 'instance_id'" do
|
92
|
+
before do
|
71
93
|
VCR.use_cassette "compute_destroy" do
|
72
|
-
|
94
|
+
instance_id = @compute.create(@image_id).instance_id
|
73
95
|
|
74
|
-
response.
|
96
|
+
@response = @compute.destroy instance_id
|
75
97
|
end
|
76
98
|
end
|
99
|
+
|
100
|
+
it "destroy the given 'instance_id'" do
|
101
|
+
@response.return.must_equal true
|
102
|
+
end
|
77
103
|
end
|
78
104
|
|
79
105
|
describe "#find" do
|
80
106
|
before do
|
81
|
-
@instance_id = "i-000004a5"
|
82
|
-
|
83
107
|
VCR.use_cassette "compute_find" do
|
108
|
+
@instance_id = @compute.create(@image_id).instance_id
|
109
|
+
|
84
110
|
@response = @compute.find @instance_id
|
85
111
|
end
|
86
112
|
end
|
87
113
|
|
114
|
+
after do
|
115
|
+
VCR.use_cassette "compute_find" do
|
116
|
+
@compute.destroy @instance_id
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
88
120
|
it "returns the given 'instance_id'" do
|
89
121
|
@response.instance_id.must_equal @instance_id
|
90
122
|
end
|
91
123
|
|
92
124
|
it "contains the compute data" do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
compute.placement.must_equal "nova"
|
107
|
-
compute.instance_type.must_equal "m1.small"
|
125
|
+
@response.project_id.must_equal @project_name
|
126
|
+
@response.description.must_be_nil
|
127
|
+
@response.name.must_match %r{Server [0-9]+}
|
128
|
+
@response.respond_to?(:key_name).must_equal true
|
129
|
+
@response.instance_id.must_match %r{i-[a-z0-9]+}
|
130
|
+
@response.state.must_match %r{[a-z]+}
|
131
|
+
@response.respond_to?(:dns_name).must_equal true
|
132
|
+
@response.respond_to?(:public_dns_name).must_equal true
|
133
|
+
@response.respond_to?(:private_dns_name).must_equal true
|
134
|
+
@response.image_id.must_match %r{ami-[a-z0-9]+}
|
135
|
+
@response.launch_time.must_be_kind_of DateTime
|
136
|
+
@response.placement.must_match %r{[a-z]+}
|
137
|
+
@response.instance_type.must_match %r{[a-z]{2}.[a-z]+}
|
108
138
|
end
|
109
139
|
end
|
110
140
|
|
111
141
|
describe "#reboot" do
|
112
|
-
before
|
113
|
-
|
114
|
-
it "reboots the given 'instance_id'" do
|
142
|
+
before do
|
115
143
|
VCR.use_cassette "compute_reboot" do
|
116
|
-
|
144
|
+
@instance_id = @compute.create(@image_id).instance_id
|
117
145
|
|
118
|
-
response.
|
146
|
+
@response = @compute.reboot @instance_id
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
after do
|
151
|
+
VCR.use_cassette "compute_reboot" do
|
152
|
+
@compute.destroy @instance_id
|
119
153
|
end
|
120
154
|
end
|
121
|
-
end
|
122
155
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
# it "API doesn't implement StartInstances" do
|
128
|
-
# VCR.use_cassette "compute_start" do
|
129
|
-
# lambda { @compute.start @instance_id }.must_raise Hugs::Errors::BadRequest
|
130
|
-
# end
|
131
|
-
# end
|
132
|
-
#end
|
133
|
-
|
134
|
-
#describe "#stop" do
|
135
|
-
# before { @instance_id = "i-000004a5" }
|
136
|
-
|
137
|
-
# 2011-02-26 20:50:45,375 ERROR nova.api [HIA363E2X4025I-FIZ7E jdewey production] Unexpected error raised: Unsupported API request: controller = CloudController, action = StopInstances
|
138
|
-
# it "API doesn't implement StopInstances" do
|
139
|
-
# VCR.use_cassette "compute_stop" do
|
140
|
-
# lambda { @compute.stop @instance_id }.must_raise Hugs::Errors::BadRequest
|
141
|
-
# end
|
142
|
-
# end
|
143
|
-
#end
|
156
|
+
it "reboots the given 'instance_id'" do
|
157
|
+
@response.return.must_equal true
|
158
|
+
end
|
159
|
+
end
|
144
160
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
describe Nephophobia::Credential do
|
2
|
+
##
|
3
|
+
# Note:
|
4
|
+
# Assumes there is always at least one valid project.
|
5
|
+
# Projects are core functionality to nova networking.
|
6
|
+
# We will always have at least one project configured.
|
7
|
+
|
8
|
+
before do
|
9
|
+
@key_name = "vcr_keypair"
|
10
|
+
@project_name = "sandbox"
|
11
|
+
@credential = ::Client.with(:user).credential
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#all" do
|
15
|
+
describe "with keys" do
|
16
|
+
before do
|
17
|
+
VCR.use_cassette "credential_all" do
|
18
|
+
@credential.create @key_name
|
19
|
+
|
20
|
+
@response = @credential.all
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
VCR.use_cassette "credential_all" do
|
26
|
+
@credential.destroy @key_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns all keys" do
|
31
|
+
@response.size.must_be :>=, 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "without keys" do
|
36
|
+
it "returns all keys" do
|
37
|
+
VCR.use_cassette "credential_all_without_keys" do
|
38
|
+
response = @credential.all
|
39
|
+
|
40
|
+
response.must_be_nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#create" do
|
47
|
+
before do
|
48
|
+
VCR.use_cassette "credential_create" do
|
49
|
+
@response = @credential.create @key_name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
VCR.use_cassette "credential_create" do
|
55
|
+
@credential.destroy @key_name
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "creates a key pair for the key name" do
|
60
|
+
@response.material.must_match %r{BEGIN RSA PRIVATE KEY.*END RSA PRIVATE KEY}m
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#destroy" do
|
65
|
+
before do
|
66
|
+
VCR.use_cassette "credential_destroy" do
|
67
|
+
@credential.create @key_name
|
68
|
+
|
69
|
+
@response = @credential.destroy @key_name
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "deletes the key pair for the key name" do
|
74
|
+
@response.return.must_equal true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#describe "#download" do
|
79
|
+
# before do
|
80
|
+
# @user_name = "jd265j"
|
81
|
+
# end
|
82
|
+
|
83
|
+
# it "returns the credentials for a given 'user_name' for the specified 'project_name'." do
|
84
|
+
# VCR.use_cassette "credential_download" do
|
85
|
+
# response = @credential.download @user_name, @project_name
|
86
|
+
|
87
|
+
# response.must_match %r{BEGIN CERTIFICATE}
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
#end
|
91
|
+
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Image do
|
4
|
+
##
|
5
|
+
# Note:
|
6
|
+
# Assumes there is always at least one valid image.
|
7
|
+
# Images need to be manually uploaded with euca2ools
|
8
|
+
# or ogle.
|
9
|
+
#
|
10
|
+
# Assumes there is always at least one valid project.
|
11
|
+
# Projects are core functionality to nova networking.
|
12
|
+
# We will always have at least one project configured.
|
13
|
+
|
4
14
|
before do
|
5
|
-
@image = ::Client.with(:user
|
6
|
-
:access_key => "57c971e9-0225-4fa4-8969-60b880e9f827",
|
7
|
-
:secret_key => "86a6a123-2d11-4e99-9931-20b01f6fb236",
|
8
|
-
:project => "vcr_project"
|
9
|
-
).image
|
15
|
+
@image = ::Client.with(:user).image
|
10
16
|
end
|
11
17
|
|
12
18
|
describe "#all" do
|
@@ -14,7 +20,7 @@ describe Nephophobia::Image do
|
|
14
20
|
VCR.use_cassette "image_all" do
|
15
21
|
response = @image.all
|
16
22
|
|
17
|
-
response.size.
|
23
|
+
response.size.must_be :>=, 1
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
@@ -22,52 +28,46 @@ describe Nephophobia::Image do
|
|
22
28
|
VCR.use_cassette "image_all_with_filter" do
|
23
29
|
response = @image.all "ExecutableBy.1" => "self"
|
24
30
|
|
25
|
-
response.size.
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "has a 'TypeError: can't convert String into Integer' error" do
|
30
|
-
VCR.use_cassette "image_all_with_string_into_int_error" do
|
31
|
-
response = @image.all
|
32
|
-
|
33
|
-
response.size.must_equal 1
|
31
|
+
response.size.must_be :>=, 1
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
36
|
describe "#find" do
|
37
|
+
##
|
38
|
+
# Note:
|
39
|
+
# Assumes this is a public, runnable, machine type.
|
40
|
+
|
39
41
|
before do
|
40
|
-
@image_id = "ami-
|
42
|
+
@image_id = "ami-00000002"
|
41
43
|
|
42
44
|
VCR.use_cassette "image_find" do
|
43
45
|
@response = @image.find @image_id
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
it "returns the
|
49
|
+
it "returns the image" do
|
48
50
|
@response.image_id.must_equal @image_id
|
49
51
|
end
|
50
52
|
|
51
53
|
it "contains the image data" do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
image.kernel_id.must_equal "true"
|
61
|
-
image.state.must_equal "available"
|
54
|
+
@response.respond_to?(:architecture).must_equal true
|
55
|
+
@response.image_id.must_equal @image_id
|
56
|
+
@response.image_location.must_match %r{[a-z]+}
|
57
|
+
@response.respond_to?(:image_owner_id).must_equal true
|
58
|
+
@response.image_type.must_equal "machine"
|
59
|
+
@response.is_public.must_equal "true"
|
60
|
+
@response.kernel_id.must_match %r{[a-z]+-[0-9]+}
|
61
|
+
@response.state.must_equal "available"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#public" do
|
66
66
|
it "returns all public images" do
|
67
67
|
VCR.use_cassette "image_all" do
|
68
|
-
response = @image.
|
68
|
+
response = @image.runnable
|
69
69
|
|
70
|
-
response.
|
70
|
+
response.any? { |i| i.image_type != "kernel"}.must_equal true
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,23 +1,38 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Project do
|
4
|
+
##
|
5
|
+
# Note:
|
6
|
+
# Assumes there is always at least one valid project.
|
7
|
+
# Projects are core functionality to nova networking.
|
8
|
+
# We will always have at least one project configured.
|
9
|
+
|
4
10
|
before do
|
11
|
+
@user_name = "vcr_user"
|
12
|
+
@project_name = "sandbox"
|
5
13
|
@project = ::Client.with(:admin).project
|
6
14
|
@user = ::Client.with(:admin).user
|
7
|
-
@user_name = "vcr"
|
8
|
-
@project_name = "vcr_project"
|
9
15
|
end
|
10
16
|
|
11
17
|
describe "#add_member" do
|
12
|
-
before
|
13
|
-
|
14
|
-
it "adds the given 'user_name' to the specified 'project_name'" do
|
18
|
+
before do
|
15
19
|
VCR.use_cassette "project_add_member" do
|
16
|
-
|
20
|
+
@user.create @user_name
|
17
21
|
|
18
|
-
response.
|
22
|
+
@response = @project.add_member @user_name, @project_name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
VCR.use_cassette "project_add_member" do
|
28
|
+
@project.remove_member @user_name, @project_name
|
29
|
+
@user.destroy @user_name
|
19
30
|
end
|
20
31
|
end
|
32
|
+
|
33
|
+
it "adds the given user name to the project" do
|
34
|
+
@response.return.must_equal true
|
35
|
+
end
|
21
36
|
end
|
22
37
|
|
23
38
|
describe "#all" do
|
@@ -25,48 +40,76 @@ describe Nephophobia::Project do
|
|
25
40
|
VCR.use_cassette "project_all" do
|
26
41
|
response = @project.all
|
27
42
|
|
28
|
-
response.size.
|
43
|
+
response.size.must_be :>=, 1
|
29
44
|
end
|
30
45
|
end
|
46
|
+
end
|
31
47
|
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
describe "#all with a 'user_name'" do
|
49
|
+
before do
|
50
|
+
VCR.use_cassette "project_all_with_user_name" do
|
51
|
+
@user.create @user_name
|
52
|
+
@project.add_member @user_name, @project_name
|
35
53
|
|
36
|
-
response.
|
54
|
+
@response = @project.all @user_name
|
37
55
|
end
|
38
56
|
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#all with a user_name" do
|
42
|
-
it "returns all projects for the given 'user_name'" do
|
43
|
-
VCR.use_cassette "project_all_with_with_user_name" do
|
44
|
-
response = @project.all @user_name
|
45
57
|
|
46
|
-
|
58
|
+
after do
|
59
|
+
VCR.use_cassette "project_all_with_user_name" do
|
60
|
+
@project.remove_member @user_name, @project_name
|
61
|
+
@user.destroy @user_name
|
47
62
|
end
|
48
63
|
end
|
64
|
+
|
65
|
+
it "returns all projects" do
|
66
|
+
@response.size.must_be :>=, 1
|
67
|
+
end
|
49
68
|
end
|
50
69
|
|
51
70
|
describe "#create" do
|
52
|
-
|
71
|
+
before do
|
53
72
|
VCR.use_cassette "project_create" do
|
54
|
-
|
73
|
+
@project_name = "vcr_project"
|
74
|
+
@user.create @user_name
|
55
75
|
|
56
|
-
response.
|
57
|
-
response.manager_id.must_equal @user_name
|
76
|
+
@response = @project.create @project_name, @user_name
|
58
77
|
end
|
59
78
|
end
|
79
|
+
|
80
|
+
after do
|
81
|
+
VCR.use_cassette "project_create" do
|
82
|
+
@user.destroy @user_name
|
83
|
+
@project.destroy @project_name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "creates the project and adds the user name as the manager" do
|
88
|
+
@response.name.must_equal @project_name
|
89
|
+
@response.manager_id.must_equal @user_name
|
90
|
+
end
|
60
91
|
end
|
61
92
|
|
62
93
|
describe "#destroy" do
|
63
|
-
|
94
|
+
before do
|
64
95
|
VCR.use_cassette "project_destroy" do
|
65
|
-
|
96
|
+
@project_name = "vcr_project"
|
97
|
+
@user.create @user_name
|
98
|
+
@project.create @project_name, @user_name
|
99
|
+
|
100
|
+
@response = @project.destroy @project_name
|
101
|
+
end
|
102
|
+
end
|
66
103
|
|
67
|
-
|
104
|
+
after do
|
105
|
+
VCR.use_cassette "project_destroy" do
|
106
|
+
@user.destroy @user_name
|
68
107
|
end
|
69
108
|
end
|
109
|
+
|
110
|
+
it "destroys the project" do
|
111
|
+
@response.return.must_equal true
|
112
|
+
end
|
70
113
|
end
|
71
114
|
|
72
115
|
describe "#find" do
|
@@ -76,21 +119,19 @@ describe Nephophobia::Project do
|
|
76
119
|
end
|
77
120
|
end
|
78
121
|
|
79
|
-
it "returns the
|
122
|
+
it "returns the project" do
|
80
123
|
@response.name.must_equal @project_name
|
81
124
|
end
|
82
125
|
|
83
126
|
it "contains the project data" do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
project.manager_id.must_equal "vcr"
|
88
|
-
project.description.must_equal "vcr_project"
|
127
|
+
@response.name.must_equal @project_name
|
128
|
+
@response.manager_id.must_match %r{[a-z]+}
|
129
|
+
@response.description.must_equal @project_name
|
89
130
|
end
|
90
131
|
end
|
91
132
|
|
92
133
|
describe "#find with invalid project_name" do
|
93
|
-
it "
|
134
|
+
it "returns nil" do
|
94
135
|
VCR.use_cassette "project_find_with_invalid_project_name" do
|
95
136
|
@response = @project.find "invalid_project_name"
|
96
137
|
end
|
@@ -100,25 +141,27 @@ describe Nephophobia::Project do
|
|
100
141
|
end
|
101
142
|
|
102
143
|
describe "#members" do
|
103
|
-
|
144
|
+
before do
|
104
145
|
VCR.use_cassette "project_members" do
|
105
|
-
|
146
|
+
@user.create @user_name
|
106
147
|
|
107
|
-
response.
|
148
|
+
@response = @project.members @project_name
|
108
149
|
end
|
109
150
|
end
|
110
151
|
|
111
|
-
|
112
|
-
VCR.use_cassette "
|
113
|
-
|
114
|
-
|
115
|
-
response.size.must_equal 1
|
152
|
+
after do
|
153
|
+
VCR.use_cassette "project_members" do
|
154
|
+
@user.destroy @user_name
|
116
155
|
end
|
117
156
|
end
|
157
|
+
|
158
|
+
it "returns all project members for the project" do
|
159
|
+
@response.size.must_be :>=, 1
|
160
|
+
end
|
118
161
|
end
|
119
162
|
|
120
163
|
describe "#members with invalid 'project_name'" do
|
121
|
-
it "
|
164
|
+
it "returns nil" do
|
122
165
|
VCR.use_cassette "project_members_with_invalid_project_name" do
|
123
166
|
@response = @project.members "invalid_project_name"
|
124
167
|
end
|
@@ -128,24 +171,45 @@ describe Nephophobia::Project do
|
|
128
171
|
end
|
129
172
|
|
130
173
|
describe "#member?" do
|
131
|
-
|
132
|
-
VCR.use_cassette "
|
133
|
-
|
174
|
+
before do
|
175
|
+
VCR.use_cassette "project_member" do
|
176
|
+
@user.create @user_name
|
177
|
+
@project.add_member @user_name, @project_name
|
134
178
|
|
135
|
-
response.
|
179
|
+
@response = @project.member? @user_name, @project_name
|
136
180
|
end
|
137
181
|
end
|
182
|
+
|
183
|
+
after do
|
184
|
+
VCR.use_cassette "project_member" do
|
185
|
+
@project.remove_member @user_name, @project_name
|
186
|
+
@user.destroy @user_name
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it "returns true if the user name is a member of the project" do
|
191
|
+
@response.must_equal true
|
192
|
+
end
|
138
193
|
end
|
139
194
|
|
140
195
|
describe "#remove_member" do
|
141
|
-
before
|
142
|
-
|
143
|
-
it "removes the given 'user_name' from the specified 'project_name'" do
|
196
|
+
before do
|
144
197
|
VCR.use_cassette "project_remove_member" do
|
145
|
-
|
198
|
+
@user.create @user_name
|
199
|
+
@project.add_member @user_name, @project_name
|
146
200
|
|
147
|
-
response.
|
201
|
+
@response = @project.remove_member @user_name, @project_name
|
148
202
|
end
|
149
203
|
end
|
204
|
+
|
205
|
+
after do
|
206
|
+
VCR.use_cassette "project_remove_member" do
|
207
|
+
@user.destroy @user_name
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
it "removes the user name from the specified project" do
|
212
|
+
@response.return.must_equal true
|
213
|
+
end
|
150
214
|
end
|
151
215
|
end
|