Created
May 17, 2013 03:27
-
-
Save sevenseacat/5596719 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec::Matchers.define :assign_to do |variable| | |
| chain :with do |value| | |
| @value = value | |
| end | |
| match do |response| | |
| if @value | |
| assigns[variable] == @value | |
| else | |
| assigns.has_key?(variable) | |
| end | |
| end | |
| failure_message_for_should do |model| | |
| if @value | |
| "Subject: @#{variable} | |
| Expected: #{@value.inspect} | |
| Actual: #{assigns[variable].inspect}" | |
| else | |
| "Subject: @#{variable} | |
| Expected: anything | |
| Actual: not set" | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment