Feature: Automatically skip steps with missing attachTo elements, resolves #6

This commit is contained in:
Jonathan Abbett 2017-01-05 13:43:48 -05:00
parent eac8e10471
commit 5aba3471fe
8 changed files with 24 additions and 1 deletions

4
.gitignore vendored
View File

@ -3,8 +3,12 @@ capybara-*.html
.rspec .rspec
/log /log
/tmp /tmp
/test/dummy/log
/test/dummy/tmp
/db/*.sqlite3 /db/*.sqlite3
/db/*.sqlite3-journal /db/*.sqlite3-journal
/test/dummy/db/*.sqlite3
/test/dummy/db/*.sqlite3-journal
/public/system /public/system
/coverage/ /coverage/
/spec/tmp /spec/tmp

View File

@ -32,6 +32,10 @@
text: "<%= step['text'] %>", text: "<%= step['text'] %>",
<% if step.key?('attachTo') %> <% if step.key?('attachTo') %>
attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" }, attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
showOn: function() {
// Only display this step if its selector is present
return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
},
<% end %> <% end %>
buttons: [ buttons: [
<% if index == 0 %> <% if index == 0 %>

View File

@ -1,4 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module Abraham module Abraham
VERSION = '1.1.1' VERSION = '1.2'
end end

View File

@ -6,6 +6,12 @@ intro:
title: "ENGLISH This step has a title" title: "ENGLISH This step has a title"
text: "ENGLISH This intermediate step has some text" text: "ENGLISH This intermediate step has some text"
3: 3:
title: "ENGLISH A missing step"
text: "ENGLISH Refers to an element that won't exist on the page, should skip to 4"
attachTo:
element: "#i-dont-exist"
position: "right"
4:
title: "ENGLISH The final step" title: "ENGLISH The final step"
text: "ENGLISH Some text here too, and it's attached to the right" text: "ENGLISH Some text here too, and it's attached to the right"
attachTo: attachTo:

View File

@ -6,6 +6,12 @@ intro:
title: "SPANISH This step has a title" title: "SPANISH This step has a title"
text: "This intermediate step has some text" text: "This intermediate step has some text"
3: 3:
title: "SPANISH A missing step"
text: "Refers to an element that won't exist on the page, should skip to 4"
attachTo:
element: "#i-dont-exist"
position: "right"
4:
title: "SPANISH The final step" title: "SPANISH The final step"
text: "Some text here too, and it's attached to the right" text: "Some text here too, and it's attached to the right"
attachTo: attachTo:

Binary file not shown.

Binary file not shown.

View File

@ -31,6 +31,9 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
assert element.text.include? 'step-1' assert element.text.include? 'step-1'
assert element.text.include? 'step-2' assert element.text.include? 'step-2'
assert element.text.include? 'step-3' assert element.text.include? 'step-3'
assert element.text.include? 'step-4'
# Generates a showOn option
assert element.text.include? 'showOn:'
# it will post the right completion information # it will post the right completion information
assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "controller_name: 'dashboard'"
assert element.text.include? "action_name: 'home'" assert element.text.include? "action_name: 'home'"