Skip to content

Instantly share code, notes, and snippets.

@paul
Created December 4, 2008 22:52
Show Gist options
  • Save paul/32131 to your computer and use it in GitHub Desktop.
Save paul/32131 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), 'host_shared_specs')
describe 'POST SSMJ1 to /client/x/hosts', :type => 'service' do
request { |attributes|
post_ssmj1(hosts_by_client_url(attributes[:client] || Client::API),
host_ssmj1_json(attributes))
}
should_be_created
should_require_pairs :name
should_ignore_pairs :href, :id, :_type,
:client_href,
:metrics_href
should_validate_pairs :name,
:valid => ['test', 'Test host', 'test.host'],
:invalid => ["t" * 65]
should_validate_pairs :comments,
:valid => ["Anything, really..."],
:invalid => ['t' * 1025]
should_allow_pairs :hostname => 'test.host',
:active? => false,
:comments => "Some comments about this host",
:tags => ['test', 'spec', 'etc...']
should_require_privilege :view_client, :create_host
end
require File.join(File.dirname(__FILE__), 'host_shared_specs')
describe 'GET SSmJ1 from /hosts/x', :type => 'service' do
subject { |attributes|
@host = Host.create({:hostname => 'test show',
:client => Client::API}.merge(attributes))
}
request { |attributes|
get_ssmj1(host_url(subject(attributes)))
}
should_be_a_ssmj1_object_document
should_have_pairs {{
:name => subject.hostname,
:tags => subject.tags,
:active? => subject.active?,
:client_href => client_url(subject.client),
:metrics_href => metrics_by_host_url(subject),
:created_at => subject.created_at.iso8601,
:updated_at => subject.updated_at.iso8601
}}
should_require_privilege :view_host
should_specify_caching :max_age => 5.minutes,
:last_modified_field => :created_at
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment