Sha256: 781900d887544629b4846a2633a627809503cfd52e059d44a6aaf03fa71be8dd

Contents?: true

Size: 1002 Bytes

Versions: 29

Compression:

Stored size: 1002 Bytes

Contents

require 'spec_helper'

describe Ridley::UserResource, type: 'wip' do
  subject { described_class.new(double('registry')) }
  let(:user_id) { "rspec-user" }
  let(:user_password) { "swordfish" }

  describe "#regenerate_key" do
    before { subject.stub(find: nil) }

    context "when a user with the given ID exists" do
      let(:user) { double('chef-user') }
      before { subject.should_receive(:find).with(user_id).and_return(user) }

      it "sets the private key to true and updates the user" do
        user.should_receive(:private_key=).with(true)
        subject.should_receive(:update).with(user)

        subject.regenerate_key(user_id)
      end
    end

    context "when a user with the given ID does not exist" do
      before { subject.should_receive(:find).with(user_id).and_return(nil) }

      it "raises a ResourceNotFound error" do
        expect {
          subject.regenerate_key(user_id)
        }.to raise_error(Ridley::Errors::ResourceNotFound)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
ridley-5.1.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-5.1.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-5.0.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.6.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.6.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.5.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.5.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.4.3 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.4.2 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.4.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.4.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.3.2 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.3.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.3.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.2.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.1.2 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.1.1 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.1.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-4.0.0 spec/unit/ridley/resources/user_resource_spec.rb
ridley-3.1.0 spec/unit/ridley/resources/user_resource_spec.rb