Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rspec3 - doubles or partial doubles from rspec-mocks outside .... #164

Open
traylenator opened this issue Nov 20, 2019 · 6 comments · May be fixed by #175
Open

rspec3 - doubles or partial doubles from rspec-mocks outside .... #164

traylenator opened this issue Nov 20, 2019 · 6 comments · May be fixed by #175
Labels
HepWanted Help Wanted

Comments

@traylenator
Copy link

With:

stomp-1.4.9

ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

$ rspec --version
RSpec 3.8
  - rspec-core 3.8.2
  - rspec-expectations 3.8.4
  - rspec-mocks 3.8.1
  - rspec-support 3.8.2

This results in:

$ rspec --fail-fast spec/client_spec.rb 
RSpec version: 3.8.0
#<Thread:0x000055a54123d138@/home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:193 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	9: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `block in start_listeners'
	8: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `loop'
	7: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:195:in `block (2 levels) in start_listeners'
	6: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/test_double.rb:102:in `method_missing'
	5: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/proxy.rb:202:in `raise_unexpected_message_error'
	4: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:50:in `raise_unexpected_message_error'
	3: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:311:in `__raise'
	2: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:327:in `notify'
	1: from /usr/share/gems/gems/rspec-support-3.8.2/lib/rspec/support.rb:106:in `notify_failure'
/usr/share/gems/gems/rspec-support-3.8.2/lib/rspec/support.rb:97:in `block in <module:Support>': #<Double "connection"> received unexpected message :receive with (no args) (RSpec::Mocks::MockExpectationError)
.#<Thread:0x000055a54150bd60@/home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:193 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	6: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `block in start_listeners'
	5: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `loop'
@gmallard
Copy link

I will try and look at this during the coming weekend.

However, if you have a fix I would appreciate a PR.

@gmallard gmallard added the HepWanted Help Wanted label Nov 30, 2019
@gmallard
Copy link

I confess rspec tests are not a strong skill.

I could use some help figuring this out.

@traylenator
Copy link
Author

I had a quick look the other day and got as far as working out it was not trivial.

@sudeeptarlekar
Copy link

How can I mock Stomp client in application? Currently I am using double to mock Stomp and methods to it. Is this correct way of testing or is there any better approach available?

@gmallard
Copy link

If mocks work for you, then it is perfectly fine to use them.

I personally do not test the gem using rspec/mocks - I run unit tests against live brokers.

I do not believe that mocks can ever approach what you will see a live running broker actually do.

The gem unit tests are run against:

  • ActiveMQ
  • RabbitMQ
  • Artemis
  • Apollo

traylenator added a commit to traylenator/stomp that referenced this issue Mar 30, 2023
Patch from

* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1027092
* https://salsa.debian.org/ruby-team/ruby-stomp/-/commit/5be6383a7a34a1d1891708d6aa8688cb4a6f89a5

resolves rspec failure:

```
$ rspec --fail-fast spec/client_spec.rb
RSpec version: 3.8.0
Traceback (most recent call last):
	9: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `block in start_listeners'
	8: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `loop'
	7: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:195:in `block (2 levels) in start_listeners'
	6: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/test_double.rb:102:in `method_missing'
	5: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/proxy.rb:202:in `raise_unexpected_message_error'
	4: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:50:in `raise_unexpected_message_error'
	3: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:311:in `__raise'
	2: from /usr/share/gems/gems/rspec-mocks-3.8.1/lib/rspec/mocks/error_generator.rb:327:in `notify'
	1: from /usr/share/gems/gems/rspec-support-3.8.2/lib/rspec/support.rb:106:in `notify_failure'
/usr/share/gems/gems/rspec-support-3.8.2/lib/rspec/support.rb:97:in `block in <module:Support>': #<Double "connection"> received unexpected message :receive with (no args) (RSpec::Mocks::MockExpectationError)
.#<Thread:0x000055a54150bd60@/home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:193 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
	6: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `block in start_listeners'
	5: from /home/straylen/pkgs/rubygem-stomp/stomp-1.4.9/lib/client/utils.rb:194:in `loop'
```

Fixes: stompgem#164
@traylenator traylenator linked a pull request Mar 30, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HepWanted Help Wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants