-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add support for Minitest::SharedExamples #46
Conversation
Could you add shared example test in In order to use shared example do we have to add another gem as dependency or it's just build in minitest gem? Could you also update test in spec/knapsack/adapters/minitest_adapter_spec.rb to cover both context for regular test and shared example. |
It's just build in minitest gem. I will try update the specs. |
@ArturT I'm not so sure about the spec part could you give some guide? I just finished the base line of it. It's like a fake_test that include the |
include Minitest::Spec::DSL | ||
end | ||
|
||
SharedExampleSpec = Minitest::SharedExamples.new do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You defined shared example here. Could you add at the bottom a new describe and include there shared example so we can see if they can be executed and recorded by knapsack (Travis will do that https://github.com/ArturT/knapsack/blob/master/.travis.yml#L62 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked locally executed fine. So I removed the spec in minitest_adapter
You could keep single describe for describe '.test_path' do
subject { described_class.test_path(obj) }
before do
parent_of_test_dir = File.expand_path('../../../', File.dirname(__FILE__))
parent_of_test_dir_regexp = Regexp.new("^#{parent_of_test_dir}")
described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir_regexp)
end
context 'when regular tes' do
class FakeUserTest
def test_user_age; end
# method provided by Minitest
# it returns test method name
def name
:test_user_age
end
end
let(:obj) { FakeUserTest.new }
it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
end
context 'when shared example test' do
class FakeSharedExampleUserTest
# TODO
end
let(:obj) { FakeSharedExampleUserTest.new }
it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
end
end You need to prepare proper FakeSharedExampleUserTest for your case. You could use binding.pry to bind in .test_path method and see what's the structure of the obj in case of shared example (the shared example you added in test_examples directory). You can run tests from that directory with |
@@ -0,0 +1,31 @@ | |||
require 'test_helper' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename this file to shared_examples_test.rb
I noticed you removed your test for |
I added missing spec for minitest adapter https://github.com/ArturT/knapsack/blob/master/spec/knapsack/adapters/minitest_adapter_spec.rb#L129 I've just released knapsack v1.12.0. I also updated pro version gem https://github.com/KnapsackPro/knapsack_pro-ruby ( https://knapsackpro.com ) @dingn1 Thank you for the PR and great work :) |
@ArturT Thanks for your help. |
This is adding support for
Minitest::SharedExamples
. In Minitest we can useSharedExamples
to create extensions inside application, which would make the searching of thetest_method_name
andtest_path
bad. This is adding a new pattern of searching when the old one does not work.