Skip to content

Commit d29d336

Browse files
alexchdshafik
authored andcommitted
customizeable caption for 'link' tag
1 parent b662648 commit d29d336

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

lib/step.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ def step name = nil, options = {}
9999
end
100100
end
101101

102-
def link name
102+
103+
def link name, options = {}
104+
options = {caption: LINK_CAPTION}.merge(options)
103105
p :class => "link" do
104-
text "Go on to "
106+
text options[:caption]
107+
text " "
105108
simple_link(name, class: :link)
106109
end
107110
end
@@ -242,6 +245,7 @@ def tip text = nil, &block
242245
IRB_CAPTION = "Type this in irb:"
243246
RESULT_CAPTION = "Expected result:"
244247
FUZZY_RESULT_CAPTION = "Approximate expected result:"
248+
LINK_CAPTION = "Go on to"
245249

246250
def console(commands)
247251
console_with_message(TERMINAL_CAPTION, commands)
+20-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
2-
link "learn_to_code"
3-
link "computers"
4-
link "objects"
5-
link "strings"
6-
link "numbers"
7-
link "variables"
8-
link "nil"
9-
link "the_command_line"
10-
link "input_and_output"
11-
link "logic"
12-
link "loops"
13-
link "arrays"
14-
link "argv"
15-
link "hashes"
16-
link "functions"
17-
link "sinatra"
18-
link "extra"
19-
link "next_steps"
1+
ul do
2+
li { link "learn_to_code", caption: "" }
3+
li { link "computers", caption: "" }
4+
li { link "objects", caption: "" }
5+
li { link "strings", caption: "" }
6+
li { link "numbers", caption: "" }
7+
li { link "variables", caption: "" }
8+
li { link "nil", caption: "" }
9+
li { link "the_command_line", caption: "" }
10+
li { link "input_and_output", caption: "" }
11+
li { link "logic", caption: "" }
12+
li { link "loops", caption: "" }
13+
li { link "arrays", caption: "" }
14+
li { link "argv", caption: "" }
15+
li { link "hashes", caption: "" }
16+
li { link "functions", caption: "" }
17+
li { link "sinatra", caption: "" }
18+
li { link "extra", caption: "" }
19+
li { link "next_steps", caption: "" }
20+
end

spec/step_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ def step_obj_for(path)
9494
hash = URI.escape '#'
9595
assert { a["href"] == "choose_breakfast?back=hello#{hash}step1" }
9696
end
97+
98+
it "has an optional parameter for the caption" do
99+
html_doc(<<-RUBY)
100+
step "breakfast" do
101+
link "breakfast", caption: "Eat some"
102+
end
103+
RUBY
104+
assert { html_doc.css("p.link").text == "Eat some Breakfast" }
105+
end
97106
end
98107

99108
describe 'source_code' do

0 commit comments

Comments
 (0)