Skip to content

Commit

Permalink
customizeable caption for 'link' tag
Browse files Browse the repository at this point in the history
  • Loading branch information
alexch committed Apr 12, 2014
1 parent b9dca72 commit 8889505
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
8 changes: 6 additions & 2 deletions lib/step.rb
Expand Up @@ -99,9 +99,12 @@ def step name = nil, options = {}
end
end

def link name

def link name, options = {}
options = {caption: LINK_CAPTION}.merge(options)
p :class => "link" do
text "Go on to "
text options[:caption]
text " "
simple_link(name, class: :link)
end
end
Expand Down Expand Up @@ -242,6 +245,7 @@ def tip text = nil, &block
IRB_CAPTION = "Type this in irb:"
RESULT_CAPTION = "Expected result:"
FUZZY_RESULT_CAPTION = "Approximate expected result:"
LINK_CAPTION = "Go on to"

def console(commands)
console_with_message(TERMINAL_CAPTION, commands)
Expand Down
39 changes: 20 additions & 19 deletions sites/en/learn-to-code/learn-to-code.step
@@ -1,19 +1,20 @@

link "learn_to_code"
link "computers"
link "objects"
link "strings"
link "numbers"
link "variables"
link "nil"
link "the_command_line"
link "input_and_output"
link "logic"
link "loops"
link "arrays"
link "argv"
link "hashes"
link "functions"
link "sinatra"
link "extra"
link "next_steps"
ul do
li { link "learn_to_code", caption: "" }
li { link "computers", caption: "" }
li { link "objects", caption: "" }
li { link "strings", caption: "" }
li { link "numbers", caption: "" }
li { link "variables", caption: "" }
li { link "nil", caption: "" }
li { link "the_command_line", caption: "" }
li { link "input_and_output", caption: "" }
li { link "logic", caption: "" }
li { link "loops", caption: "" }
li { link "arrays", caption: "" }
li { link "argv", caption: "" }
li { link "hashes", caption: "" }
li { link "functions", caption: "" }
li { link "sinatra", caption: "" }
li { link "extra", caption: "" }
li { link "next_steps", caption: "" }
end
9 changes: 9 additions & 0 deletions spec/step_spec.rb
Expand Up @@ -94,6 +94,15 @@ def step_obj_for(path)
hash = URI.escape '#'
assert { a["href"] == "choose_breakfast?back=hello#{hash}step1" }
end

it "has an optional parameter for the caption" do
html_doc(<<-RUBY)
step "breakfast" do
link "breakfast", caption: "Eat some"
end
RUBY
assert { html_doc.css("p.link").text == "Eat some Breakfast" }
end
end

describe 'source_code' do
Expand Down

0 comments on commit 8889505

Please sign in to comment.