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

Resolve RSpec::Mocks::OutsideOfExampleError #874

Merged
merged 2 commits into from
Dec 30, 2020

Conversation

abicky
Copy link
Contributor

@abicky abicky commented Dec 12, 2020

This PR resolves RSpec::Mocks::OutsideOfExampleError when spec/async_producer_spec.rb is executed.

Before

% rspec spec/async_producer_spec.rb
Run options: exclude {:functional=>true, :performance=>true, :fuzz=>true}

Kafka::AsyncProducer
  #deliver_messages
    instruments the error after failing to deliver buffered messages
  #shutdown
    delivers buffered messages
    instruments a failure to deliver buffered messages
  #produce
    delivers buffered messages
    retries until configured max_retries
    requires `topic` to be a String

Finished in 0.73698 seconds (files took 0.63537 seconds to load)
6 examples, 0 failures

#<Thread:0x00007fc7ab171c70 /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:162 aborting> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        9: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:162:in `block (2 levels) in ensure_threads_running!'
        8: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:253:in `run'
        7: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:252:in `ensure in run'
        6: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/method_double.rb:64:in `block (2 levels) in define_proxy_method'
        5: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/method_double.rb:77:in `proxy_method_invoked'
        4: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/proxy.rb:214:in `message_received'
        3: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/test_double.rb:75:in `method_missing'
        2: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/test_double.rb:112:in `__mock_proxy'
        1: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/space.rb:11:in `proxy_for'
/Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/space.rb:51:in `raise_lifecycle_message': The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported. (RSpec::Mocks::OutsideOfExampleError)
#<Thread:0x00007fc7ab16a150 /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:162 aborting> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        9: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:162:in `block (2 levels) in ensure_threads_running!'
        8: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:253:in `run'
        7: from /Users/arabiki/ghq/src/github.com/zendesk/ruby-kafka/lib/kafka/async_producer.rb:252:in `ensure in run'
        6: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/method_double.rb:64:in `block (2 levels) in define_proxy_method'
        5: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/method_double.rb:77:in `proxy_method_invoked'
        4: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/proxy.rb:214:in `message_received'
        3: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/test_double.rb:75:in `method_missing'
        2: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/test_double.rb:112:in `__mock_proxy'
        1: from /Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/space.rb:11:in `proxy_for'
/Users/arabiki/.anyenv/envs/rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rspec-mocks-3.9.1/lib/rspec/mocks/space.rb:51:in `raise_lifecycle_message': The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported. (RSpec::Mocks::OutsideOfExampleError)

After

% rspec spec/async_producer_spec.rb
Run options: exclude {:functional=>true, :performance=>true, :fuzz=>true}

Kafka::AsyncProducer
  #deliver_messages
    instruments the error after failing to deliver buffered messages
  #shutdown
    delivers buffered messages
    instruments a failure to deliver buffered messages
  #produce
    delivers buffered messages
    retries until configured max_retries
    requires `topic` to be a String

Finished in 0.73808 seconds (files took 0.70865 seconds to load)
6 examples, 0 failures

Copy link
Contributor

@dasch dasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dasch dasch merged commit 6d80b33 into zendesk:master Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants