Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Document how to stub route helper functions in isolated tests. Addres…

…ses #506.
  • Loading branch information...
commit dbe8a81ca7d4d9ae87b4b62926a0ba6379397fbc 1 parent 18e27a5
@carols10cents authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 README.md
View
21 README.md
@@ -390,6 +390,27 @@ Draper::ViewContext.test_strategy :fast do
end
```
+#### Stubbing route helper functions
+
+If you are writing isolated tests for Draper methods that call route helper
+methods, you can stub them instead of needing to include Rails.
+
+To get access to the Draper `helpers` in your test, include them in your tests:
+
+```ruby
+describe YourDecorator do
+ include Draper::ViewHelpers
+end
+```
+
+Then you can stub the specific route helper functions you need using your
+preferred stubbing technique (this example uses mocha):
+
+```ruby
+helpers.stubs(users_path: '/users')
+```
+
+
## Advanced usage
### Shared Decorator Methods
Please sign in to comment.
Something went wrong with that request. Please try again.