daddy 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWVkYzljMjg0YzljMjljNmRkMzg4Yjk1MjhiNzkyZjQ3NmEwMTcyZA==
4
+ ZTc3ZmI4NTNlODk3NGI5ZTU0ZTU2Y2U1OGFjYjJiNjA5Y2UwNTAwZg==
5
5
  data.tar.gz: !binary |-
6
- MzQ4ZmYyNGMwOGM5NTlmYzA3YWI3NzFiOWIyMjE1YjQwZDc3NmM1Ng==
6
+ ZWIxYmFkNGQ1MmIyN2UyMWE4MDM0ZmIyNzY4NDkzNjc2MmU0OWNjOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWU3YjE0M2RhZWE0NzE4MzcxMDE3ODRjYzY3NTlkZWRiMjk5YzFjZjhlM2Fj
10
- MjRkNzM2MzgxZmNkMjEzYWVmYmRiZGJkMmM4MGRkZDgzNzc5OGVmZDY0NDEw
11
- YjgxYThmM2Q3MzA3ODNhMWMyMzg0Mzk5ZDMyMzFiNTdkMDM4MjE=
9
+ OWY3MzcxMDFkNDFkZjJiZDExNGEzOGQ4ZjBkMzAyNDViZTFlMzRjMDUyOWI1
10
+ MjBiY2Y3NTdiYTkxODJhZTgzZmVmZTIxMTU2MWY5ZWMxZDRmNTUzZTY3N2Nj
11
+ ZWNkZTY1OGEzMTJlZDFmZGE3NjNiOWE3NmRkNjE0NTQxMTMzODc=
12
12
  data.tar.gz: !binary |-
13
- NTgzYTg1MjI2ODUzYmMyZGVmODc1YmIwYjIzYWIwMDRkMWU1MDZjZjAxNzgz
14
- ZDIwM2Y0YjRhZDA3NDI3NjEyNWE2MjNkM2UxNGFhZmYwM2RjNmZmNGFiOWY0
15
- YmFmMzUyNTRkOTYzMGRhZGY0NzgxYjgwOGJjMGRlZmJjZTUxNjc=
13
+ NjA3OTlkOWI3MDkxYWVmYzRiNzI4ZWRlOGE3NzJhYTFiZDQ4OWU0ZWUyZTdj
14
+ MWE1NThmYWVjYzg3M2I2ODZmNzhlOThlZDY2NTMxZGI5N2U1ZDg4ZGQwNTNl
15
+ NTIzMWRiZWM5NmNmMjg2Njk3NDgzZjhjYjE1ODk2MzUwMjhlMjI=
@@ -0,0 +1,48 @@
1
+ # coding: UTF-8
2
+
3
+ require 'cucumber/rails'
4
+ require "capybara/webkit"
5
+
6
+ Capybara.default_driver = (ENV['DRIVER'] || :selenium).to_sym
7
+ Capybara.default_selector = :css
8
+
9
+ ActionController::Base.allow_rescue = false
10
+
11
+ require 'daddy/cucumber/assert'
12
+ require 'daddy/cucumber/capture'
13
+ require 'daddy/cucumber/table'
14
+ World(Daddy::Cucumber::Assert)
15
+ World(Daddy::Cucumber::Capture)
16
+ World(Daddy::Cucumber::Table)
17
+
18
+ Dir::glob(File.dirname(__FILE__) + '/cucumber/step_definitions/*.rb').each do |file|
19
+ load file
20
+ end
21
+
22
+ def override_method(obj, method_name, &block)
23
+ klass = class <<obj; self; end
24
+ klass.send(:undef_method, method_name)
25
+ klass.send(:define_method, method_name, block)
26
+ end
27
+
28
+ AfterConfiguration do |configuration|
29
+ feature_files = configuration.feature_files
30
+
31
+ override_method(configuration, :feature_files) {
32
+ sorted_files = feature_files.sort do |x, y|
33
+ if x.start_with?('features/開発日記') and y.start_with?('features/開発日記')
34
+ x <=> y
35
+ elsif x.start_with?('features/仕様書') and y.start_with?('features/仕様書')
36
+ x <=> y
37
+ elsif x.start_with?('features/開発日記')
38
+ -1
39
+ elsif y.start_with?('features/開発日記')
40
+ 1
41
+ else
42
+ x <=> y
43
+ end
44
+ end
45
+
46
+ sorted_files
47
+ }
48
+ end
@@ -0,0 +1,121 @@
1
+ # coding: UTF-8
2
+
3
+ module Daddy
4
+ module Cucumber
5
+ module Assert
6
+ def assert_url(path, params = {})
7
+ # スクリーンショットの保存
8
+ url_without_domain = remove_domain(current_url)
9
+
10
+ begin
11
+ capture url_without_domain
12
+ rescue
13
+ puts "URL: #{url_without_domain}"
14
+ end
15
+
16
+ # パスのチェック
17
+ re = path.gsub(/\//, '\/')
18
+ assert /#{re}/ =~ current_path, "想定しているパスではありません。想定 #{path} : 実際 #{current_path}"
19
+
20
+ # パラメータのチェック
21
+ current_params = get_current_params()
22
+ params.each do |key, value|
23
+ re = value
24
+ assert /#{re}/ =~ current_params[key], "#{key}が想定している値ではありません。想定 #{value} : 実際 #{current_params[key]}"
25
+ end
26
+ end
27
+
28
+ def assert_visit(path, params = {})
29
+ query_string = ''
30
+ params.each do |key, value|
31
+ if query_string.blank?
32
+ query_string += '?'
33
+ else
34
+ query_string += '&'
35
+ end
36
+ query_string += (key.to_s + '=' + value.to_s)
37
+ end
38
+
39
+ visit path + query_string
40
+ assert_url path, params
41
+ end
42
+
43
+ def assert_fill_in(field_name, value)
44
+ fill_in field_name, :with => value
45
+ capture
46
+ end
47
+
48
+ def assert_fill_in_rich(field_name, value)
49
+ fill_in_rich field_name, value
50
+ capture
51
+ end
52
+
53
+ def assert_check(field_name)
54
+ check field_name
55
+ capture
56
+ end
57
+
58
+ def assert_uncheck(field_name)
59
+ uncheck field_name
60
+ capture
61
+ end
62
+
63
+ def assert_choose(field_name)
64
+ choose field_name
65
+ capture
66
+ end
67
+
68
+ def assert_select(name, value)
69
+ select value, :from => name
70
+ capture
71
+ end
72
+
73
+ def assert_selector(selector, options = {})
74
+ assert page.has_selector?(selector), options[:message]
75
+ capture if options[:capture]
76
+ end
77
+
78
+ def assert_no_selector(selector, options = {})
79
+ assert page.has_no_selector?(selector), options[:message]
80
+ capture if options[:capture]
81
+ end
82
+
83
+ def assert_present(value, message = nil)
84
+ assert value.present?, message
85
+ end
86
+
87
+ def assert_not_present(value, message = nil)
88
+ assert ! value.present?, message
89
+ end
90
+
91
+ def assert_content_type(content_type)
92
+ assert_equal page.response_headers['Content-Type'], content_type
93
+ end
94
+
95
+ def assert_iterate(array)
96
+ iterated = false
97
+
98
+ array.each do |x|
99
+ iterated ||= yield x
100
+ end
101
+
102
+ fail 'テスト対象のデータがありません。' unless iterated
103
+ end
104
+
105
+ def get_current_params
106
+ ret = {}
107
+ if current_url.include?('?')
108
+ current_url.split('?')[1].split('&').each do |query_string|
109
+ key, value = query_string.split('=')
110
+ ret.store key.to_sym, value
111
+ end
112
+ end
113
+ ret
114
+ end
115
+
116
+ def remove_domain(url)
117
+ url.sub(/http:\/\/([^\/:]+)(:[0-9]+)?\/(.+)/) { "/#{$3}" }
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,32 @@
1
+ # coding: UTF-8
2
+
3
+ module Daddy
4
+ module Cucumber
5
+ module Capture
6
+ SCREENSHOT_DIR = 'features/reports/screenshots'
7
+ FileUtils.mkdir_p(SCREENSHOT_DIR)
8
+
9
+ @@_screen_count = 0
10
+
11
+ def capture(url = nil)
12
+
13
+ url ||= remove_domain(current_url)
14
+
15
+ @@_screen_count += 1
16
+
17
+ image = "#{@@_screen_count}.png"
18
+
19
+ if Capybara.current_driver == :webkit
20
+ page.driver.render("#{SCREENSHOT_DIR}/#{image}")
21
+ else
22
+ page.driver.browser.save_screenshot("#{SCREENSHOT_DIR}/#{image}")
23
+ end
24
+
25
+ puts %{
26
+ <div style="margin: 5px 0;">#{url}</div>
27
+ <div style="padding-right: 20px;"><img src="screenshots/#{image}" width="60%" height="60%"/></div>
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ # coding: UTF-8
2
+
3
+ もし /^(.*?) をクリック(する)?$/ do |name, suffix|
4
+ click_on name
5
+ end
6
+
7
+ もし /^(.*?) を選択(する)?$/ do |name, suffix|
8
+ click_on name
9
+ end
10
+
11
+ もし /^(.*?) にチェック(を入れる)?$/ do |name, suffix|
12
+ assert_check name
13
+ end
14
+
15
+ もし /^(.*?) に (.*?) を選択(する)?$/ do |name, value, suffix|
16
+ assert_select name, value
17
+ end
18
+
19
+ もし /^(.*?) に (.*?) を選ぶ?$/ do |name, value|
20
+ assert_choose value
21
+ end
22
+
23
+ もし /^(.*?) に (.*?) と入力(する)?$/ do |name, value, suffix|
24
+ assert_fill_in name, value
25
+ end
26
+
27
+ もし /^(.*?) に以下の文章を入力(する)?$/ do |name, suffix, text|
28
+ assert_fill_in name, text
29
+ end
30
+
31
+ もし /^(.*?) に (.*?) とリッチに入力(する)?$/ do |name, value, suffix|
32
+ assert_fill_in_rich name, value
33
+ end
@@ -0,0 +1,24 @@
1
+ # coding: UTF-8
2
+
3
+ module Daddy
4
+ module Cucumber
5
+ module Table
6
+ def normalize_table(ast_table)
7
+ ret = []
8
+
9
+ ast_table.raw.each do |ast_row|
10
+ row = []
11
+
12
+ ast_row.each do |ast_col|
13
+ value = ast_col.gsub(/ /, '')
14
+ row << value
15
+ end
16
+
17
+ ret << row
18
+ end
19
+
20
+ ret
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,285 @@
1
+ /* cucumber.css is generated from cucumber.sass */
2
+ /* Regenerate with rake sass */
3
+ body {
4
+ font-size: 0px;
5
+ color: white;
6
+ margin: 0px;
7
+ padding: 0px;
8
+ }
9
+
10
+ .cucumber, td, th {
11
+ font: normal 11px "Lucida Grande", Helvetica, sans-serif;
12
+ background: white;
13
+ color: black;
14
+ }
15
+ .cucumber #cucumber-header, td #cucumber-header, th #cucumber-header {
16
+ background: #65c400;
17
+ color: white;
18
+ height: 6em;
19
+ }
20
+ .cucumber #cucumber-header #expand-collapse p, td #cucumber-header #expand-collapse p, th #cucumber-header #expand-collapse p {
21
+ float: right;
22
+ margin: 0 0 0 10px;
23
+ }
24
+ .cucumber .scenario h3, td .scenario h3, th .scenario h3, .background h3 {
25
+ font-size: 11px;
26
+ padding: 3px;
27
+ margin: 0;
28
+ background: #65c400;
29
+ color: white;
30
+ font-weight: bold;
31
+ }
32
+
33
+ .background h3 {
34
+ font-size: 1.2em;
35
+ background: #666;
36
+ }
37
+
38
+ .cucumber h1, td h1, th h1 {
39
+ margin: 0px 10px 0px 10px;
40
+ padding: 10px;
41
+ font-family: "Lucida Grande", Helvetica, sans-serif;
42
+ font-size: 2em;
43
+ position: absolute;
44
+ }
45
+ .cucumber h4, td h4, th h4 {
46
+ margin-bottom: 2px;
47
+ }
48
+ .cucumber div.feature, td div.feature, th div.feature {
49
+ padding: 2px;
50
+ margin: 0px 10px 5px 10px;
51
+ }
52
+ .cucumber div.examples, td div.examples, th div.examples {
53
+ padding: 0em 0em 0em 1em;
54
+ }
55
+ .cucumber .stats, td .stats, th .stats {
56
+ margin: 2em;
57
+ }
58
+ .cucumber .summary ul.features li, td .summary ul.features li, th .summary ul.features li {
59
+ display: inline;
60
+ }
61
+ .cucumber .step_name, td .step_name, th .step_name {
62
+ float: left;
63
+ }
64
+ .cucumber .step_file, td .step_file, th .step_file {
65
+ text-align: right;
66
+ color: #999999;
67
+ }
68
+ .cucumber .step_file a, td .step_file a, th .step_file a {
69
+ color: #999999;
70
+ }
71
+ .cucumber .scenario_file, td .scenario_file, th .scenario_file {
72
+ float: right;
73
+ color: #999999;
74
+ }
75
+ .cucumber .tag, td .tag, th .tag {
76
+ font-weight: bold;
77
+ color: #246ac1;
78
+ }
79
+ .cucumber .backtrace, td .backtrace, th .backtrace {
80
+ margin-top: 0;
81
+ margin-bottom: 0;
82
+ margin-left: 1em;
83
+ color: black;
84
+ }
85
+ .cucumber a, td a, th a {
86
+ text-decoration: none;
87
+ color: #be5c00;
88
+ }
89
+ .cucumber a:hover, td a:hover, th a:hover {
90
+ text-decoration: underline;
91
+ }
92
+ .cucumber a:visited, td a:visited, th a:visited {
93
+ font-weight: normal;
94
+ }
95
+ .cucumber a div.examples, td a div.examples, th a div.examples {
96
+ margin: 5px 0px 5px 15px;
97
+ color: black;
98
+ }
99
+ .cucumber .outline table, td .outline table, th .outline table {
100
+ margin: 0px 0px 5px 10px;
101
+ }
102
+ .cucumber table, td table, th table {
103
+ border-collapse: collapse;
104
+ }
105
+ .cucumber table td, td table td, th table td {
106
+ padding: 3px 3px 3px 5px;
107
+ }
108
+ .cucumber table td.failed, .cucumber table td.passed, .cucumber table td.skipped, .cucumber table td.pending, .cucumber table td.undefined, td table td.failed, td table td.passed, td table td.skipped, td table td.pending, td table td.undefined, th table td.failed, th table td.passed, th table td.skipped, th table td.pending, th table td.undefined {
109
+ padding-left: 18px;
110
+ padding-right: 10px;
111
+ }
112
+ .cucumber table td.failed, td table td.failed, th table td.failed {
113
+ border-left: 5px solid #c20000;
114
+ border-bottom: 1px solid #c20000;
115
+ background: #fffbd3;
116
+ color: #c20000;
117
+ }
118
+ .cucumber table td.passed, td table td.passed, th table td.passed {
119
+ border-left: 5px solid #65c400;
120
+ border-bottom: 1px solid #65c400;
121
+ background: #dbffb4;
122
+ color: #3d7700;
123
+ }
124
+ .cucumber table td.skipped, td table td.skipped, th table td.skipped {
125
+ border-left: 5px solid aqua;
126
+ border-bottom: 1px solid aqua;
127
+ background: #e0ffff;
128
+ color: #001111;
129
+ }
130
+ .cucumber table td.pending, td table td.pending, th table td.pending {
131
+ border-left: 5px solid #faf834;
132
+ border-bottom: 1px solid #faf834;
133
+ background: #fcfb98;
134
+ color: #131313;
135
+ }
136
+ .cucumber table td.undefined, td table td.undefined, th table td.undefined {
137
+ border-left: 5px solid #faf834;
138
+ border-bottom: 1px solid #faf834;
139
+ background: #fcfb98;
140
+ color: #131313;
141
+ }
142
+ .cucumber table td.message, td table td.message, th table td.message {
143
+ border-left: 5px solid aqua;
144
+ border-bottom: 1px solid aqua;
145
+ background: #e0ffff;
146
+ color: #001111;
147
+ }
148
+ .cucumber ol, td ol, th ol {
149
+ list-style: none;
150
+ margin: 0px;
151
+ padding: 0px;
152
+ }
153
+ .cucumber ol li.step, td ol li.step, th ol li.step {
154
+ padding: 3px 3px 3px 18px;
155
+ margin: 5px 0px 5px 5px;
156
+ }
157
+ .cucumber ol li, td ol li, th ol li {
158
+ margin: 0em 0em 0em 1em;
159
+ padding: 0em 0em 0em 0.2em;
160
+ }
161
+ .cucumber ol li span.param, td ol li span.param, th ol li span.param {
162
+ font-weight: bold;
163
+ }
164
+ .cucumber ol li.failed, td ol li.failed, th ol li.failed {
165
+ border-left: 5px solid #c20000;
166
+ border-bottom: 1px solid #c20000;
167
+ background: #fffbd3;
168
+ color: #c20000;
169
+ }
170
+ .cucumber ol li.passed, td ol li.passed, th ol li.passed {
171
+ border-left: 5px solid #65c400;
172
+ border-bottom: 1px solid #65c400;
173
+ background: #dbffb4;
174
+ color: #3d7700;
175
+ }
176
+ .cucumber ol li.skipped, td ol li.skipped, th ol li.skipped {
177
+ border-left: 5px solid aqua;
178
+ border-bottom: 1px solid aqua;
179
+ background: #e0ffff;
180
+ color: #001111;
181
+ }
182
+ .cucumber ol li.pending, td ol li.pending, th ol li.pending {
183
+ border-left: 5px solid #faf834;
184
+ border-bottom: 1px solid #faf834;
185
+ background: #fcfb98;
186
+ color: #131313;
187
+ }
188
+ .cucumber ol li.undefined, td ol li.undefined, th ol li.undefined {
189
+ border-left: 5px solid #faf834;
190
+ border-bottom: 1px solid #faf834;
191
+ background: #fcfb98;
192
+ color: #131313;
193
+ }
194
+ .cucumber ol li.message, td ol li.message, th ol li.message {
195
+ border-left: 5px solid aqua;
196
+ border-bottom: 1px solid aqua;
197
+ background: #e0ffff;
198
+ color: #001111;
199
+ margin-left: 10px;
200
+ }
201
+ .cucumber #summary, td #summary, th #summary {
202
+ margin: 0px;
203
+ padding: 5px 10px;
204
+ text-align: right;
205
+ top: 0px;
206
+ right: 0px;
207
+ float: right;
208
+ }
209
+ .cucumber #summary p, td #summary p, th #summary p {
210
+ margin: 0 0 0 2px;
211
+ }
212
+ .cucumber #summary #totals, td #summary #totals, th #summary #totals {
213
+ font-size: 1.2em;
214
+ }
215
+
216
+ .ruby {
217
+ font-size: 12px;
218
+ font-family: monospace;
219
+ color: white;
220
+ background: black;
221
+ padding: 0.1em 0 0.2em 0;
222
+ }
223
+ .ruby .keyword {
224
+ color: #ff6600;
225
+ }
226
+ .ruby .constant {
227
+ color: #339999;
228
+ }
229
+ .ruby .attribute {
230
+ color: white;
231
+ }
232
+ .ruby .global {
233
+ color: white;
234
+ }
235
+ .ruby .module {
236
+ color: white;
237
+ }
238
+ .ruby .class {
239
+ color: white;
240
+ }
241
+ .ruby .string {
242
+ color: #66ff00;
243
+ }
244
+ .ruby .ident {
245
+ color: white;
246
+ }
247
+ .ruby .method {
248
+ color: #ffcc00;
249
+ }
250
+ .ruby .number {
251
+ color: white;
252
+ }
253
+ .ruby .char {
254
+ color: white;
255
+ }
256
+ .ruby .comment {
257
+ color: #9933cc;
258
+ }
259
+ .ruby .symbol {
260
+ color: white;
261
+ }
262
+ .ruby .regex {
263
+ color: #44b4cc;
264
+ }
265
+ .ruby .punct {
266
+ color: white;
267
+ }
268
+ .ruby .escape {
269
+ color: white;
270
+ }
271
+ .ruby .interp {
272
+ color: white;
273
+ }
274
+ .ruby .expr {
275
+ color: white;
276
+ }
277
+ .ruby .offending {
278
+ background: #333333;
279
+ }
280
+ .ruby .linenum {
281
+ width: 75px;
282
+ padding: 0.1em 1em 0.2em 0;
283
+ color: black;
284
+ background: #fffbd3;
285
+ }