Skip to content

Commit 02e23c1

Browse files
Sam PhippenLaurent Cobos
authored andcommitted
Fix #1865 by memoizing generated method name. (#1872)
The problem here is that rails calls `#method_name` on the example a number of times in order to correctly generate the screenshot and then manipulate it. Given that we were randomising the integer that was generated on every call, this didn't work. This patch solves the problem by memoizing the generated method name so that the screenshot path is generated once per example and then correctly accessed on subsequent method calls.
1 parent c5fc2e5 commit 02e23c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/rspec/rails/example/system_example_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def passed?
3535

3636
# @private
3737
def method_name
38-
[
38+
@method_name ||= [
3939
self.class.name.underscore,
4040
RSpec.current_example.description.underscore,
4141
rand(1000)

0 commit comments

Comments
 (0)