decko 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decko/generators/decko/templates/Gemfile +1 -0
- metadata +5 -109
- data/.rspec +0 -4
- data/Guardfile +0 -32
- data/decko.gemspec +0 -42
- data/features/attach.feature +0 -85
- data/features/autonaming.feature +0 -19
- data/features/conflict.feature +0 -41
- data/features/follow.feature +0 -64
- data/features/history.feature +0 -27
- data/features/layouts.feature +0 -25
- data/features/navbox.feature +0 -34
- data/features/notifications.feature +0 -33
- data/features/paging.feature +0 -34
- data/features/pointer_inputs.feature +0 -81
- data/features/presetting_content.feature +0 -13
- data/features/reference.feature +0 -26
- data/features/reset_password.feature +0 -35
- data/features/rules.feature +0 -45
- data/features/setup.feature +0 -32
- data/features/signup.feature +0 -61
- data/features/step_definitions/decko_steps.rb +0 -532
- data/features/step_definitions/email_steps.rb +0 -216
- data/features/step_definitions/history_steps.rb +0 -5
- data/features/step_definitions/web_steps.rb +0 -155
- data/features/step_definitions/window_steps.rb +0 -27
- data/features/structure.feature +0 -41
- data/features/support/debugger.rb +0 -44
- data/features/support/delayed_job.rb +0 -20
- data/features/support/env.rb +0 -115
- data/features/support/file.txt +0 -1
- data/features/support/image.png +0 -0
- data/features/support/image2.jpg +0 -0
- data/features/support/paths.rb +0 -63
- data/features/support/scopes.rb +0 -34
- data/features/support/wagn_env.rb +0 -11
- data/features/table_of_contents.feature +0 -36
- data/features/toolbar.feature +0 -29
- data/features/update_includers.feature +0 -75
- data/lib/decko/tasks/.gitkeep +0 -0
- data/spec/controllers/card_controller_spec.rb +0 -407
- data/spec/controllers/location_spec.rb +0 -25
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +0 -812
- data/spec/javascripts/support/jasmine.yml.erb +0 -79
- data/spec/javascripts/support/jasmine_config.rb +0 -21
- data/spec/javascripts/support/jasmine_runner.rb +0 -21
- data/spec/javascripts/wagn_spec.coffee +0 -42
- data/test/1.10.0-data-dump.sql +0 -359
- data/test/performance/card_create_test.rb +0 -21
- data/test/performance/fetch_test.rb +0 -9
- data/test/performance/homepage_test.rb +0 -9
- data/test/performance/render_test.rb +0 -10
- data/test/script/run_engine_deck.sh +0 -47
- data/test/script/run_mig.sh +0 -29
- data/test/test_helper.rb +0 -125
@@ -1,532 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
# rubocop:disable Lint/AmbiguousRegexpLiteral
|
3
|
-
require "uri"
|
4
|
-
require "cgi"
|
5
|
-
support_paths_file = File.join File.dirname(__FILE__), "..", "support", "paths"
|
6
|
-
require File.expand_path support_paths_file
|
7
|
-
|
8
|
-
if RUBY_VERSION =~ /^2/
|
9
|
-
require "byebug"
|
10
|
-
else
|
11
|
-
require "debugger"
|
12
|
-
end
|
13
|
-
|
14
|
-
Given /^site simulates setup need$/ do
|
15
|
-
Card::Auth.simulate_setup_need!
|
16
|
-
end
|
17
|
-
|
18
|
-
Given /^site stops simulating setup need$/ do
|
19
|
-
Card::Auth.simulate_setup_need! false
|
20
|
-
step "I am signed out"
|
21
|
-
end
|
22
|
-
|
23
|
-
Given /^I am signed in as (.+)$/ do |account_name|
|
24
|
-
accounted = Card[account_name]
|
25
|
-
visit "/update/:signin?card[subcards][%2B*email][content]="\
|
26
|
-
"#{accounted.account.email}&card[subcards][%2B*password][content]=joe_pass"
|
27
|
-
# could optimize by specifying simple text success page
|
28
|
-
end
|
29
|
-
|
30
|
-
Given /^I am signed out$/ do
|
31
|
-
visit "/"
|
32
|
-
step 'I follow "Sign out"' if page.has_content? "Sign out"
|
33
|
-
end
|
34
|
-
|
35
|
-
# Given /^I sign in as (.+)$/ do |account_name|
|
36
|
-
# # FIXME: define a faster simulate method ("I am logged in as")
|
37
|
-
# accounted = Card[account_name]
|
38
|
-
# @current_id = accounted.id
|
39
|
-
# visit "/:signin"
|
40
|
-
# fill_in "card[subcards][+*email][content]", with: accounted.account.email
|
41
|
-
# fill_in "card[subcards][+*password][content]", with: 'joe_pass'
|
42
|
-
# click_button "Sign in"
|
43
|
-
# page.should have_content(account_name)
|
44
|
-
# end
|
45
|
-
|
46
|
-
Given /^the card (.*) contains "([^\"]*)"$/ do |cardname, content|
|
47
|
-
Card::Auth.as_bot do
|
48
|
-
card = Card.fetch cardname, new: {}
|
49
|
-
card.content = content
|
50
|
-
card.save!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
When /^(.*) edits? "([^\"]*)"$/ do |username, cardname|
|
55
|
-
signed_in_as(username) do
|
56
|
-
visit "/card/edit/#{cardname.to_name.url_key}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
When /^(.*) edits? "([^\"]*)" entering "([^\"]*)" into wysiwyg$/ do
|
61
|
-
|username, cardname, content|
|
62
|
-
signed_in_as(username) do
|
63
|
-
visit "/card/edit/#{cardname.to_name.url_key}"
|
64
|
-
page.execute_script "$('#main .d0-card-content').val('#{content}')"
|
65
|
-
click_button "Submit"
|
66
|
-
wait_for_ajax
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
When /^(.*) edits? "([^\"]*)" setting (.*) to "([^\"]*)"$/ do
|
71
|
-
|username, cardname, _field, content|
|
72
|
-
signed_in_as(username) do
|
73
|
-
visit "/card/edit/#{cardname.to_name.url_key}"
|
74
|
-
set_content "card[content]", content
|
75
|
-
click_button "Submit"
|
76
|
-
wait_for_ajax
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
When /^(.*) edits? "([^\"]*)" filling in "([^\"]*)"$/ do |_username, cardname, content|
|
81
|
-
visit "/card/edit/#{cardname.to_name.url_key}"
|
82
|
-
fill_in "card[content]", with: content
|
83
|
-
end
|
84
|
-
|
85
|
-
When /^(.*) edits? "([^\"]*)" with plusses:/ do |username, cardname, plusses|
|
86
|
-
signed_in_as(username) do
|
87
|
-
visit "/card/edit/#{cardname.to_name.url_key}"
|
88
|
-
plusses.hashes.first.each do |name, content|
|
89
|
-
set_content "card[subcards][+#{name}][content]", content
|
90
|
-
end
|
91
|
-
click_button "Submit"
|
92
|
-
wait_for_ajax
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def set_content name, content, _cardtype=nil
|
97
|
-
Capybara.ignore_hidden_elements = false
|
98
|
-
wait_for_ajax
|
99
|
-
set_ace_editor_content(name, content) ||
|
100
|
-
set_pm_editor_content(name, content) ||
|
101
|
-
set_tinymce_editor_content(name, content) ||
|
102
|
-
fill_in(name, with: content)
|
103
|
-
Capybara.ignore_hidden_elements = true
|
104
|
-
end
|
105
|
-
|
106
|
-
def set_ace_editor_content name, content
|
107
|
-
find_editor ".ace-editor-textarea[name='#{name}']" do |_editors|
|
108
|
-
return unless page.evaluate_script("typeof ace != 'undefined'")
|
109
|
-
sleep(0.5)
|
110
|
-
content = escape_quotes content
|
111
|
-
page.execute_script "ace.edit($('.ace_editor').get(0))"\
|
112
|
-
".getSession().setValue('#{content}')"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def set_pm_editor_content name, content
|
117
|
-
find_editor ".prosemirror-editor > [name='#{name}']" do |editors|
|
118
|
-
content = escape_quotes content
|
119
|
-
editor_id = editors.first.first(:xpath, ".//..")[:id]
|
120
|
-
page.execute_script "$('##{editor_id} .ProseMirror').text('#{content}')"
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def set_tinymce_editor_content name, content
|
125
|
-
find_editor "textarea[name='#{name}']" do |editors|
|
126
|
-
editor_id = editors.first[:id]
|
127
|
-
return unless page.evaluate_script("typeof tinyMCE != 'undefined' && "\
|
128
|
-
"tinyMCE.get('#{editor_id}') != null")
|
129
|
-
sleep(0.5)
|
130
|
-
content = escape_quotes content
|
131
|
-
page.execute_script "tinyMCE.get('#{editor_id}').setContent('#{content}')"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def escape_quotes content
|
136
|
-
content.gsub("'", "\\'")
|
137
|
-
end
|
138
|
-
|
139
|
-
def find_editor selector
|
140
|
-
editors = all(selector)
|
141
|
-
return unless editors.present?
|
142
|
-
yield editors
|
143
|
-
true
|
144
|
-
end
|
145
|
-
|
146
|
-
When /^(.*) creates?\s*a?\s*([^\s]*) card "(.*)" with content "(.*)"$/ do
|
147
|
-
|username, cardtype, cardname, content|
|
148
|
-
create_card(username, cardtype, cardname, content) do
|
149
|
-
set_content "card[content]", content, cardtype
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
When /^(.*) creates?\s*([^\s]*) card "([^"]*)"$/ do |username, cardtype, cardname|
|
154
|
-
create_card username, cardtype, cardname
|
155
|
-
end
|
156
|
-
|
157
|
-
When /^(.*) creates?\s*([^\s]*) card "([^"]*)" with plusses:$/ do
|
158
|
-
|username, cardtype, cardname, plusses|
|
159
|
-
create_card(username, cardtype, cardname) do
|
160
|
-
plusses.hashes.first.each do |name, content|
|
161
|
-
set_content "card[subcards][+#{name}][content]", content, cardtype
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
When /^(.*) deletes? "([^\"]*)"$/ do |username, cardname|
|
167
|
-
signed_in_as(username) do
|
168
|
-
visit "/card/delete/#{cardname.to_name.url_key}"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
When /^(?:|I )enter "([^"]*)" into "([^"]*)"$/ do |value, field|
|
173
|
-
selector = ".RIGHT-#{field.to_name.safe_key} input.d0-card-content"
|
174
|
-
find(selector).set value
|
175
|
-
end
|
176
|
-
|
177
|
-
When /^(?:|I )upload the (.+) "(.+)"$/ do |attachment_name, filename|
|
178
|
-
Capybara.ignore_hidden_elements = false
|
179
|
-
attach_file "card_#{attachment_name}", find_file(filename)
|
180
|
-
Capybara.ignore_hidden_elements = true
|
181
|
-
wait_for_ajax
|
182
|
-
end
|
183
|
-
|
184
|
-
def find_file filename
|
185
|
-
roots = "{#{Cardio.root}/mod/**,#{Cardio.gem_root}/mod/**,#{Decko.gem_root}}"
|
186
|
-
paths = Dir.glob(File.join(roots, "features", "support", filename))
|
187
|
-
raise ArgumentError, "couldn't find file '#{filename}'" if paths.empty?
|
188
|
-
paths.first
|
189
|
-
end
|
190
|
-
|
191
|
-
Given /^(.*) (is|am) watching "([^\"]+)"$/ do |user, _verb, cardname|
|
192
|
-
Delayed::Worker.new.work_off
|
193
|
-
user = Card::Auth.current.name if user == "I"
|
194
|
-
signed_in_as user do
|
195
|
-
step "the card #{cardname}+#{user}+*follow contains \"[[*always]]\""
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
Given /^(.*) (is|am) not watching "([^\"]+)"$/ do |user, _verb, cardname|
|
200
|
-
user = Card::Auth.current.name if user == "I"
|
201
|
-
signed_in_as user do
|
202
|
-
step "the card #{cardname}+#{user}+*follow contains \"[[*never]]\""
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
When /I wait a sec/ do
|
207
|
-
sleep 1
|
208
|
-
end
|
209
|
-
|
210
|
-
When /I wait (\d+) seconds?$/ do |period|
|
211
|
-
sleep period.to_i
|
212
|
-
end
|
213
|
-
|
214
|
-
def wait_for_ajax
|
215
|
-
Timeout.timeout(Capybara.default_max_wait_time) do
|
216
|
-
sleep(0.5) until finished_all_ajax_requests?
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def finished_all_ajax_requests?
|
221
|
-
jquery_undefined? || page.evaluate_script("jQuery.active").zero?
|
222
|
-
end
|
223
|
-
|
224
|
-
def jquery_undefined?
|
225
|
-
page.evaluate_script("typeof(jQuery) === 'undefined'")
|
226
|
-
end
|
227
|
-
|
228
|
-
When /^I wait for ajax response$/ do
|
229
|
-
wait_for_ajax
|
230
|
-
end
|
231
|
-
|
232
|
-
# Then /what/ do
|
233
|
-
# save_and_open_page
|
234
|
-
# end
|
235
|
-
#
|
236
|
-
Then /debug/ do
|
237
|
-
require "pry"
|
238
|
-
#
|
239
|
-
nil
|
240
|
-
end
|
241
|
-
# if RUBY_VERSION =~ /^2/
|
242
|
-
# else
|
243
|
-
# debugger
|
244
|
-
# end
|
245
|
-
# nil
|
246
|
-
# end
|
247
|
-
|
248
|
-
def create_card username, cardtype, cardname, content=""
|
249
|
-
signed_in_as(username) do
|
250
|
-
if cardtype == "Pointer"
|
251
|
-
Card.create name: cardname, type: cardtype, content: content
|
252
|
-
else
|
253
|
-
visit "/card/new?card[name]=#{CGI.escape(cardname)}&type=#{cardtype}"
|
254
|
-
yield if block_given?
|
255
|
-
click_button "Submit"
|
256
|
-
wait_for_ajax
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def signed_in_as username
|
262
|
-
sameuser = (username == "I")
|
263
|
-
sameuser ||= (Card::Auth.current.key == username.to_name.key)
|
264
|
-
was_signed_in = Card::Auth.current_id if Card::Auth.signed_in?
|
265
|
-
step "I am signed in as #{username}" unless sameuser
|
266
|
-
yield
|
267
|
-
return if sameuser
|
268
|
-
msg = if was_signed_in
|
269
|
-
"I am signed in as #{Card[was_signed_in].name}"
|
270
|
-
else
|
271
|
-
'I follow "Sign out"'
|
272
|
-
end
|
273
|
-
step msg
|
274
|
-
end
|
275
|
-
|
276
|
-
When /^In (.*) I follow "([^\"]*)"$/ do |section, link|
|
277
|
-
within scope_of(section) do
|
278
|
-
click_link link
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
When /^In (.*) I click "(.*)"$/ do |section, link|
|
283
|
-
within scope_of(section) do
|
284
|
-
click_link link
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
When /^I click "(.*)" within "(.*)"$/ do |link, selector|
|
289
|
-
within selector do
|
290
|
-
click_link link
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
When /^In (.*) I find link with class "(.*)" and click it$/ do |section, css_class|
|
295
|
-
within scope_of(section) do
|
296
|
-
find("a.#{css_class}").click
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
When /^In (.*) I find link with icon "(.*)" and click it$/ do |section, icon|
|
301
|
-
within scope_of(section) do
|
302
|
-
find("a > i.material-icons", text: icon).click
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
When /^In (.*) I find button with icon "(.*)" and click it$/ do |section, icon|
|
307
|
-
within scope_of(section) do
|
308
|
-
find("button > i.material-icons", text: icon).click
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
Given /^Jobs are dispatched$/ do
|
313
|
-
Delayed::Worker.new.work_off
|
314
|
-
end
|
315
|
-
|
316
|
-
Then /^No errors in the job queue$/ do
|
317
|
-
if (last = Delayed::Job.last) && (last.last_error)
|
318
|
-
puts last.last_error
|
319
|
-
expect(last.last_error).to be_blank
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
|
324
|
-
Then /I submit$/ do
|
325
|
-
click_button "Submit"
|
326
|
-
end
|
327
|
-
|
328
|
-
When /^I open the main card menu$/ do
|
329
|
-
slot = "$('#main .menu-slot .vertical-card-menu._show-on-hover .card-slot')"
|
330
|
-
page.execute_script "#{slot}.show()"
|
331
|
-
page.find("#main .menu-slot .card-menu a").click
|
332
|
-
end
|
333
|
-
|
334
|
-
When /^I close the modal window$/ do
|
335
|
-
page.find(".modal-menu .close-modal").click
|
336
|
-
end
|
337
|
-
|
338
|
-
# When /^I pick (.*)$/ do |menu_item|
|
339
|
-
# end
|
340
|
-
|
341
|
-
Then /the card (.*) should contain "([^\"]*)"$/ do |cardname, content|
|
342
|
-
visit path_to("card #{cardname}")
|
343
|
-
within scope_of("main card content") do
|
344
|
-
expect(page).to have_content(content)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
Then /the card (.*) should not contain "([^\"]*)"$/ do |cardname, content|
|
349
|
-
visit path_to("card #{cardname}")
|
350
|
-
within scope_of("main card content") do
|
351
|
-
expect(page).not_to have_content(content)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
Then /the card (.*) should point to "([^\"]*)"$/ do |cardname, content|
|
356
|
-
visit path_to("card #{cardname}")
|
357
|
-
within scope_of("pointer card content") do
|
358
|
-
expect(page).to have_content(content)
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
Then /the card (.*) should not point to "([^\"]*)"$/ do |cardname, content|
|
363
|
-
visit path_to("card #{cardname}")
|
364
|
-
within scope_of("pointer card content") do
|
365
|
-
expect(page).not_to have_content(content)
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
Then /^In (.*) I should see "([^\"]*)"$/ do |section, text|
|
370
|
-
within scope_of(section) do
|
371
|
-
if text.index("|")
|
372
|
-
expect(text.split("|").any? { |t| have_content(t) }).to be
|
373
|
-
else
|
374
|
-
expect(page).to have_content(text)
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
Then /^I should see "([^\"]*)" in the editor$/ do |text|
|
380
|
-
within_frame 0 do
|
381
|
-
expect(page).to have_content(text)
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
Then /^In (.*) I should not see "([^\"]*)"$/ do |section, text|
|
386
|
-
within scope_of(section) do
|
387
|
-
expect(page).not_to have_content(text)
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
class_re = /^In (.*) I should (not )?see a ([^\"]*) with class "([^\"]*)"$/
|
392
|
-
Then class_re do |selection, neg, element, selector|
|
393
|
-
# checks for existence of a element with a class in a selection context
|
394
|
-
element = "a" if element == "link"
|
395
|
-
within scope_of(selection) do
|
396
|
-
verb = neg ? :should_not : :should
|
397
|
-
page.send(verb, have_css([element, selector].join(".")))
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
content_re = /^In (.*) I should (not )?see a ([^\"]*) with content "([^\"]*)"$/
|
402
|
-
Then content_re do |selection, neg, element, content|
|
403
|
-
# checks for existence of a element with a class in a selection context
|
404
|
-
element = "a" if element == "link"
|
405
|
-
within scope_of(selection) do
|
406
|
-
verb = neg ? :should_not : :should
|
407
|
-
page.send(verb, have_css(element, text: content))
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |field, value|
|
412
|
-
expect(field_labeled(field).value).to match(/#{value}/)
|
413
|
-
end
|
414
|
-
|
415
|
-
Then /^"([^"]*)" should be selected for "([^"]*)"$/ do |value, field|
|
416
|
-
element = field_labeled(field).element
|
417
|
-
selected = element.search ".//option[@selected = 'selected']"
|
418
|
-
expect(selected.inner_html).to match /#{value}/
|
419
|
-
end
|
420
|
-
|
421
|
-
Then /^"([^"]*)" should be signed in$/ do |user| # "
|
422
|
-
has_css?(".my-card-link", text: user)
|
423
|
-
end
|
424
|
-
|
425
|
-
When /^I press enter to search$/ do
|
426
|
-
find("#_keyword").native.send_keys(:return)
|
427
|
-
end
|
428
|
-
|
429
|
-
## variants of standard steps to handle """ style quoted args
|
430
|
-
Then /^I should see$/ do |text|
|
431
|
-
expect(page).to have_content(text)
|
432
|
-
end
|
433
|
-
|
434
|
-
Then /^I should see a preview image of size (.+)$/ do |size|
|
435
|
-
find("span.preview img[src*='#{size}.png']")
|
436
|
-
end
|
437
|
-
|
438
|
-
Then /^I should see an image of size "(.+)" and type "(.+)"$/ do |size, type|
|
439
|
-
find("img[src*='#{size}.#{type}']")
|
440
|
-
end
|
441
|
-
|
442
|
-
img_sld = /^within "(.+)" I should see an image of size "(.+)" and type "(.+)"$/
|
443
|
-
Then img_sld do |selector, size, type|
|
444
|
-
within selector do
|
445
|
-
find("img[src*='#{size}.#{type}']")
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
img_should = /^I should see a non-coded image of size "(.+)" and type "(.+)"$/
|
450
|
-
Then img_should do |size, type|
|
451
|
-
element = find("img[src*='#{size}.#{type}']")
|
452
|
-
expect(element[:src]).to match(%r{/~\d+/})
|
453
|
-
end
|
454
|
-
|
455
|
-
Then /^I should see "([^\"]*)" in color (.*)$/ do |text, css_class|
|
456
|
-
page.has_css?(".diff-#{css_class}", text: text)
|
457
|
-
end
|
458
|
-
|
459
|
-
Then /^I should see css class "([^\"]*)"$/ do |css_class|
|
460
|
-
find(css_class)
|
461
|
-
end
|
462
|
-
|
463
|
-
css_should = /^I should see css class "([^\"]*)" within "(.*)"$/
|
464
|
-
Then css_should do |css_class, selector|
|
465
|
-
within selector do
|
466
|
-
find(css_class)
|
467
|
-
end
|
468
|
-
end
|
469
|
-
|
470
|
-
When /^I fill in "([^\"]*)" with$/ do |field, value|
|
471
|
-
fill_in(field, with: value)
|
472
|
-
end
|
473
|
-
|
474
|
-
When(/^I scroll (-?\d+) pixels$/) do |number|
|
475
|
-
page.execute_script "window.scrollBy(0, #{number})"
|
476
|
-
end
|
477
|
-
|
478
|
-
When(/^I scroll (\d+) pixels down$/) do |number|
|
479
|
-
page.execute_script "window.scrollBy(0, #{number})"
|
480
|
-
end
|
481
|
-
|
482
|
-
When(/^I scroll (\d+) pixels up$/) do |number|
|
483
|
-
page.execute_script "window.scrollBy(0, -#{number})"
|
484
|
-
end
|
485
|
-
|
486
|
-
module Capybara
|
487
|
-
module Node
|
488
|
-
# adapt capybara methods to fill in forms to decko's form interface
|
489
|
-
module Actions
|
490
|
-
alias_method :original_fill_in, :fill_in
|
491
|
-
alias_method :original_select, :select
|
492
|
-
|
493
|
-
def fill_in locator, options={}
|
494
|
-
decko_fill_in(locator, options) || original_fill_in(locator, options)
|
495
|
-
end
|
496
|
-
|
497
|
-
def select value, options={}
|
498
|
-
decko_select(value, options) || original_select(value, options)
|
499
|
-
end
|
500
|
-
|
501
|
-
def decko_fill_in locator, options
|
502
|
-
el = labeled_field(:input, locator) || labeled_field(:textarea, locator)
|
503
|
-
return unless el
|
504
|
-
el.set options[:with]
|
505
|
-
true
|
506
|
-
end
|
507
|
-
|
508
|
-
def decko_select value, options
|
509
|
-
el = labeled_field :select, options[:from], visible: false
|
510
|
-
return unless el
|
511
|
-
value = el.find("option", text: value, visible: false)["value"]
|
512
|
-
choose_value el, value
|
513
|
-
true
|
514
|
-
end
|
515
|
-
|
516
|
-
def choose_value el, value
|
517
|
-
id = el["id"]
|
518
|
-
session.execute_script("$('##{id}').val('#{value}')")
|
519
|
-
# session.execute_script("$('##{id}').trigger('chosen:updated')")
|
520
|
-
# session.execute_script("$('##{id}').change()")
|
521
|
-
end
|
522
|
-
|
523
|
-
def labeled_field type, label, options={}
|
524
|
-
label.gsub!(/^\+/, "") # because '+' is in an extra span,
|
525
|
-
# descendant-or-self::text doesn't find it
|
526
|
-
first :xpath,
|
527
|
-
"//label[descendant-or-self::text()='#{label}']/..//#{type}",
|
528
|
-
options.merge(wait: 5)
|
529
|
-
end
|
530
|
-
end
|
531
|
-
end
|
532
|
-
end
|