Skip to content

Commit 98ea112

Browse files
authored
Merge pull request #611 from Insti/Example_file_location_bugfix
tests: Check in the correct location for the example file.
2 parents 8679661 + ae435ea commit 98ea112

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/tasks/exercise.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def directory
2323
end
2424

2525
def example_file
26-
File.exist?(example_filename) ? example_filename : legacy_example_filename
26+
File.exist?(File.join(directory, example_filename)) ? example_filename : legacy_example_filename
2727
end
2828

2929
def testable_example_file

test/tasks/exercise_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ def test_directory
3131
end
3232

3333
def test_example_file
34-
File.stub(:exist?, true) do
35-
assert_equal '.meta/solutions/name.rb', Exercise.new('name').example_file
34+
mock_exist = Minitest::Mock.new
35+
mock_exist.expect(:call, true, ['exercises/alpha/./.meta/solutions/alpha.rb'])
36+
File.stub(:exist?, mock_exist) do
37+
assert_equal '.meta/solutions/alpha.rb', Exercise.new('alpha').example_file
3638
end
3739
end
3840

0 commit comments

Comments
 (0)