similar to: How to test modules and custom validators

Displaying 20 results from an estimated 300 matches similar to: "How to test modules and custom validators"

2011 Aug 02
4
Best way to test tasks
I have a task that runs frequently in order to get/import data from another system. Because of this I wanted to know which is the best way to test tasks in order to create the tests needed. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110802/315d630f/attachment.html>
2011 Jul 28
2
RSpec, shoulda-matchers and Rails model attributes validations
I was trying out RSpec framework in a project and got stopped doing the unit test of a model. In particular, doing the test for the associations and the ActiveRecord validations. I started writing the validations but my tests didn''t look DRY at all. Before refactoring the tests checked out and look for other people solutions. I found out shoulda-matchers and Shoulda (which if I
2011 Jul 26
1
ActiveRecord has_many associations
Given the models Country, State, City and Person as follows. class Country < ActiveRecord::Base has_many :states end class State < ActiveRecord::Base belongs_to :country has_many :cities end class City < ActiveRecord::Base belongs_to :state has_many :people end class Person < ActiveRecord::Base belongs_to :city end Is there any way that doesn''t allow to delete
2011 May 31
1
Calendars in Rails
Hi all, I''m currently in the need to implement a calendar in rails. It should be able to present a year, month and day view. The events in these 3 views should be able to be opened, on click, to view the information and/or edit it (according to restrictions). The events will belong to users. One requirement is that users could filter which other users events they want to see (different
2009 Apr 26
1
validators.rb breaks after update from Rails 2.2.2 to 2.3.2
I just updated my rails application from 2.2.2 to 2.3.2 and the following message is displayed while trying to start with ./script/ server: [code] => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/ active_support/core_ext/module/aliasing.rb:33:in `alias_method'': undefined method `valid?''
2010 Jan 20
1
R.oo installation warnings?
I got the following warnings when I install R.oo. Are these warnings normal? Should I reinstall the package as mentioned in the warnings? How to reinstall? The sessionInfo() is at the end. > install.packages("R.oo", dependencies=T) Warning in install.packages("R.oo", dependencies = T) : argument 'lib' is missing: using '/utility/R' also installing the
2006 Jul 26
0
Using validators for appending to a HABTM association
class User < ActiveRecord::Base has_and_belongs_to_many :projects end class Project < ActiveRecord::Base has_and_belongs_to_many :users end class ProjectController < ApplicationController def add_user @project = Project.find(params[:project_id]) @user = User.find(params[:id]) @project.users << @user unless @project.users.include?(@user) # I''d
2013 Oct 22
2
[Proposal] Add ability to read authorized keys from shell script instead of file
File authorized_keys is unusable for mass key storage and manipulation. I wan to store keys in something like mysql server, but It will add big unwanted dependency to package. What if we use auth_rsa.c but instead search in file send key to some script and read sigle return value if key finded and empty if not. I think it will be very customizable. -- With Best Regards, Constantine
2008 Nov 28
2
Sendmail - STARTTLS not appear on one client
Hi, I have Sendmail configured to use STARTTLS for authentication. On all internet connections and computers (that I have tested) works connection over encrypted SMTP flawlessly. Today I was setting up mail client on PC of my customer and standardily checked boxes, that I want to use SSL for POP3 and SMTP. Next I wanted to check configuration (by sending email from this mailbox to this mailbox)
2004 Mar 14
2
Status report, including progess toward 0.3
Greetings all, I''m trying to get a good start on 0.3, so I checked in quite a few changes tonight. I am working through all my old emails where people had submitted patches or bug reports, and tried to do as many as I could. There are a few more still in my queue. See the changelog for a complete record of what I fixed. The hardest one turned out to be validators. They were
2006 Feb 04
4
Page caching feeds and cache file extensions
I have a feeds controller which generates RSS and Atom pages. I put ''caches_page :show'' in it. The problem is that the pages are saved with an html extension. As a result, browsers display the cached feeds as HTML rather than XML, and feed validators complain. There''s an option to set ''Base.page_cache_extension'' globally, but I don''t want
2004 Feb 24
1
Tweaks for 0.2
I can make these changes tonight, but if somebody else could do it that would be swell too. 1) Validators currently do not work for the dumbest reason ever... the "Clone" method in wxRbValidator needs to be changed to: virtual wxObject* Clone() const; while in there, I think the validator methods need to be renamed to proper ''wxruby'' things ("validate"
2006 Jan 30
8
Translating a validtion flash
I''m a belgian Rails user (Dutch is my native language). I wondered if it is possible to translate error messages (generated by validators). I know how to create my own error messages: def method content rescue logger.error(...) flash[:notice] = ''My own error message" redirect_to(...) But where can I find the validator''s .rb files, so I can change them?
2005 Nov 28
4
validates_format_of nil
I''ve noticed that validates_format_of will return invalid if the field is nil. Question 1) How should we declare a validation that will validate it with a regex if it is set, but, if the field is not set, just move on Question 2) Why is it done this way? The other validators are only invoked if the field is set . If you want to declare the field mandatory, you add a
2006 Apr 24
1
JSON Validator
Maybe I am missing something very obvious, but guys does anyone know of any JSON Validators around? The reason is when you do an eval(json_response), if the JSON format is not proper, you''ll only get an error like "Can''t eval..". But, this doesn''t help identify where the actual problem lies. Is there some kind of a schema or something we can write to check
2006 Jun 08
5
Field names in validators
Hi! Is there a (simple) way to use alternative field names in validation messages? For example, if I have a validator like this one: validates_presence_of :email how can I make it print a message like "E-Mail Address can''t be blank" instead of "Email can''t be blank"? I can override the "can''t be blank" part by using the :message
2009 Jan 18
2
after_save -- stack level too deep
Hi all, I''m running into a brick wall trying to figure out my problem here. I have a model that has a boolean property called "paid". I''d like to add the following to my model: def after_save self.amount == self.splits.sum(:amount) ? self.update_attribute (:paid, true) : self.update_attribute(:paid, false) end The problem is, when I do this I get an error that
2006 Aug 14
2
Plugins: Validation Reflection and Client-Side Validation
I''ve just put two plugins on RubyForge. Included below are the READMEs. You can get the plugins at svn://rubyforge.org//var/svn/valirefl/validation_reflection/trunk svn://rubyforge.org//var/svn/clientsidevali/client_side_validation/trunk Michael Validation Reflection ===================== Version 0.2, 2006-08-06 This plugin adds reflective access to validations -
2008 Apr 04
6
validates_numericality_of :not_equal_to
I have a situation in which I want to validate a number is not zero. Both positive and negative values are acceptable, just not zero. validates_numericality_of has an :equal_to attribute, but I don''t see a :not_equal_to. I have not yet been able to find anyone who has discussed this. I did find information about custom validators, so I am now using a custom validator to check the field
2006 Aug 09
0
class validations - instance equivalent?
does anyone know if it''s possible to use rails validators from validate() I have some conditional validation to do, and using :if => Proc.new... on the class validators is getting messy, so I''m doing the condition checking in one place - validate() - except of course I can''t use rails validators there. I''ve started writing my own validators but I hate to