-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec_helper.rb
62 lines (50 loc) · 1.14 KB
/
spec_helper.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
require 'capybara/rspec'
require 'capybara/webkit'
Capybara.run_server = false
Capybara.default_driver = :webkit
Capybara.default_wait_time = 5
Capybara.app_host =
'http://agorae.test.hypertopic.org'
RSpec.configure do |config|
config.before(:each) do
prefer_language 'fr'
end
end
def a_string()
s = ('a'..'z').to_a.shuffle[0,8].join
end
def in_dialog()
f = find('.ui-dialog')
end
def prefer_language(language)
page.driver.header 'Accept-Language', language
end
def sample(name)
IO.read("spec/samples/#{name}.bib")
end
def field(id)
find_by_id(id).value
end
# for select boxes handled by Chosen
def fill_in_and_select(value, options)
options[:visible] = false
select value, options
end
def wait_until
require "timeout"
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = yield
value
end
end
def downloaded_file_name
wait_until {page.response_headers['Content-Disposition']}.partition('=').last
end
def check_path_content(content)
uri = URI.parse(current_url)
uri.path.should == content
end
def check_query_content(content)
uri = URI.parse(current_url)
url.query.should == content
end