Skip to content

Commit 11acf48

Browse files
committed
Merge pull request #37 from kitcheck/shoulda_context_support
Adds support for the shoulda-context gem
2 parents 4a05730 + e61df78 commit 11acf48

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/knapsack/adapters/minitest_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def set_test_helper_path(file_path)
4848

4949
def self.test_path(obj)
5050
# Pick the first public method in the class itself, that starts with "test_"
51-
test_method_name = obj.public_methods(false).select{|m| m =~ /^test_/ }.first
51+
test_method_name = obj.public_methods(false).select{|m| m =~ /^test(:|_)/ }.first
5252
method_object = obj.method(test_method_name)
5353
full_test_path = method_object.source_location.first
5454
parent_of_test_dir_regexp = Regexp.new("^#{@@parent_of_test_dir}")

spec/knapsack/adapters/minitest_adapter_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,26 @@ def name
122122

123123
it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
124124
end
125+
126+
describe 'shoulda context installed' do
127+
class FakeUserTest
128+
def test_user_age; end
129+
130+
def name
131+
"test_: on delete qqq should allow us to make another portfolio for that user. "
132+
end
133+
end
134+
135+
let(:obj) { FakeUserTest.new }
136+
137+
subject { described_class.test_path(obj) }
138+
139+
before do
140+
parent_of_test_dir = File.expand_path('../../../', File.dirname(__FILE__))
141+
parent_of_test_dir_regexp = Regexp.new("^#{parent_of_test_dir}")
142+
described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir_regexp)
143+
end
144+
145+
it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
146+
end
125147
end

0 commit comments

Comments
 (0)