Skip to content
This repository
Browse code

Update README with a section for test helper

  • Loading branch information...
commit 587ca88ba36f5c6900ac1b9657f5daf97d81a628 1 parent b0bfc1d
Andreas Loupasakis authored January 13, 2013

Showing 1 changed file with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. 30  README.md
30  README.md
Source Rendered
@@ -362,6 +362,36 @@ without the cents part.
362 362
 This will render a formatted money value including the currency symbol and
363 363
 without the cents part.
364 364
 
  365
+### Testing
  366
+
  367
+If you use Rspec there is an test helper implementation.
  368
+Just write `require "money-rails/test_helpers"` in spec_helper.rb and
  369
+`include MoneyRails::TestHelpers` inside a describe block you want to
  370
+use the helper.
  371
+
  372
+* the `monetize` matcher
  373
+
  374
+```
  375
+monetize(:price_cents).should be_true
  376
+```
  377
+This will ensure that a column called `price_cents` is being monetized.
  378
+
  379
+```
  380
+monetize(:price_cents).as(:discount_value).should be_true
  381
+```
  382
+By using `as` chain you can specify the exact name to which a monetized
  383
+column is being mapped.
  384
+
  385
+```
  386
+monetize(:price_cents).with_currency(:gbp).should be_true
  387
+```
  388
+
  389
+By using the `with_currency` chain you can specify the expected currency
  390
+for the chosen money attribute. (You can also combine all the chains.)
  391
+
  392
+For examples on using the test_helpers look at
  393
+[test_helpers_spec.rb](https://github.com/RubyMoney/money-rails/blob/master/spec/test_helpers_spec.rb)
  394
+
365 395
 ## Supported ORMs/ODMs
366 396
 
367 397
 * ActiveRecord (>= 3.x)

0 notes on commit 587ca88

Please sign in to comment.
Something went wrong with that request. Please try again.