spec/shelly/client_spec.rb in shelly-0.1.6 vs spec/shelly/client_spec.rb in shelly-0.1.7
- old
+ new
@@ -188,9 +188,27 @@
response = @client.app("staging-foo")
response.should == {"web_server_ip" => "192.0.2.1", "mail_server_ip" => "192.0.2.3"}
end
end
+ describe "#statistics" do
+ it "should fetch app statistics from API" do
+ @body = [{:name => "app1",
+ :memory => {:kilobyte => "276756", :percent => "74.1"},
+ :swap => {:kilobyte => "44332", :percent => "2.8"},
+ :cpu => {:wait => "0.8", :system => "0.0", :user => "0.1"},
+ :load => {:avg15 => "0.13", :avg05 => "0.15", :avg01 => "0.04"}}]
+ FakeWeb.register_uri(:get, api_url("apps/staging-foo/statistics"),
+ :body => @body.to_json)
+ response = @client.statistics("staging-foo")
+ response.should == [{"name" => "app1",
+ "memory" => {"kilobyte" => "276756", "percent" => "74.1"},
+ "swap" => {"kilobyte" => "44332", "percent" => "2.8"},
+ "cpu" => {"wait" => "0.8", "system" => "0.0", "user" => "0.1"},
+ "load" => {"avg15" =>"0.13", "avg05" => "0.15", "avg01" => "0.04"}}]
+ end
+ end
+
describe "#command" do
it "should send post request with app code_name, body and type" do
@client.should_receive(:post).with("/apps/staging-foo/command",
{:body => "2 + 2", :type => :ruby}).and_return({"result" => "4"})
response = @client.command("staging-foo", "2 + 2", :ruby)