Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Use static exercise README if it is present #76

Merged
merged 1 commit into from
Jul 16, 2017
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
1 change: 1 addition & 0 deletions fixtures/tracks/fake/exercises/two/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom readme for 'two'
7 changes: 6 additions & 1 deletion lib/trackler/implementation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def zip
end

def readme
@readme ||= assemble_readme
@readme ||= static_readme || assemble_readme
end

def git_url
Expand Down Expand Up @@ -84,6 +84,11 @@ def exercise_dir
File.join('exercises', slug)
end

def static_readme
path = File.join(implementation_dir, 'README.md')
return File.read(path) if File.exist?(path)
end

def assemble_readme
<<-README
# #{name}
Expand Down
7 changes: 7 additions & 0 deletions test/trackler/implementation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def test_language
assert_equal expected_language, implementation.language
end

def test_prefer_static_readme_if_present
track = Trackler::Track.new('fake', FIXTURE_PATH)
specification = Trackler::Specification.new('two', FIXTURE_PATH)
implementation = Trackler::Implementation.new(track, specification)
assert_equal "custom readme for 'two'\n", implementation.readme
end

#### DEPRECATION TESTS: HINTS ####
# These can be removed when all tracks have renamed their
# HINTS.md files to .meta/hints.md
Expand Down