-
Notifications
You must be signed in to change notification settings - Fork 15
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
There can be only one gem that calls #before or #after... #24
Comments
The solution is pretty simple. It is just this: module Spec
module SetupAndTeardown
def setup
super
if metadata[:vcr]
options = metadata[:vcr].is_a?(Hash) ? metadata[:vcr] : {}
VCR.insert_cassette StringHelpers.vcr_path(self), options
end
end
def teardown
super
::VCR.eject_cassette if metadata[:vcr]
end
end
def self.configure!
::MiniTest::Spec.send(:include, SetupAndTeardown)
end
end # Spec Can you add this in? |
Sure. You want to open a PR? |
I'm trying to fork and run specs. On 2.4.1 with a clean bundle install rake test gives me 1) Error:
MinitestVcr::Spec::an it with metadata::with a nested example group#test_0002_can supply metadata:
NoMethodError: undefined method `<<' for {:read_timeout=>60, :continue_timeout=>nil, :debug_output=>nil}:Hash
Did you mean? <
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:219:in `writing'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:202:in `write'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/generic_request.rb:334:in `write_header'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/generic_request.rb:127:in `exec'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1444:in `block in transport_request'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1443:in `catch'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1443:in `transport_request'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1416:in `request'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/webmock-1.24.6/lib/webmock/http_lib_adapters/net_http.rb:97:in `block in request'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/webmock-1.24.6/lib/webmock/http_lib_adapters/net_http.rb:110:in `block in request'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:877:in `start'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/webmock-1.24.6/lib/webmock/http_lib_adapters/net_http.rb:109:in `request'
/Users/aryk/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1165:in `get'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/adapter/net_http.rb:78:in `perform_request'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/adapter/net_http.rb:38:in `block in call'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/adapter/net_http.rb:85:in `with_net_http_connection'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/adapter/net_http.rb:33:in `call'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/request/url_encoded.rb:15:in `call'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/rack_builder.rb:139:in `build_response'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/connection.rb:386:in `run_request'
/Users/aryk/.rvm/gems/ruby-2.4.1@minitest-vcr/gems/faraday-0.12.1/lib/faraday/connection.rb:149:in `get'
/Users/aryk/Development/contributions/minitest-vcr/test/minitest-vcr/spec_test.rb:28:in `block (4 levels) in <top (required)>' |
Upgrading webmock fixes it, so going to update it. |
If any of other test helping library calls ::MiniTest::Spec.before or ::MiniTest::Spec.after, the last one called wins. That should not be the case. It makes for really had to track down bugs Fixes mfpiccolo#24
PR submitted. |
Is there any reason why this is coupled to Minitest::Spec and not Minitest::Test? The setup and teardown exist on that class, and I'm not sure why this has to be coupled to Minitest::Spec. Thoughts? |
If any of other test helping library calls ::MiniTest::Spec.before or ::MiniTest::Spec.after, the last one called wins. That should not be the case. It makes for really hard to track down bugs,
Instead we should include a module with super for setup and teardown. All those methods do is redefine setup and teardown but they weren't designed to be used on the top level class.
It was supposed to be used in nested describe where each nesting is its own subclass.
The text was updated successfully, but these errors were encountered: