cucumber-rails 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/History.md +8 -1
- data/Rakefile +4 -2
- data/cucumber-rails.gemspec +17 -17
- data/features/allow_rescue.feature +1 -1
- data/features/capybara_javascript_drivers.feature +1 -1
- data/features/choose_javascript_database_strategy.feature +63 -0
- data/features/database_cleaner.feature +1 -1
- data/features/emulate_javascript.feature +2 -2
- data/features/field_with_errors.feature +2 -2
- data/features/fixing_bundler_pre.feature +1 -1
- data/features/inspect_query_string.feature +1 -1
- data/features/install_cucumber_rails.feature +1 -1
- data/features/multiple_databases.feature +1 -1
- data/features/no_database.feature +1 -1
- data/features/rerun_profile.feature +1 -1
- data/features/rest_api.feature +1 -1
- data/features/routing.feature +1 -1
- data/features/step_definitions/cucumber_rails_steps.rb +52 -398
- data/features/support/bundler_pre_support.rb +28 -0
- data/features/support/env.rb +1 -4
- data/features/support/fixtures/bundler-1.0.21.gem +0 -0
- data/features/support/fixtures/bundler-1.1.rc.gem +0 -0
- data/{lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb → features/support/legacy_web_steps_support.rb} +69 -14
- data/lib/cucumber/rails.rb +1 -1
- data/lib/cucumber/rails/database.rb +67 -0
- data/lib/cucumber/rails/hooks/active_record.rb +2 -12
- data/lib/generators/cucumber/install/USAGE +0 -3
- data/lib/generators/cucumber/install/templates/support/_rails_each_run.rb.erb +6 -1
- metadata +79 -88
- data/Gemfile.lock +0 -202
- data/features/test_unit.feature +0 -45
- data/lib/cucumber/web/tableish.rb +0 -119
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_cs.rb.erb +0 -127
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_da.rb.erb +0 -105
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_de.rb.erb +0 -127
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_es.rb.erb +0 -127
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ja.rb.erb +0 -140
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_ko.rb.erb +0 -142
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_no.rb.erb +0 -105
- data/lib/generators/cucumber/install/templates/step_definitions/web_steps_pt-BR.rb.erb +0 -132
- data/spec/cucumber/web/tableish_spec.rb +0 -239
@@ -1,142 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
<%= embed_file('support/web_steps_warning.txt') %>
|
3
|
-
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
6
|
-
|
7
|
-
조건 /^(.+)페이지에 있습니다$/ do |page_name|
|
8
|
-
Given %{I am on #{page_name}}
|
9
|
-
end
|
10
|
-
|
11
|
-
만일 /^(.+)페이지로 갑니다$/ do |page_name|
|
12
|
-
When %{I go to #{page_name}}
|
13
|
-
end
|
14
|
-
|
15
|
-
만일 /^"([^"]*)"버튼을 누릅니다$/ do |button|
|
16
|
-
When %{I press "#{button}"}
|
17
|
-
end
|
18
|
-
|
19
|
-
만일 /^"([^"]*)"링크를 클릭합니다$/ do |link|
|
20
|
-
When %{I follow "#{link}"}
|
21
|
-
end
|
22
|
-
|
23
|
-
만일 /^"([^"]*)"안에 있는 "([^"]*)"링크를 클릭합니다$/ do |parent, link|
|
24
|
-
When %{I follow "#{link}" within "#{parent}"}
|
25
|
-
end
|
26
|
-
|
27
|
-
만일 /^"([^"]*)"에 "([^"]*)"라고 적습니다$/ do |field, value|
|
28
|
-
When %{I fill in "#{field}" with "#{value}"}
|
29
|
-
end
|
30
|
-
|
31
|
-
만일 /^"([^"]*)"라고 "([^"]*)"에 적습니다$/ do |value, field|
|
32
|
-
When %{I fill in "#{value}" for "#{field}"}
|
33
|
-
end
|
34
|
-
|
35
|
-
만일 /^아레의 목록을 입력합니다$/ do |fields|
|
36
|
-
When %{I fill in the following:}, fields
|
37
|
-
end
|
38
|
-
|
39
|
-
만일 /^"([^"]*)"를 "([^"]*)"으로 합니다$/ do |field, value|
|
40
|
-
When %{I select "#{value}" from "#{field}"}
|
41
|
-
end
|
42
|
-
|
43
|
-
만일 /^날짜와 시간를 "([^"]*)"으로 합니다$/ do |time|
|
44
|
-
When %{I select "#{time}" as the date and time}
|
45
|
-
end
|
46
|
-
|
47
|
-
만일 /^"([^"]*)"의 날짜와 시간을 "([^"]*)"으로 합니다$/ do |datetime_label, datetime|
|
48
|
-
When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
|
49
|
-
end
|
50
|
-
|
51
|
-
만일 /^시간을 "([^"]*)"으로 합니다$/ do |time|
|
52
|
-
When %{I select "#{time}" as the time}
|
53
|
-
end
|
54
|
-
|
55
|
-
만일 /^"([^"]*)"의 시간을 "([^"]*)"으로 합니다$/ do |time_label, time|
|
56
|
-
When %{I select "#{time}" as the "#{time_label}" time}
|
57
|
-
end
|
58
|
-
|
59
|
-
만일 /^날짜를 "([^"]*)"으로 합니다$/ do |date|
|
60
|
-
When %{I select "#{date}" as the date}
|
61
|
-
end
|
62
|
-
|
63
|
-
만일 /^"([^"]*)"의 날짜를 "([^"]*)"으로 합니다$/ do |date_label, date|
|
64
|
-
When %{I select "#{date}" as the "#{date_label}" date}
|
65
|
-
end
|
66
|
-
|
67
|
-
만일 /^"([^"]*)"를 체크합니다$/ do |field|
|
68
|
-
When %{I check "#{field}"}
|
69
|
-
end
|
70
|
-
|
71
|
-
만일 /^"([^"]*)"의 체크를 해제합니다$/ do |field|
|
72
|
-
When %{I uncheck "#{field}"}
|
73
|
-
end
|
74
|
-
|
75
|
-
만일 /^"([^"]*)"를 고릅니다$/ do |field|
|
76
|
-
When %{I choose "#{field}"}
|
77
|
-
end
|
78
|
-
|
79
|
-
만일 /^"([^"]*)"에 "([^"]*)"파일을 첨부합니다$/ do |field, path|
|
80
|
-
When %{I attach the file "#{path}" to "#{field}"}
|
81
|
-
end
|
82
|
-
|
83
|
-
그러면 /^"([^"]*)"가 보여야 합니다$/ do |text|
|
84
|
-
Then %{I should see "#{text}"}
|
85
|
-
end
|
86
|
-
|
87
|
-
그러면 /^"([^"]*)"안에 "([^"]*)"가 보여야 합니다$/ do |selector, text|
|
88
|
-
Then %{I should see "#{text}" within "#{selector}"}
|
89
|
-
end
|
90
|
-
|
91
|
-
그러면 /^\/([^\/]*)\/가 보여야 합니다$/ do |regexp|
|
92
|
-
Then %{I should see /#{regexp}/}
|
93
|
-
end
|
94
|
-
|
95
|
-
그러면 /^"([^"]*)"안에 \/([^\/]*)\/가 보여야 합니다$/ do |selector, regexp|
|
96
|
-
Then %{I should see /#{regexp}/ within "#{selector}"}
|
97
|
-
end
|
98
|
-
|
99
|
-
그러면 /^"([^"]*)"가 보이면 안됩니다$/ do |text|
|
100
|
-
Then %{I should not see "#{text}"}
|
101
|
-
end
|
102
|
-
|
103
|
-
그러면 /^"([^"]*)"안에 "([^"]*)"가 보이면 안됩니다$/ do |selector, text|
|
104
|
-
Then %{I should not see "#{text}" within "#{selector}"}
|
105
|
-
end
|
106
|
-
|
107
|
-
그러면 /^\/([^\/]*)\/가 보이면 안됩니다$/ do |regexp|
|
108
|
-
Then %{I should not see /#{regexp}/}
|
109
|
-
end
|
110
|
-
|
111
|
-
그러면 /^"([^"]*)"안에 \/([^\/]*)\/가 보이면 안됩니다$/ do |selector, regexp|
|
112
|
-
Then %{I should not see /#{regexp}/ within "#{selector}"}
|
113
|
-
end
|
114
|
-
|
115
|
-
그러면 /^"([^"]*)"는 "([^"]*)"이어야 합니다$/ do |field, value|
|
116
|
-
Then %{the "#{field}" field should contain "#{value}"}
|
117
|
-
end
|
118
|
-
|
119
|
-
그러면 /^"([^"]*)"는 "([^"]*)"이면 안됩니다$/ do |field, value|
|
120
|
-
Then %{the "#{field}" field should not contain "#{value}"}
|
121
|
-
end
|
122
|
-
|
123
|
-
그러면 /^"([^"]*)"는 체크되어 있어야 합니다$/ do |label|
|
124
|
-
Then %{the "#{label}" checkbox should be checked}
|
125
|
-
end
|
126
|
-
|
127
|
-
그러면 /^"([^"]*)"는 체크되어 있으면 안됩니다$/ do |label|
|
128
|
-
Then %{the "#{label}" checkbox should not be checked}
|
129
|
-
end
|
130
|
-
|
131
|
-
그러면 /^(.+)에 있어야 합니다$/ do |page_name|
|
132
|
-
Then %{I should be on #{page_name}}
|
133
|
-
end
|
134
|
-
|
135
|
-
그러면 /^다음 쿼리들이 나와야합니다:$/ do |expected_pairs|
|
136
|
-
Then %{I should have the following query string:}
|
137
|
-
end
|
138
|
-
|
139
|
-
그러면 /^페이지를 엽니다$/ do
|
140
|
-
Then %{show me the page}
|
141
|
-
end
|
142
|
-
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
<%= embed_file('support/web_steps_warning.txt') %>
|
3
|
-
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
6
|
-
|
7
|
-
# Single-line step scoper
|
8
|
-
Når /^(.*) under ([^:]+)$/ do |step, parent|
|
9
|
-
with_scope(parent) { Når step }
|
10
|
-
end
|
11
|
-
|
12
|
-
# Multi-line step scoper
|
13
|
-
Når /^(.*) under ([^:]+):$/ do |step, parent, table_or_string|
|
14
|
-
with_scope(parent) { Når "#{step}:", table_or_string }
|
15
|
-
end
|
16
|
-
|
17
|
-
Gitt /^(?:|at )jeg står på (.*)$/ do |page_name|
|
18
|
-
Given %{I am on #{page_name}}
|
19
|
-
end
|
20
|
-
|
21
|
-
Når /^jeg går til (.*)$/ do |page_name|
|
22
|
-
When %{I go to #{page_name}}
|
23
|
-
end
|
24
|
-
|
25
|
-
Når /^jeg trykker "([^"]*)"$/ do |button|
|
26
|
-
When %{I press "#{button}"}
|
27
|
-
end
|
28
|
-
|
29
|
-
Når /^jeg klikker "([^"]*)"$/ do |link|
|
30
|
-
When %{I follow "#{link}"}
|
31
|
-
end
|
32
|
-
|
33
|
-
Når /^jeg fyller inn "([^"]*)" med "([^"]*)"$/ do |field, value|
|
34
|
-
When %{I fill in "#{field}" with "#{value}"}
|
35
|
-
end
|
36
|
-
|
37
|
-
Når /^jeg fyller inn "([^"]*)" for "([^"]*)"$/ do |value, field|
|
38
|
-
When %{I fill in "#{value}" for "#{field}"}
|
39
|
-
end
|
40
|
-
|
41
|
-
Når /^jeg fyller inn følgende:$/ do |fields|
|
42
|
-
When %{I fill in the following:}, fields
|
43
|
-
end
|
44
|
-
|
45
|
-
Når /^jeg velger "([^"]*)" fra "([^"]*)"$/ do |value, field|
|
46
|
-
When %{I select "#{value}" from "#{field}"}
|
47
|
-
end
|
48
|
-
|
49
|
-
# Missing: date stuff
|
50
|
-
|
51
|
-
Når /^jeg krysser av "([^"]*)"$/ do |field|
|
52
|
-
When %{I check "#{field}"}
|
53
|
-
end
|
54
|
-
|
55
|
-
Når /^jeg fjerner avkrysning for "([^"]*)"$/ do |field|
|
56
|
-
When %{I uncheck "#{field}"}
|
57
|
-
end
|
58
|
-
|
59
|
-
Når /^jeg velger "([^"]*)"$/ do |field|
|
60
|
-
When %{I choose "#{field}"}
|
61
|
-
end
|
62
|
-
|
63
|
-
Når /^jeg legger ved filen "([^"]*)" til "([^"]*)"$/ do |path, field|
|
64
|
-
When %{I attach the file "#{path}" to "#{field}"}
|
65
|
-
end
|
66
|
-
|
67
|
-
Så /^(?:skal jeg|jeg skal) se "([^"]*)"$/ do |text|
|
68
|
-
Then %{I should see "#{text}"}
|
69
|
-
end
|
70
|
-
|
71
|
-
Så /^(?:skal jeg|jeg skal) se \/([^\/]*)\/$/ do |regexp|
|
72
|
-
Then %{I should see /#{regexp}/}
|
73
|
-
end
|
74
|
-
|
75
|
-
Så /^(?:skal jeg|jeg skal) ikke se "([^"]*)"$/ do |text|
|
76
|
-
Then %{I should not see "#{text}"}
|
77
|
-
end
|
78
|
-
|
79
|
-
Så /^(?:skal jeg|jeg skal) ikke se \/([^\/]*)\/$/ do |regexp|
|
80
|
-
Then %{I should not see /#{regexp}/}
|
81
|
-
end
|
82
|
-
|
83
|
-
Så /^(?:skal )"([^"]*)" feltet (?:skal )inneholde "([^"]*)"$/ do |field, value|
|
84
|
-
Then %{the "#{field}" field should contain "#{value}"}
|
85
|
-
end
|
86
|
-
|
87
|
-
Så /^(?:skal ) "([^"]*)" feltet (?:skal )ikke inneholde "([^"]*)"$/ do |field, value|
|
88
|
-
Then %{the "#{field}" field should not contain "#{value}"}
|
89
|
-
end
|
90
|
-
|
91
|
-
Så /^(?:skal ) "([^"]*)" avkrysningsboksen (?:skal )være krysset av$/ do |label|
|
92
|
-
Then %{the "#{label}" checkbox should be checked}
|
93
|
-
end
|
94
|
-
|
95
|
-
Så /^(?:skal ) "([^"]*)" avkrysningsboksen (?:skal )ikke være krysset av$/ do |label|
|
96
|
-
Then %{the "#{label}" checkbox should not be checked}
|
97
|
-
end
|
98
|
-
|
99
|
-
Så /^(?:skal jeg|jeg skal) komme til (.+)$/ do |page_name|
|
100
|
-
Then %{I should be on #{page_name}}
|
101
|
-
end
|
102
|
-
|
103
|
-
Så /^vil jeg se siden$/ do |page_name|
|
104
|
-
Then %{show me the page}
|
105
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
<%= embed_file('support/web_steps_warning.txt') %>
|
3
|
-
|
4
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
6
|
-
|
7
|
-
# Single-line step scoper
|
8
|
-
Quando /^(.*) dentro de ([^:]+)$/ do |step, parent|
|
9
|
-
with_scope(parent) { Quando step }
|
10
|
-
end
|
11
|
-
|
12
|
-
# Multi-line step scoper
|
13
|
-
Quando /^(.*) dentro de ([^:]+):$/ do |step, parent, table_or_string|
|
14
|
-
with_scope(parent) { Quando "#{step}:", table_or_string }
|
15
|
-
end
|
16
|
-
|
17
|
-
Dado /^que eu estou na (.+)$/ do |page_name|
|
18
|
-
Given %{I am on #{page_name}}
|
19
|
-
end
|
20
|
-
|
21
|
-
Quando /^eu vou para (.+)$/ do |page_name|
|
22
|
-
When %{I go to #{page_name}}
|
23
|
-
end
|
24
|
-
|
25
|
-
Quando /^eu aperto "([^"]*)"$/ do |button|
|
26
|
-
When %{I press "#{button}"}
|
27
|
-
end
|
28
|
-
|
29
|
-
Quando /^eu clico "([^"]*)"$/ do |link|
|
30
|
-
When %{I follow "#{link}"}
|
31
|
-
end
|
32
|
-
|
33
|
-
Quando /^eu preencho "([^"]*)" com "([^"]*)"$/ do |field, value|
|
34
|
-
When %{I fill in "#{field}" with "#{value}"}
|
35
|
-
end
|
36
|
-
|
37
|
-
Quando /^eu preencho "([^"]*)" para "([^"]*)"$/ do |value, field|
|
38
|
-
When %{I fill in "#{value}" for "#{field}"}
|
39
|
-
end
|
40
|
-
|
41
|
-
Quando /^eu preencho o seguinte:$/ do |fields|
|
42
|
-
When %{I fill in the following:}, fields
|
43
|
-
end
|
44
|
-
|
45
|
-
Quando /^eu seleciono "([^"]*)" de "([^"]*)"$/ do |value, field|
|
46
|
-
When %{I select "#{value}" from "#{field}"}
|
47
|
-
end
|
48
|
-
|
49
|
-
Quando /^eu seleciono "([^"]*)" como a data e a hora$/ do |time|
|
50
|
-
When %{I select "#{time}" as the date and time}
|
51
|
-
end
|
52
|
-
|
53
|
-
Quando /^eu seleciono "([^"]*)" como a data e a hora "([^"]*)"$/ do |datetime, datetime_label|
|
54
|
-
When %{I select "#{datetime}" as the "#{datetime_label}" date and time}
|
55
|
-
end
|
56
|
-
|
57
|
-
Quando /^eu seleciono "([^"]*)" como a hora$/ do |time|
|
58
|
-
When %{I select "#{time}" as the time}
|
59
|
-
end
|
60
|
-
|
61
|
-
Quando /^eu seleciono "([^"]*)" como a hora "([^"]*)"$/ do |time, time_label|
|
62
|
-
When %{I select "#{time}" as the "#{time_label}" time}
|
63
|
-
end
|
64
|
-
|
65
|
-
Quando /^eu seleciono "([^"]*)" como a data$/ do |date|
|
66
|
-
When %{I select "#{date}" as the date}
|
67
|
-
end
|
68
|
-
|
69
|
-
Quando /^eu seleciono "([^"]*)" como a data "([^"]*)"$/ do |date, date_label|
|
70
|
-
When %{I select "#{date}" as the "#{date_label}" date}
|
71
|
-
end
|
72
|
-
|
73
|
-
Quando /^eu seleciono "([^"]*)" como "([^"]*)"$/ do |date, date_label|
|
74
|
-
When %{I select "#{date}" as the "#{date_label}" date}
|
75
|
-
end
|
76
|
-
|
77
|
-
Quando /^eu marco "([^"]*)"$/ do |field|
|
78
|
-
When %{I check "#{field}"}
|
79
|
-
end
|
80
|
-
|
81
|
-
Quando /^eu desmarco "([^"]*)"$/ do |field|
|
82
|
-
When %{I uncheck "#{field}"}
|
83
|
-
end
|
84
|
-
|
85
|
-
Quando /^eu escolho "([^"]*)"$/ do |field|
|
86
|
-
When %{I choose "#{field}"}
|
87
|
-
end
|
88
|
-
|
89
|
-
Quando /^eu anexo o arquivo em "([^"]*)" a "([^"]*)"$/ do |path, field|
|
90
|
-
When %{I attach the file "#{path}" to "#{field}"}
|
91
|
-
end
|
92
|
-
|
93
|
-
Então /^eu devo ver "([^"]*)"$/ do |text|
|
94
|
-
Then %{I should see "#{text}"}
|
95
|
-
end
|
96
|
-
|
97
|
-
Então /^eu devo ver \/([^\/]*)\/$/ do |regexp|
|
98
|
-
Then %{I should see /#{regexp}/}
|
99
|
-
end
|
100
|
-
|
101
|
-
Então /^eu não devo ver "([^"]*)"$/ do |text|
|
102
|
-
Then %{I should not see "#{text}"}
|
103
|
-
end
|
104
|
-
|
105
|
-
Então /^eu não devo ver \/([^\/]*)\/$/ do |regexp|
|
106
|
-
Then %{I should not see /#{regexp}/}
|
107
|
-
end
|
108
|
-
|
109
|
-
Então /^o campo "([^"]*)" deve conter "([^"]*)"$/ do |field, value|
|
110
|
-
Then %{the "#{field}" field should contain "#{value}"}
|
111
|
-
end
|
112
|
-
|
113
|
-
Então /^o campo "([^"]*)" não deve conter "([^"]*)"$/ do |field, value|
|
114
|
-
Then %{the "#{field}" field should not contain "#{value}"}
|
115
|
-
end
|
116
|
-
|
117
|
-
Então /^o checkbox "([^"]*)" deve estar marcado$/ do |label|
|
118
|
-
Then %{the "#{label}" checkbox should be checked}
|
119
|
-
end
|
120
|
-
|
121
|
-
Então /^o checkbox "([^"]*)" não deve estar marcado$/ do |label|
|
122
|
-
Then %{the "#{label}" checkbox should not be checked}
|
123
|
-
end
|
124
|
-
|
125
|
-
Então /^eu devo estar na (.+)$/ do |page_name|
|
126
|
-
Then %{I should be on #{page_name}}
|
127
|
-
end
|
128
|
-
|
129
|
-
Então /^mostre-me a página$/ do
|
130
|
-
Then %{show me the page}
|
131
|
-
end
|
132
|
-
|
@@ -1,239 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
4
|
-
|
5
|
-
def World(*a); end
|
6
|
-
require 'cucumber/web/tableish'
|
7
|
-
|
8
|
-
module Cucumber
|
9
|
-
module Web
|
10
|
-
describe Tableish do
|
11
|
-
include Tableish
|
12
|
-
|
13
|
-
unless RUBY_PLATFORM =~ /java/
|
14
|
-
it "should convert a table" do
|
15
|
-
html = <<-HTML
|
16
|
-
<div class="admin-table">
|
17
|
-
<table>
|
18
|
-
<thead>
|
19
|
-
<tr>
|
20
|
-
<th>Name</th>
|
21
|
-
<th><span>Edit</span></th>
|
22
|
-
<th><span>Delete</span></th>
|
23
|
-
</tr>
|
24
|
-
</thead>
|
25
|
-
<tbody>
|
26
|
-
<tr>
|
27
|
-
<td><strong>Guybrush Threepwood</strong></td>
|
28
|
-
<td><a href="/users/1/edit">Edit</a></td>
|
29
|
-
<td>
|
30
|
-
<form method="post" action="/users/1" class="button-to">
|
31
|
-
<div>
|
32
|
-
<input type="hidden" name="_method" value="delete" />
|
33
|
-
<input value="Delete" type="submit" />
|
34
|
-
</div>
|
35
|
-
</form>
|
36
|
-
</td>
|
37
|
-
</tr>
|
38
|
-
</tbody>
|
39
|
-
</table>
|
40
|
-
</div>
|
41
|
-
HTML
|
42
|
-
|
43
|
-
header = _tableish(html, '.admin-table table thead tr', 'th')
|
44
|
-
|
45
|
-
column_selector = lambda do |tr|
|
46
|
-
tds = tr.search('td')
|
47
|
-
[
|
48
|
-
tds[0].text,
|
49
|
-
tds[1].text,
|
50
|
-
tds[2].css('input:nth-child(2)').first.attributes['value']
|
51
|
-
]
|
52
|
-
end
|
53
|
-
body = _tableish(html, '.admin-table table tbody tr', column_selector)
|
54
|
-
|
55
|
-
(header + body).should == [
|
56
|
-
['Name', 'Edit', 'Delete'],
|
57
|
-
['Guybrush Threepwood', 'Edit', 'Delete']
|
58
|
-
]
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should convert a table" do
|
62
|
-
html = <<-HTML
|
63
|
-
<table id="tools">
|
64
|
-
<tr>
|
65
|
-
<th>tool</th>
|
66
|
-
<th>dude</th>
|
67
|
-
</tr>
|
68
|
-
<tr>
|
69
|
-
<td>webrat</td>
|
70
|
-
<td>bryan</td>
|
71
|
-
</tr>
|
72
|
-
<tr>
|
73
|
-
<td>cucumber</td>
|
74
|
-
<td>aslak</td>
|
75
|
-
</tr>
|
76
|
-
</table>
|
77
|
-
HTML
|
78
|
-
|
79
|
-
_tableish(html, 'table#tools tr', 'td,th').should == [
|
80
|
-
%w{tool dude},
|
81
|
-
%w{webrat bryan},
|
82
|
-
%w{cucumber aslak}
|
83
|
-
]
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should size to the first row" do
|
87
|
-
html = <<-HTML
|
88
|
-
<table id="tools">
|
89
|
-
<tr>
|
90
|
-
<th>tool</th>
|
91
|
-
<th>dude</th>
|
92
|
-
</tr>
|
93
|
-
<tr>
|
94
|
-
<td>webrat</td>
|
95
|
-
<td>bryan</td>
|
96
|
-
<td>crapola</td>
|
97
|
-
</tr>
|
98
|
-
<tr>
|
99
|
-
<td>cucumber</td>
|
100
|
-
<td>aslak</td>
|
101
|
-
<td>gunk</td>
|
102
|
-
<td>filth</td>
|
103
|
-
</tr>
|
104
|
-
</table>
|
105
|
-
HTML
|
106
|
-
|
107
|
-
_tableish(html, 'table#tools tr', 'td,th').should == [
|
108
|
-
['tool', 'dude',],
|
109
|
-
['webrat', 'bryan'],
|
110
|
-
['cucumber', 'aslak']
|
111
|
-
]
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should pad with empty Strings if some rows are shorter" do
|
115
|
-
html = <<-HTML
|
116
|
-
<table id="tools">
|
117
|
-
<tr>
|
118
|
-
<th>tool</th>
|
119
|
-
<th>dude</th>
|
120
|
-
</tr>
|
121
|
-
<tr>
|
122
|
-
<td>webrat</td>
|
123
|
-
<td>bryan</td>
|
124
|
-
</tr>
|
125
|
-
<tr>
|
126
|
-
<td>cucumber</td>
|
127
|
-
</tr>
|
128
|
-
</table>
|
129
|
-
HTML
|
130
|
-
|
131
|
-
_tableish(html, 'table#tools tr', 'td,th').should == [
|
132
|
-
%w{tool dude},
|
133
|
-
%w{webrat bryan},
|
134
|
-
['cucumber', '']
|
135
|
-
]
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should handle colspan and rowspan" do
|
139
|
-
html = <<-HTML
|
140
|
-
<table id="tools">
|
141
|
-
<tr>
|
142
|
-
<td rowspan="4">a</td>
|
143
|
-
<td>b</td>
|
144
|
-
<td>c</td>
|
145
|
-
<td>d</td>
|
146
|
-
</tr>
|
147
|
-
<tr>
|
148
|
-
<td colspan="3">e</td>
|
149
|
-
</tr>
|
150
|
-
<tr>
|
151
|
-
<td rowspan="2" colspan="2">f</td>
|
152
|
-
<td>g</td>
|
153
|
-
</tr>
|
154
|
-
<tr>
|
155
|
-
<td>h</td>
|
156
|
-
</tr>
|
157
|
-
</table>
|
158
|
-
HTML
|
159
|
-
|
160
|
-
_tableish(html, 'table#tools tr', 'td,th').should == [
|
161
|
-
['a', 'b', 'c', 'd'],
|
162
|
-
['', 'e', '', '' ],
|
163
|
-
['', 'f', '', 'g' ],
|
164
|
-
['', '', '', 'h' ],
|
165
|
-
]
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should convert a dl" do
|
169
|
-
html = <<-HTML
|
170
|
-
<dl id="tools">
|
171
|
-
<dt>webrat</dt>
|
172
|
-
<dd>bryan</dd>
|
173
|
-
<dt>cucumber</dt>
|
174
|
-
<dd>aslak</dd>
|
175
|
-
</dl>
|
176
|
-
HTML
|
177
|
-
|
178
|
-
_tableish(html, 'dl#tools dt', lambda{|dt| [dt, dt.next.next]}).should == [
|
179
|
-
%w{webrat bryan},
|
180
|
-
%w{cucumber aslak}
|
181
|
-
]
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should convert a ul" do
|
185
|
-
html = <<-HTML
|
186
|
-
<ul id="phony">
|
187
|
-
<li>nope</li>
|
188
|
-
</ul>
|
189
|
-
|
190
|
-
<ul id="yes">
|
191
|
-
<li>webrat</li>
|
192
|
-
<li>bryan</li>
|
193
|
-
<li>cucumber</li>
|
194
|
-
<li>aslak</li>
|
195
|
-
</ul>
|
196
|
-
HTML
|
197
|
-
|
198
|
-
_tableish(html, 'ul#yes li', lambda{|li| [li]}).should == [
|
199
|
-
%w{webrat},
|
200
|
-
%w{bryan},
|
201
|
-
%w{cucumber},
|
202
|
-
%w{aslak},
|
203
|
-
]
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should do complex shit" do
|
207
|
-
html = <<-HTML
|
208
|
-
<form method="post" action="/invoices/10/approve" class="button-to">
|
209
|
-
<div>
|
210
|
-
<input id="approve_invoice_10" type="submit" value="Approve" />
|
211
|
-
<input name="authenticity_token" type="hidden" value="WxKGVy3Y5zcvFEiFe66D/odoc3CicfMdAup4vzQfiZ0=" />
|
212
|
-
<span>Hello World<span>
|
213
|
-
</div>
|
214
|
-
</form>
|
215
|
-
<form method="post" action="/invoices/10/delegate" class="button-to">
|
216
|
-
<div>
|
217
|
-
<input id="delegate_invoice_10" type="submit" value="Delegate" />
|
218
|
-
<input name="authenticity_token" type="hidden" value="WxKGVy3Y5zcvFEiFe66D/odoc3CicfMdAup4vzQfiZ0=" />
|
219
|
-
<span>Hi There<span>
|
220
|
-
</div>
|
221
|
-
</form>
|
222
|
-
HTML
|
223
|
-
|
224
|
-
selectors = lambda do |form|
|
225
|
-
[
|
226
|
-
form.css('div input:nth-child(1)').first.attributes['value'],
|
227
|
-
form.css('span').first.text.gsub(/\302\240/, ' ')
|
228
|
-
]
|
229
|
-
end
|
230
|
-
|
231
|
-
_tableish(html, 'form', selectors).should == [
|
232
|
-
['Approve', "Hello World"],
|
233
|
-
['Delegate', 'Hi There']
|
234
|
-
]
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|