1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Improve documentation about stubbing route helpers

* Get rid of an unnecessary newline
* Change 'include Rails' to 'require Rails'
* Clarify when you would need to explicitly include ViewHelpers
* Switch from mocha `stubs` to RSpec `stub`
This commit is contained in:
Carol Nichols 2013-04-05 13:54:49 -04:00
parent dbe8a81ca7
commit 943f25bdef

View file

@ -393,9 +393,12 @@ 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.
methods, you can stub them instead of needing to require Rails.
To get access to the Draper `helpers` in your test, include them in your tests:
If you are using RSpec, minitest-rails, or the Test::Unit syntax of minitest,
you already have access to the Draper `helpers` in your tests since they
inherit from `Draper::TestCase`. If you are using minitest's spec syntax
without minitest-rails, you can explicitly include the Draper `helpers`:
```ruby
describe YourDecorator do
@ -404,13 +407,12 @@ end
```
Then you can stub the specific route helper functions you need using your
preferred stubbing technique (this example uses mocha):
preferred stubbing technique (this example uses RSpec's `stub` method):
```ruby
helpers.stubs(users_path: '/users')
helpers.stub(users_path: '/users')
```
## Advanced usage
### Shared Decorator Methods