Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Unreleased

### 9.2.1

* Minitest: Fix for `Minitest::Spec` with oneword dynamic classes (`describe "oneword"`) (https://github.com/KnapsackPro/knapsack_pro-ruby/pull/324).

### 9.2.0

* RSpec: Allow initializing the test queue for Queue Mode with `rake knapsack_pro:queue:rspec:initialize` (https://github.com/KnapsackPro/knapsack_pro-ruby/pull/322).
Expand Down
13 changes: 8 additions & 5 deletions lib/knapsack_pro/adapters/minitest_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ def self.test_path(obj)
path, _line =
begin
Object.const_source_location(obj.class.to_s)
rescue NameError
test_method_name = obj.class.runnable_methods.first
obj.method(test_method_name).source_location
rescue NameError # Dynamically defined class (Minitest::Spec `describe "more words"`)
nil
end

if path.nil? # Dynamically defined class (Minitest::Spec `describe "oneword"`)
test_method_name = obj.class.runnable_methods.first
path, _line = obj.method(test_method_name).source_location
end

path.gsub(Regexp.new("^#{@@parent_of_test_dir}"), '.')
end

# See how to write hooks and plugins
# https://github.com/seattlerb/minitest/blob/master/lib/minitest/test.rb
module BindTimeTrackerMinitestPlugin
def before_setup
super
Expand Down
2 changes: 1 addition & 1 deletion rails-app-with-knapsack_pro/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ GIT
PATH
remote: ..
specs:
knapsack_pro (9.1.0)
knapsack_pro (9.2.0)
rake

GEM
Expand Down
35 changes: 0 additions & 35 deletions rails-app-with-knapsack_pro/test/minitest/meme_spec_test.rb

This file was deleted.

35 changes: 35 additions & 0 deletions rails-app-with-knapsack_pro/test/minitest/minitest_spec_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "test_helper"

class MinitestSpecTest < ActiveSupport::TestCase
describe "oneword" do
it "works" do
_(1).must_equal 1
end
end

describe "two words" do
it "really works" do
_(1).must_equal 1
end
end

context "with nested" do
describe "described in context" do
it "works" do
_(1).must_equal 1
end
end
end

describe "with nested" do
context "context in describe" do
it "works" do
_(1).must_equal 1
end
end
end

it "top level it" do
_(1).must_equal 1
end
end