ruby on rails - Paperclip Shoulda Matchers for Miniteset -


the paperclip documentation provides instruction setting paperclip's shoulda matchers rspec , test::unit. when tried set them minitest wasn't successful (i followed same instructions test::unit).

does knows requires make papercips shoulda matchers work minitest?

in case comes here google did...this ended working me minitest-spec-rails & custom assertions

# test_helper.rb  require 'paperclip/matchers'  class activesupport::testcase   extend paperclip::shoulda::matchers   include paperclip::shoulda::matchers    # ... other code  end  module minitest   module assertions     ##     # passes if matcher.matches?(subject) returns true     #     # example:     #     #   def test_validations     #     assert_must be_valid, @user     #   end     def assert_must(matcher, subject, msg = nil)       msg = message(msg)         if matcher.respond_to? :failure_message           matcher.failure_message # rspec 3.x, 1.1         else           matcher.failure_message_for_should # rspec 2.x, 1.2         end       end        assert matcher.matches?(subject), msg     end      ##     # facilitator assert_must use minitest-spec. if no subject     # given, defaults matching against current `subject` or     # instance variable `@subject`.     #     # example:     #     #   subject { order.new }     #     #   "should have associations"     #     must belong_to :account     #     must have_many :line_items     #   end     def must(matcher, subject = @subject || subject, msg = nil)       assert_must matcher, subject, msg     end      ##     # passes if matcher.matches?(subject) returns false     #     # example:     #     #   def test_validations     #     assert_wont be_valid, @user     #   end     def assert_wont(matcher, subject, msg = nil)       msg = message(msg)         if matcher.respond_to? :failure_message_when_negated # rspec 3.x           matcher.failure_message_when_negated # rspec 3.x         elsif matcher.respond_to? :failure_message_for_should_not           matcher.failure_message_for_should_not # rspec 2.x, 1.2         else           matcher.negative_failure_message # rspec 1.1         end       end        if matcher.respond_to? :does_not_match?         assert matcher.does_not_match?(subject), msg       else         refute matcher.matches?(subject), msg       end     end      ##     # facilitator assert_wont use minitest-spec. if no subject     # given, defaults matching against current `subject` or     # instance variable `@subject`.     #     # example:     #     #   subject { user.new }     #     #   "should validate"     #     wont have_valid(:email).when("foo", "foo@bar", "@bar.com")     #   end     def wont(matcher, subject = @subject || subject, msg = nil)       assert_wont matcher, subject, msg     end   end end 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -