Top Level Namespace
Defined Under Namespace
Modules: MyGenerators, MySpec, Rails
Instance Method Summary
collapse
Instance Method Details
#any_old(type, stubs = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/generators/my_spec/scaffold/templates/inherited_resources_stubs.rb', line 6
def any_old(type, stubs={})
type = type.to_s.camelize.constantize
ivar = '@mock_' + type.name.downcase
(mock_obj = instance_variable_get(ivar) || mock_model(type).as_null_object).tap do |node|
node.stub(stubs) unless stubs.empty?
end
instance_variable_set(ivar, mock_obj)
mock_obj
end
|
#john_q(type, stubs = {}) ⇒ Object
2
3
4
|
# File 'lib/generators/my_spec/scaffold/templates/inherited_resources_stubs.rb', line 2
def john_q(type, stubs={})
any_old type, stubs
end
|
#stub_inherited_resources_helpers(view, resource = nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/generators/my_spec/scaffold/templates/inherited_resources_stubs.rb', line 16
def stub_inherited_resources_helpers(view, resource=nil)
view.stub(:resource_url) {"/foobar"}
view.stub(:edit_resource_url) {"/foobar"}
view.stub(:resource_url) {"/projects/#{resource.try(:id) || '1'}/tags/1}"}
view.stub(:resource_url).with(resource) {"/projects/#{resource.try(:id) || '1'}/tags/1"}
view.stub(:new_resource_url) {"/projects/#{resource.try(:id) || '1'}/tags/new"}
view.stub(:edit_resource_url) {"/projects/#{resource.try(:id) || '1'}/tags/#{resource.try(:id) || '1'}/edit"}
view.stub(:edit_resource_url).with(resource) {"/projects/1/tags/#{resource.try(:id) || '1'}/edit"}
view.stub(:collection_url) {"/projects/1/tags"}
view.stub(:parent_url) {"/projects/1"}
end
|