require "test_helper" describe Nephophobia::User do before do @user = ::Client.with(:admin).user @user_name = "vcr" end describe "#create" do it "creates the given 'user_name'" do VCR.use_cassette "user_create" do response = @user.create @user_name response.username.must_equal @user_name end end end describe "#credentials" do before { @project_name = "vcr_project" } it "returns the credentials for a given 'user_name' for the specified 'project_name'." do VCR.use_cassette "user_credentials" do response = @user.credentials @user_name, @project_name response.must_match %r{BEGIN CERTIFICATE} end end end describe "#destroy" do it "destroys the given 'user_name'" do VCR.use_cassette "user_destroy" do response = @user.destroy @user_name response.return.must_equal true end end end describe "#find" do before do VCR.use_cassette "user_find" do @response = @user.find @user_name end end it "returns the given 'user_name'" do @response.username.must_equal @user_name end it "contains the user data" do user = @response user.username.must_equal "vcr" user.secretkey.must_equal "a0d9ff15-2b76-416c-b6fb-03f63c4b8413" user.accesskey.must_equal "285db1a2-4c3b-4f35-a36f-1e5495fa94f2" end end describe "#find with invalid user_name" do it "rescues Hugs::Errors::BadRequest" do VCR.use_cassette "user_find_with_invalid_user_name" do @response = @user.find "invalid_user_name" end @response.must_be_nil end end end