-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #399 from openstax/570-labs-numbered-lists
Bake ordered lists as embedded exercise questions in `computer-science`
- Loading branch information
Showing
7 changed files
with
244 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Kitchen | ||
module Directions | ||
module BakeEmbeddedExerciseQuestion | ||
def self.v1(question:, number:, append_to:) | ||
append_to.append(child: | ||
<<~HTML | ||
<div data-type="exercise"> | ||
<div data-type="problem"> | ||
<span class="os-number">#{number}</span> | ||
<span class="os-divider">. </span> | ||
<div class="os-problem-container">#{question.cut.paste}</div> | ||
</div> | ||
</div> | ||
HTML | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
spec/kitchen_spec/directions/bake_embedded_exercise_question_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Kitchen::Directions::BakeEmbeddedExerciseQuestion do | ||
let(:book_with_question) do | ||
book_containing(html: | ||
one_chapter_with_one_page_containing( | ||
<<~HTML | ||
<section> | ||
<div>Question</div> | ||
</section> | ||
HTML | ||
) | ||
) | ||
end | ||
|
||
context 'when question and number provided' do | ||
it 'bakes' do | ||
section = book_with_question.search('section').first! | ||
question = section.search('div').first! | ||
described_class.v1(question: question, number: 1, append_to: section) | ||
expect(book_with_question.pages.first).to match_snapshot_auto | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...chen_Directions_BakeEmbeddedExerciseQuestion_when_question_and_number_provided_bakes.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div data-type="page" id="testidOne"> | ||
<section> | ||
|
||
<div data-type="exercise"> | ||
<div data-type="problem"> | ||
<span class="os-number">1</span> | ||
<span class="os-divider">. </span> | ||
<div class="os-problem-container"><div>Question</div></div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
</div> |