admin-vmc-plugin 0.0.5 → 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/admin-vmc-plugin/curl.rb +10 -6
- data/lib/admin-vmc-plugin/version.rb +1 -1
- data/spec/curl_spec.rb +25 -0
- data/spec/spec_helper.rb +18 -0
- metadata +15 -14
@@ -17,7 +17,7 @@ module VMCAdmin
|
|
17
17
|
input :body, :alias => "-b",
|
18
18
|
:desc => "Request body"
|
19
19
|
def curl
|
20
|
-
mode = input[:mode].
|
20
|
+
mode = input[:mode].upcase
|
21
21
|
path = input[:path]
|
22
22
|
body = input[:body]
|
23
23
|
|
@@ -31,12 +31,12 @@ module VMCAdmin
|
|
31
31
|
accept = headers["accept"]
|
32
32
|
|
33
33
|
content ||= :json if body
|
34
|
-
accept ||= :json unless
|
34
|
+
accept ||= :json unless %w(DELETE HEAD).include?(mode)
|
35
35
|
|
36
|
-
res =
|
37
|
-
client.base.
|
38
|
-
|
39
|
-
path
|
36
|
+
req, res =
|
37
|
+
client.base.request_raw(
|
38
|
+
mode,
|
39
|
+
remove_leading_slash(path),
|
40
40
|
:headers => headers,
|
41
41
|
:accept => accept,
|
42
42
|
:payload => body,
|
@@ -48,5 +48,9 @@ module VMCAdmin
|
|
48
48
|
puts res
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
def remove_leading_slash(path)
|
53
|
+
path.sub(%r{^/}, '')
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
data/spec/curl_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe VMCAdmin::Curl do
|
4
|
+
use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dir" }
|
5
|
+
|
6
|
+
subject { vmc ["curl", "--mode", "GET", "--path", "apps/5/instances"] }
|
7
|
+
|
8
|
+
before do
|
9
|
+
any_instance_of(CFoundry::Client) do |client|
|
10
|
+
stub(client).info { { :version => 2 } }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "makes a request to the current target" do
|
15
|
+
stub_request(:get, "https://api.some-target-for-vmc-curl.com/apps/5/instances").to_return(
|
16
|
+
:status => 200,
|
17
|
+
:body => 'some-body'
|
18
|
+
)
|
19
|
+
|
20
|
+
subject
|
21
|
+
|
22
|
+
expect(stdout.string).to include('"status": "200"')
|
23
|
+
expect(stdout.string).to include('"body": "some-body"')
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
SPEC_ROOT = File.dirname(__FILE__).freeze
|
2
|
+
|
3
|
+
require "rspec"
|
4
|
+
require "vmc"
|
5
|
+
require "cfoundry"
|
6
|
+
require "cfoundry/test_support"
|
7
|
+
require "webmock/rspec"
|
8
|
+
require "vmc/test_support"
|
9
|
+
|
10
|
+
require "#{SPEC_ROOT}/../lib/admin-vmc-plugin/plugin"
|
11
|
+
|
12
|
+
RSpec.configure do |c|
|
13
|
+
c.include Fake::FakeMethods
|
14
|
+
c.mock_with :rr
|
15
|
+
|
16
|
+
c.include VMC::TestSupport::FakeHomeDir
|
17
|
+
c.include VMC::TestSupport::CommandHelper
|
18
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admin-vmc-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.5
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2013-02-06 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: cfoundry
|
@@ -26,12 +25,12 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
28
|
+
hash: 11
|
30
29
|
segments:
|
31
30
|
- 0
|
32
|
-
-
|
31
|
+
- 5
|
33
32
|
- 0
|
34
|
-
version: 0.
|
33
|
+
version: 0.5.0
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
37
36
|
description:
|
@@ -45,11 +44,12 @@ extra_rdoc_files: []
|
|
45
44
|
|
46
45
|
files:
|
47
46
|
- Rakefile
|
48
|
-
- lib/admin-vmc-plugin/
|
47
|
+
- lib/admin-vmc-plugin/curl.rb
|
49
48
|
- lib/admin-vmc-plugin/plugin.rb
|
50
49
|
- lib/admin-vmc-plugin/service_auth_token.rb
|
51
|
-
- lib/admin-vmc-plugin/
|
52
|
-
|
50
|
+
- lib/admin-vmc-plugin/version.rb
|
51
|
+
- spec/curl_spec.rb
|
52
|
+
- spec/spec_helper.rb
|
53
53
|
homepage: http://cloudfoundry.com/
|
54
54
|
licenses: []
|
55
55
|
|
@@ -79,9 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements: []
|
80
80
|
|
81
81
|
rubyforge_project: admin-vmc-plugin
|
82
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.8.24
|
83
83
|
signing_key:
|
84
84
|
specification_version: 3
|
85
85
|
summary: Cloud Foundry administration commands.
|
86
|
-
test_files:
|
87
|
-
|
86
|
+
test_files:
|
87
|
+
- spec/curl_spec.rb
|
88
|
+
- spec/spec_helper.rb
|