Hi team.

I'm using transpec to convert rspec syntax to rspec3, but it seems
that it's not enough. I need help to properly convert such pieces:

== rspec 2.14 syntax ==
describe Ridley::ClientResource do
  subject { described_class.new(double('registry')) }

  describe "#regenerate_key" do
    let(:client_id) { "rspec-client" }
    before { subject.stub(find: nil) }

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

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

== after transpec ==
describe Ridley::ClientResource do
  subject { described_class.new(double('registry')) }

  describe "#regenerate_key" do
    let(:client_id) { "rspec-client" }
    before { allow(subject).to receive_messages(find: nil) }

    context "when a client with the given ID does not exist" do
      before { expect(subject).to
receive(:find).with(client_id).and_return(nil) }

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

The problem that code in before {} does not work, and ...Mock... error
raised instead of expected one.

How such code should look to work with rspec3?


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: 
https://lists.debian.org/CAAB-Kc=ZBH33fg88fD7j7vRHaf1maYAwyq7=KU7ZiPT=bjc...@mail.gmail.com

Reply via email to