Skip to content

Commit ae50bf9

Browse files
committed
Generated mock_[model] method adds (optional) stubs on each reference.
- This fixes an edge case bug that appears when defining stubs using the lazy-eval'd block form (obj.stub(:m) {v}). - Closes #218.
1 parent 0115007 commit ae50bf9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/generators/rspec/scaffold/templates/controller_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
describe <%= controller_class_name %>Controller do
44

55
def <%= mock_file_name %>(stubs={})
6-
@<%= mock_file_name %> ||= mock_model(<%= class_name %>, stubs).as_null_object
6+
(@<%= mock_file_name %> ||= mock_model(<%= class_name %>).as_null_object).tap do |<%= file_name %>|
7+
<%= file_name %>.stub(stubs) unless stubs.empty?
8+
end
79
end
810

911
<% unless options[:singleton] -%>

0 commit comments

Comments
 (0)