OSDN Git Service

add rspec-rails
[praisedb/praisedb.git] / vendor / plugins / rspec-rails / lib / spec / rails / extensions / action_view / base.rb
1 module ActionView #:nodoc:
2   class Base #:nodoc:
3     include Spec::Rails::Example::RenderObserver
4     cattr_accessor :base_view_path
5
6     def render_partial_with_base_view_path_handling(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
7       if partial_path.is_a?(String)
8         unless partial_path.include?("/")
9           unless self.class.base_view_path.nil?
10             partial_path = "#{self.class.base_view_path}/#{partial_path}"
11           end
12         end
13       end
14       begin
15         render_partial_without_base_view_path_handling(partial_path, local_assigns, deprecated_local_assigns)
16       rescue ArgumentError # edge rails > 2.1 changed render_partial to accept only one arg
17         render_partial_without_base_view_path_handling(partial_path)
18       end
19     end
20     alias_method_chain :render_partial, :base_view_path_handling
21
22     def render_with_mock_proxy(options = {}, old_local_assigns = {}, &block)
23       if render_proxy.__send__(:__mock_proxy).__send__(:find_matching_expectation, :render, options)
24         render_proxy.render(options)
25       else
26         unless render_proxy.__send__(:__mock_proxy).__send__(:find_matching_method_stub, :render, options)
27           render_without_mock_proxy(options, old_local_assigns, &block)
28         end
29       end
30     end
31     alias_method_chain :render, :mock_proxy
32   end
33 end