Add support for Minitest::SharedExamples#46
Add support for Minitest::SharedExamples#46ArturT merged 10 commits intoKnapsackPro:masterfrom dingn1:master
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.
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.
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
endYou 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.
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 useSharedExamplesto create extensions inside application, which would make the searching of thetest_method_nameandtest_pathbad. This is adding a new pattern of searching when the old one does not work.