spec/cfoundry/uaaclient_spec.rb in cfoundry-4.3.5.rc1 vs spec/cfoundry/uaaclient_spec.rb in cfoundry-4.3.5

- old
+ new

@@ -253,31 +253,61 @@ describe "#add_user" do let(:email) { 'test@test.com' } let(:password) { 'secret' } - subject { uaa.add_user(email, password) } + context "without given/family name" do + subject { uaa.add_user(email, password) } - context 'with valid data' do - it "should add a user" do - req = + context 'with valid data' do + it "should add a user" do + req = stub_request(:post, "https://uaa.example.com/Users").with( :body => { :userName => email, :emails => [{ :value => email }], :password => password, :name => { :givenName => email, :familyName => email } } - ).to_return( - :status => 200, - :body => '{ "id" : "id" }', - :headers => { "Content-Type" => 'application/json' } - ) + ).to_return( + :status => 200, + :body => '{ "id" : "id" }', + :headers => { "Content-Type" => 'application/json' } + ) - expect(subject).to eq({:id => "id"}) - expect(req).to have_been_requested + expect(subject).to eq({:id => "id"}) + expect(req).to have_been_requested + end end end + + context "with given/family name" do + let(:givenName) { 'givenName' } + let(:familyName) { 'familyName' } + subject { uaa.add_user(email, password, givenName: givenName, familyName: familyName) } + + context 'with valid data' do + it "should add a user" do + req = + stub_request(:post, "https://uaa.example.com/Users").with( + :body => + { :userName => email, + :emails => [{ :value => email }], + :password => password, + :name => { :givenName => givenName, :familyName => familyName } + } + ).to_return( + :status => 200, + :body => '{ "id" : "id" }', + :headers => { "Content-Type" => 'application/json' } + ) + + expect(subject).to eq({:id => "id"}) + expect(req).to have_been_requested + end + end + end + end describe "#delete_user" do let(:guid) { "123" } let!(:req) {