[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rspec2 -> rspec3 conversion question



On 8/4/15, Hleb Valoshka <375gnu@gmail.com> wrote:

Quite strange, because this code is correct, and it works for my
simple class made just to check it. Any help is appreciated.

> == 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.


Reply to: