-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_step.rb
90 lines (70 loc) · 2.26 KB
/
generic_step.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# vim:set fileencoding=utf-8 filetype=ruby:
#
# page オブジェクトに関するステップ
# テスト用ステップ
step %(:textと表示されている) do |text|
expect(page).to have_content(text)
end
step %(:textが:cnt個表示されている) do |text, cnt|
expect(page).to have_content(text, count: cnt)
end
step %(:textと表示されていない) do |text|
expect(page).not_to have_content(text)
end
step %(アクセス表示権限エラーが出ていない) do
expect(page).not_to have_content("リンク先のページを表示する権限がありません")
end
step %(アクセス表示権限エラーが出ていない) do
expect(page).not_to have_content("リンク先のページを表示する権限がありません")
end
step %(CSVファイルが出力される) do
expect(page.response_headers['Content-Type']).to eq 'text/csv'
expect(CSV.parse(page.body)).to be_a(Array)
end
step %(ファイル:filenameがダウンロードされる) do |filename|
expect(page.response_headers['Content-Disposition']).to include(%(filename="#{filename}"))
end
step %(セレクトボックス:selectboxに:itemがある) do |selectbox, item|
expect(page).to have_select(selectbox, with_options: item)
end
# 操作用ステップ
step %(:textリンクをクリックする) do |text|
click_link text
end
step %(:n番目の:textリンクをクリックする) do |n, text|
n = n.to_i - 1
all(:link_or_button, text)[n].click
end
step %(:textボタンをクリックする) do |text|
click_button text
end
step %(:n番目の:textボタンをクリックする) do |n, text|
n = n.to_i - 1
all(:link_or_button, text)[n].click
end
step %(:fieldに:valueを設定する) do |field, value|
fill_in field, with: value
end
step %(:n番目の:fieldに:valueを設定する) do |n, field, value|
fill_in field, with: value
end
step %(:optionオプションの:valueを選択する) do |option, value|
select value, from: option
end
step %(:choiceを選択する) do |choice|
choose choice
end
step %(:choiceをチェックする) do |choice|
check choice
end
step %(:choiceのチェックを外す) do |choice|
uncheck choice
end
# デバッグ用
step %(pryを呼び出す) do
binding.pry
puts ''
end
step %(表示する) do
save_and_open_page
end