thoughtbot/shoulda-matchers — pull request #358 by anujbiyani (2013-09-13 17:48:40+00:00)
Title: add context_matcher subclass

:warning: tests currently don't pass. I'm not sure how to fix it, could use some help. The trouble I'm having is I don't know how to ensure the model on which validations are run is in the `:customisable` context. I'm fairly new to Ruby so maybe my Ruby-fu isn't quite up to par =) .

```
$ rake
>> BUNDLE_GEMFILE=/Users/abiyani/code/shoulda-matchers/gemfiles/3.2.gemfile bundle exec /Users/abiyani/.rvm/gems/ruby-2.0.0-p195@shoulda-matchers/bin/rake
....................................................................................................................................F................................................................................................................................................F.....................................................................................................................................................................................................................

Failures:

1) Shoulda::Matchers::ActiveModel::ContextMatcher on
Failure/Error: it { instance_with_validations(:on => :customisable).should matcher.on(:customisable) }
Expected validation for 'attr' to run only on 'customisable', but didn't.
# ./spec/shoulda/matchers/active_model/context_matcher_spec.rb:7:in `block (3 levels) in '

2) Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher with a context-dependent validation with the validation context matches
Failure/Error: validating_numericality(:on => :customisable).should matcher.on(:customisable)
Expected validation for 'attr' to run only on 'customisable', but didn't.
# ./spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb:140:in `block (4 levels) in '

Finished in 7.02 seconds
491 examples, 2 failures
```