Skip to content

Commit af78962

Browse files
committed
Merge pull request #1452 from Futurelearn/faster-view-specs
Halve the time it takes to run view specs by enabling the resolver cache
2 parents 93c38d8 + 892d501 commit af78962

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

lib/rspec/rails/example/view_example_group.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _default_render_options
114114

115115
render_options = { :template => template }
116116
render_options[:handlers] = [handler] if handler
117-
render_options[:formats] = [format] if format
117+
render_options[:formats] = [format.to_sym] if format
118118
render_options[:locales] = [locale] if locale
119119

120120
render_options
@@ -155,9 +155,6 @@ def _include_controller_helpers
155155
view.lookup_context.prefixes << _controller_path
156156
end
157157

158-
# fixes bug with differing formats
159-
view.lookup_context.view_paths.each(&:clear_cache)
160-
161158
controller.controller_path = _controller_path
162159
controller.request.path_parameters[:controller] = _controller_path
163160
controller.request.path_parameters[:action] = _inferred_action unless _inferred_action =~ /^_/

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _assigns
121121
view_spec.render
122122

123123
if ::Rails::VERSION::STRING >= '3.2'
124-
expect(view_spec.received.first).to eq([{:template => "widgets/new", :locales=>['en'], :formats=>['html'], :handlers=>['erb']}, {}, nil])
124+
expect(view_spec.received.first).to eq([{:template => "widgets/new", :locales=>['en'], :formats=>[:html], :handlers=>['erb']}, {}, nil])
125125
else
126126
expect(view_spec.received.first).to eq([{:template => "widgets/new.en.html.erb"}, {}, nil])
127127
end

0 commit comments

Comments
 (0)