Top Level Namespace
Defined Under Namespace
Modules: CucumberScaffold
Instance Method Summary
collapse
Instance Method Details
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/generators/cucumber_scaffold/install/templates/step_definitions/web_steps_additional.rb', line 26
def form_field_for_label(label)
input_tags = label.parent.css('input,textarea')
return if input_tags.size == 0
input_tag = input_tags.last
if input_tags.size > 1 && input_tag['type'] != 'checkbox'
raise "Wrong number of input tags while parsing form (found #{input_tags.size})"
end
if input_tag.name == 'textarea'
input_tag.inner_html
elsif input_tag.name == 'input'
if input_tag['type'] == 'checkbox'
input_tag['checked'] == 'checked' ? '[x]' : '[ ]'
else
input_tag['value']
end
end
end
|
#replace_spaces_with_underscores_in_keys(hashes) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/generators/cucumber_scaffold/install/templates/support/table_helpers.rb', line 1
def replace_spaces_with_underscores_in_keys(hashes)
if hashes.class == Hash
result = {}
hashes.each_pair do |key, value|
new_key = key.gsub(' ', '_')
result[new_key] = value
end
else
result = []
hashes.each do |record|
result << {}
record.each_pair do |key, value|
new_key = key.gsub(' ', '_')
result.last[new_key] = value
end
end
end
result
end
|