Module: Capybara::Reloads
- Defined in:
- lib/capybara/reloads.rb,
lib/capybara/reloads/version.rb,
lib/capybara/reloads/node/matchers.rb
Defined Under Namespace
Modules: Node
Classes: Error
Constant Summary
collapse
- VERSION =
"0.2.0"
- @@recommended_allow_max_reloads =
2
- @@allow_max_reloads =
By default Capybara::Reloads should have no impact It should be explicitly enabled, by setting to the recommended_allow_max_reloads with Capybara::Reloads.allow_max_reloads = CapybaraReload.recommended_allow_max_reloads
0
- @@only_report =
The goal of Capybara::Reloads is to help identify places where the JS does not load not to hide them. By default Capybara::Reloads will try to reload to see if the error we can continue, but even if we do it will by default report this as an error. In this way we have clearly shown that this example depends on reloading the page and this is the real error here. Not that we can’t find an element on the page but that this element is found sometimes and if we refresh it will be found more often than not
To make Capybara::Reloads continue use only_report
false
- @@before_reload_callback =
Proc.new do |args|
puts "Refreshing the page as an exception occurred: #{args[:exception].message}"
end
- @@reload_callback =
Proc.new do |args|
base = args[:base]
base.session.refresh
end
- @@reload_fixed_it_callback =
Proc.new do |args|
Capybara::Reloads.construct_message(args)
end
Class Method Summary
collapse
Class Method Details
.allow_max_reloads ⇒ Object
60
61
62
|
# File 'lib/capybara/reloads.rb', line 60
def self.allow_max_reloads
@@allow_max_reloads
end
|
.allow_max_reloads=(reloads) ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'lib/capybara/reloads.rb', line 64
def self.allow_max_reloads=(reloads)
if reloads > @@recommended_allow_max_reloads
puts "You are setting Capybara::Reloads.allow_max_reloads to be #{reloads}."
puts "This is more than the recommended value of #{@@recommended_allow_max_reloads} (Capybara::Reloads.recommended_allow_max_reloads)."
puts "Please refer to documentation about why this might be a bad idea."
end
@@allow_max_reloads = reloads
end
|
.before_reload_callback ⇒ Object
81
82
83
|
# File 'lib/capybara/reloads.rb', line 81
def self.before_reload_callback
@@before_reload_callback
end
|
.before_reload_callback=(the_proc) ⇒ Object
85
86
87
|
# File 'lib/capybara/reloads.rb', line 85
def self.before_reload_callback=(the_proc)
@@before_reload_callback = the_proc
end
|
.construct_message(args) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/capybara/reloads.rb', line 43
def self.construct_message args
message = <<-MESSAGE
The example initially failed, but after #{args[:reloads_made]} reloads it was successful.
States are shown below in order:
MESSAGE
args[:states].each_with_index do |state, index|
message += "\n"
message += "State #{index}\n"
message += JSON.pretty_generate(state)
end
message
end
|
.only_report ⇒ Object
73
74
75
|
# File 'lib/capybara/reloads.rb', line 73
def self.only_report
@@only_report
end
|
.only_report=(value) ⇒ Object
77
78
79
|
# File 'lib/capybara/reloads.rb', line 77
def self.only_report=(value)
@@only_report = value
end
|
.recommended_allow_max_reloads ⇒ Object
56
57
58
|
# File 'lib/capybara/reloads.rb', line 56
def self.recommended_allow_max_reloads
@@recommended_allow_max_reloads
end
|
.reload_callback ⇒ Object
89
90
91
|
# File 'lib/capybara/reloads.rb', line 89
def self.reload_callback
@@reload_callback
end
|
.reload_callback=(the_proc) ⇒ Object
93
94
95
|
# File 'lib/capybara/reloads.rb', line 93
def self.reload_callback=(the_proc)
@@reload_callback = the_proc
end
|
.reload_fixed_it_callback ⇒ Object
97
98
99
|
# File 'lib/capybara/reloads.rb', line 97
def self.reload_fixed_it_callback
@@reload_fixed_it_callback
end
|