Giter VIP home page Giter VIP logo

Comments (11)

qrush avatar qrush commented on September 13, 2024

Could you provide some examples? Throw it in a gist, perhaps: http://gist.github.com

Thanks!

from shoulda.

benvds avatar benvds commented on September 13, 2024

Maybe the problem could be solved if for every attribute all the activerecord error messages are set. But with many models and attributes this is a hell of a lot of work. Instead i use generic activerecord error messages which are just fine.

The classes can be found here:
http://gist.github.com/132526

I get the following error message:

[
1) Failure:
test: Customer should require first_name to be set. (CustomerTest)
    [vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/assertions.rb:50:in `assert_accepts'
     vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/active_record/macros.rb:46:in `__bind_1245402819_887562'
     vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:253:in `call'
     vendor/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:253:in `test: Customer should require first_name to be set. ']:

Expected errors to include "translation missing: nl, activerecord, errors, messages, blank" when first_name is set to nil, got errors: comment translation missing: nl, activerecord, errors, models, customer, attributes, comment, too_long (nil)city translation missing: nl, activerecord, errors, models, customer, attributes, city, blank (nil)city translation missing: nl, activerecord, errors, models, customer, attributes, city, too_long (nil)postal_code translation missing: nl, activerecord, errors, models, customer, attributes, postal_code, blank (nil)postal_code translation missing: nl, activerecord, errors, models, customer, attributes, postal_code, too_long (nil)identification translation missing: nl, activerecord, errors, models, customer, attributes, identification, blank (nil)identification translation missing: nl, activerecord, errors, models, customer, attributes, identification, too_long (nil)street translation missing: nl, activerecord, errors, models, customer, attributes, street, blank (nil)street translation missing: nl, activerecord, errors, models, customer, attributes, street, too_long (nil)phone translation missing: nl, activerecord, errors, models, customer, attributes, phone, blank (nil)phone translation missing: nl, activerecord, errors, models, customer, attributes, phone, too_long (nil)last_name translation missing: nl, activerecord, errors, models, customer, attributes, last_name, blank (nil)last_name translation missing: nl, activerecord, errors, models, customer, attributes, last_name, too_long (nil)first_name translation missing: nl, activerecord, errors, models, customer, attributes, first_name, blank (nil)first_name translation missing: nl, activerecord, errors, models, customer, attributes, first_name, too_long (nil)]

from shoulda.

 avatar commented on September 13, 2024

I'm having the same issue, did you find a way to fix it?

from shoulda.

taryneast avatar taryneast commented on September 13, 2024

I've got a patch that's working for m (ie my own tests in my own rails project run fine now). but it'll take time for me to write shoulda-compatible tests.

I'll put the patch up somewhere so you can see.

Mostly it's a matter of adding the :attribute=> and :count => into the correct places.

from shoulda.

taryneast avatar taryneast commented on September 13, 2024

ok, here's the patch.
http://pastie.org/662116

The problem: nothing was passing the actual attribute into the default_error_messages method, so the tests were all testing against:
"Please enter a value for {{attribute}}"

instead of, say:
"Please enter a value for Myfield"

from shoulda.

universal avatar universal commented on September 13, 2024

i had the same problem in a rails3 project which was mainly due to that most error messages have been moved from activerecord.errors... to errors...

the fix is simple, but most likely breaks backwards compatability. couldn't run the shoulda tests using rails3 since the loading process seems to have been changed. but with my changes quite a bunch of tests fail because of not finding the correct default translation.

i've put the changes along with some changes to fix rails3 deprecation warnings in my fork in the rails3 branch:

http://github.com/universal/shoulda/tree/rails3

from shoulda.

jferris avatar jferris commented on September 13, 2024

Is this still an issue with shoulda 2.11?

from shoulda.

carlosramireziii avatar carlosramireziii commented on September 13, 2024

This is still an issue as of 2.11.3.

from shoulda.

gabebw avatar gabebw commented on September 13, 2024

Is this still an issue with shoulda 3.0?

from shoulda.

taryneast avatar taryneast commented on September 13, 2024

Dear "is this still an issue" people... build a test case for it... if your code passes, then it's not an issue anymore. :)

from shoulda.

gabebw avatar gabebw commented on September 13, 2024

@taryneast - can you please file a pull request over at shoulda-matchers? (That's where all of the "real code" lives now. Shoulda has become just a meta-gem that depends on that code.)

Thanks,
Gabe

from shoulda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.