Hi Dimitry

Ah yes, we don’t rescue `exit` as we consider that to be the correct Ruby 
semantic, we don’t know wether its your code, an extension, or some other 
reason, you can prevent it yourself with `expect { … }.to 
raise_error(SystemExit)`.

`expect(something).to receive(:message)`

Will not invoke `message` on `something` unless you use `.and_call_original()`. 
It replaces it with a dummy implementation that returns nil by default.

Cheers
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk

On 6 February 2020 at 10:54, Dmitry Sokolyansky wrote:
> I figure out. The thread does not go to the "expect" statement because of the 
> Ruby script terminates with the "exit" statement.
> So, I reverted PR, and now in the “master” branch is the implementation of my 
> loop, and in the “dev” branch is the implementation with the “exit” operator.
>
>
> My loop implementation works well, but “expect (current_subject) .to receive 
> (: create)” runs the “create” method in addition to the loop and it hangs up 
> the test.
> If you comment out the “expect” statement, the test completes correctly.
>
> I mean going through all the expected methods that I checked by their 
> messages and state values, that is, I see changes of all expected states:
> :greeting -> :choose_base_option -> :create -> :exit
>
>
>
>
> And if you change the name of the called method from "create" to "load" 
> (which will not be called), the test will fail, as expected.
> If you add "once / twice" to the “expect” expression, for example, 
> “expect(current_subject).to receive(:create).once / twice ”, this will raise 
> an expectation error:
>
> (#<Console:0x0000563bfc2f7f90 @state=:create>).create(no args)
>
> expected : 1 time with
> any arguments
> received
> : 2 times
>
> and
>
>
> (#<Console:0x00005570a26aedf8 @state=:create>).create(no args)
>
> expected : 2 times with
> any arguments
> received
> : 3 times
>
> respectively
>
>
>
>
> branch master
>
> Thus, the issue is how to test the method being called without calling it 
> from the expression "expect".

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/dejalu-217-3c1775d4-54e5-4053-abee-4460f9bc482d%40jonrowe.co.uk.

Reply via email to