Top Level Namespace
Defined Under Namespace
Modules: Doop, DoopHelper
Classes: DemoController, DoopgovukGenerator
Instance Method Summary
collapse
Instance Method Details
#answer_question(q_title) {|block| ... } ⇒ Object
42
43
44
45
46
47
|
# File 'lib/doop-rspec.rb', line 42
def answer_question q_title, &block
@q_title = q_title
expect( question q_title ).to be_asked
yield block
page.find_by_id( "#{q_title}-closed" )
end
|
#b_fill_in(options = {}) ⇒ Object
73
74
75
76
77
|
# File 'lib/doop-rspec.rb', line 73
def b_fill_in options = {}
options.keys.each do |key|
page.fill_in( "b_#{key}", :with => options[key] )
end
end
|
61
62
63
|
# File 'lib/doop-rspec.rb', line 61
def change_answer_tooltip
"#{@q_title}-change-answer-tooltip"
end
|
53
54
55
|
# File 'lib/doop-rspec.rb', line 53
def change_answer_tooltip_for q_id
"#{q_id}-change-answer-tooltip"
end
|
#change_page(page_name) ⇒ Object
79
80
81
82
|
# File 'lib/doop-rspec.rb', line 79
def change_page page_name
page.find_by_id( "#{page_name}-nav" ).click
wait_for_page page_name
end
|
#change_question(q_title) {|block| ... } ⇒ Object
35
36
37
38
39
40
|
# File 'lib/doop-rspec.rb', line 35
def change_question q_title, &block
@q_title = q_title
page.find_by_id( "#{q_title}-change" ).click
expect( question q_title ).to be_asked
yield block
end
|
271
272
273
274
275
276
277
278
|
# File 'lib/generators/doopgovuk/templates/app/controllers/demo_controller.rb', line 271
def format_date d
begin
return nil if d.length != 10
Date.strptime( d, "%d/%m/%Y" ).strftime( "%-d %B %Y" )
rescue
nil
end
end
|
#is_number(num) ⇒ Object
294
295
296
|
# File 'lib/generators/doopgovuk/templates/app/controllers/demo_controller.rb', line 294
def is_number num
num =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
end
|
#page_title ⇒ Object
69
70
71
|
# File 'lib/doop-rspec.rb', line 69
def page_title
page.find_by_id( "page_title").text
end
|
#question(text) ⇒ Object
31
32
33
|
# File 'lib/doop-rspec.rb', line 31
def question text
text
end
|
#rollup_text ⇒ Object
49
50
51
|
# File 'lib/doop-rspec.rb', line 49
def rollup_text
page.find_by_id( "#{@q_title}-change" ).text
end
|
57
58
59
|
# File 'lib/doop-rspec.rb', line 57
def tooltip
"#{@q_title}-tooltip"
end
|
#validate(answer, fields = nil) ⇒ Object
280
281
282
283
284
285
286
287
288
289
290
291
292
|
# File 'lib/generators/doopgovuk/templates/app/controllers/demo_controller.rb', line 280
def validate answer,fields=nil
res = {}
if fields == nil
res["answer_error".to_sym] = "Can not be empty" if answer.squish.empty?
return res
end
fields.each do |f|
res["#{f}_error".to_sym] = "Can not be empty" if answer[f].squish.empty?
end
res
end
|
#wait_for_page(p_title) ⇒ Object
65
66
67
|
# File 'lib/doop-rspec.rb', line 65
def wait_for_page p_title
page.find_by_id( "#{p_title}-page" )
end
|