Comments (11)
Could you provide some examples? Throw it in a gist, perhaps: http://gist.github.com
Thanks!
from shoulda.
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.
I'm having the same issue, did you find a way to fix it?
from shoulda.
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.
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.
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.
Is this still an issue with shoulda 2.11?
from shoulda.
This is still an issue as of 2.11.3.
from shoulda.
Is this still an issue with shoulda 3.0?
from shoulda.
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.
@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)
- weird shoulda ensure_exclusion_of with_message HOT 1
- Add matcher for validates_with HOT 9
- wrong constant name 1 HOT 3
- validates_presence_of :media (carrierwave) failing rails 4.0.4, rspec HOT 2
- Deprecation with Rspec 3 HOT 1
- Please update dependencies HOT 1
- Add associations for posts and categories HOT 1
- Unable to include shoulda tests in a module HOT 3
- NoMethodError validate_presence_of HOT 2
- Undefined method `should` for model HOT 1
- Undefined method validate_uniqueness_of error on sinatra app HOT 1
- time error in minitest HOT 3
- Rubygems.org not updated with latest version HOT 2
- shoulda-matchers HOT 6
- Not worked with rails 5.0.1 old project? HOT 6
- Still Maintained? HOT 10
- Migrations incompatibilities in Rails 5.1+ HOT 3
- 2.11.3 broken by rake 12.3.3 HOT 2
- Use transactions to save time setting up context HOT 3
- Using outdated shoulda-matchers version HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shoulda.