Displaying 20 results from an estimated 300 matches similar to: "Problem validating boolean"
2007 Nov 29
3
Stylistic preferences
What are people''s opinions on which of these two styles is better to
use?
1) before
---------------------------
module UserSpecHelper
include GenericSpecHelper
def valid_sms_attributes(phone_number="12345")
{ :phone_number => phone_number }
end
end
describe User, "with phone number" do
include UserSpecHelper
before(:each) do
@user =
2009 Feb 28
7
be_valid (validates_format_of ..., :on => :create)
Greetings,
How to write Example which will check if model''s variable''s
format is valid using :on => :create, like this:
class User < ActiveRecord::Base
...
validates_format_of :email, :with => /.../, :on => :create
...
Using following code is not right:
it "should ..." do
@user = users(:example_user)
@user.email =
2010 Aug 28
1
validates_uniqueness_of missing in rails 3.0 rc2?
Has anybody noticed validates_uniqueness_of missing in rails 3.0 rc2? I''m not sure if this is a bug or I''m just doing something wrong.
Here''s what I''m doing.
Class 1:
class Title < ActiveRecord::Base
validates_length_of :language, :is => 3
validates_uniqueness_of :language, :scope => :book_id
validate :language,
2007 Nov 13
2
Trouble stubbing a method
Hey guys,
I''ll try to explain this without the model code at first, since there is so
much, but if need be, I''ll pastie it.
I have an Order model that makes API calls to a payment
gateway(TrustCommerce) during validation(to verify the credit card
information). I''d like to stub this behavior to avoid thousands of calls to
TrustCommerce a day(autotest).
All the calls
2007 Jul 10
2
Multiple calls to a class method
Hi
Just wrote myself a Date.extract_from_rails_hash to handle parsing
the "date(1i)", "date(2i)" parameters created in the controller
params. I''ve got a method that needs to call this either once or
twice, depending on the contents of the form (one section of the form
is rendered conditionally). So I had two specs for the case where
the second form section
2010 Mar 24
2
Mock "Consent_6335" received unexpected message :marked_for_destruction? with (no args)
I have a mock object (Person) that is associated with another object
(my_object) through a belongs_to association. When I check whether
my_object is valid (my_object.should be_valid), I am getting an error
like the following:
Mock "Person_6338" received unexpected
message :marked_for_destruction? with (no args)
Checking the list of methods on the mock,
2007 Jul 26
3
Spec for validation plugin
Hi,
I''m writing a specification for a model called Location which has a
post_code attribute which should be a valid UK postcode. I''m using the
http://svn.designbyfront.com/rails/plugins/validates_as_uk_postcode/
validates_as_uk_postcode plugin to handle the validation but I''m not sure
how I should properly specify my model.
Heres the model code:
class Location <
2011 Mar 07
1
@attr.merge?
Hi,
What does the @attr.merge in something like:
it "should require a password" do
User.new(@attr.merge(:password => "", :password_confirmation =>
"")).
should_not be_valid
end
do?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
2012 May 24
0
Ruby on Rails Tutorial Chapter 6 RSpec tests failing
Hello all:
I''m a RoR newbie who is currently following the Ruby on Rails
Tutorial: Learning by Example book (http://ruby.railstutorial.org/
chapters/modeling-users#sec:adding_a_secure_password). The following
Chapter 6 RSpec tests are failing:
Failures:
1) User [31mFailure/Error:[0m [31mit { should be_valid }[0m
[31mexpected valid? to return true, got false[0m [36m # ./spec/models/
2007 Dec 11
3
can''t access helper methods for model testing
I would like to have some valid mock models readily available in the
helper module, but when I try to access the helper I get the error
saying that the method is not found.
=======
describe MembersHelper do # Helper methods can be called directly in the
examples (it blocks)
def valid_member_mock
member = mock_model(Member)
member.stub!(:first_name).and_return("Joe")
2007 Sep 04
16
Failure Messages in RSpec
Having used JUnit and Test::Unit, I''m quite used to having the ability to
insert a failure message, which helps when tests fail.
For instance, the example RSpec that is generated for a model class
specifies that the model class is valid. Assuming this were supposed to be
true, and it failed, I''ve now got to duplicate the code in the test in order
to find out why it
2009 Jan 16
3
rspec model testing - test on user defined validation- How do I test that the create failed.
I''m new to rspec and looking for way to test a validation I added to a model.
The test checks to see that if field1 has a value then field2 must be nil
and vice versa.
-------------------------------
When I did the rspec_scaffold it generated one test which worked
before :each do
@valid_attributes = {
:field1 = "value for field1"
:field2 = "value for
2007 Nov 09
9
fixture_file_upload and edge rspec?
Hi all,
I had some specs that were using fixture_file_upload that were
passing just fine. Then I froze edge rails to get some 2.0
functionality, then a I upgraded to trunk rspec to deal with
uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper
After a couple other of tribulations, I have now gotten down to just
a couple of not passing specs, all using the fixture_file_upload.
2008 Nov 04
9
RSpec and PostgreSQL not playing nicely together
Here is a very simple spec:
--
require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'')
describe Product, "The Product model" do
describe "When a new blank product object gets created" do
before(:each) do
@product = Product.new
end
it "should not be valid" do
@product.should_not be_valid
2007 May 15
5
Rspec + Oracle
Hi all.
Does anybody use Rspec with Oracle? I have RoR app + Oracle DB. I use
Rspec 0.9.4.
I have installed Rspec plugin and generated spec for model Country.
If I use "@countries = Country.new" in my spec I get
"ArgumentError in ''Country should be valid''
block not supplied
/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:
12:in
2008 Mar 03
2
stuck on testing validation
Hello,
I must be doing something dumb, but here it goes...
why does this work?
before(:each) do
@work = Work.new
end
#for testing validates_presence_of :title
it "should require a title" do
@work.title = nil
@work.should_not be_valid
end
while this doesn''t:
def valid_work_attributes
{
:title => "guernica",
:description
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi,
I''m a bit stuck with mocking a unit test of a join model with regards to a
validates_uniqueness_of clause.
I have
class Book < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clip < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clipping < AR:B
belongs_to :book
belongs_to :clip
validates_uniqueness_of :clip_id,
2008 Jan 23
6
sharing specs in a subclass
Hi
I''ve spec''d a class and they pass.
Now I''d like to assure that any subclass of this class also passes
the same specs.
Any suggestions for a clever way to handle this?
I''d prefer to keep the existing specs as is (eg instead of moving
everything into shared behaviors, or doing something to all the
''describe'' lines)
thanks
linoj
2010 Aug 11
6
rspec2 not working with shoulda
I am using rails edge. I am using gem "rspec-rails", "= 2.0.0.beta.
19" .
I have following code at spec/models/user_spec.rb
require ''spec_helper''
describe User do
it { should validate_presence_of(:email) }
it { should validate_presence_of(:name) }
end
Here is my gemfile
group :development, :test do
gem ''factory_girl_rails'',
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had
originally written my spec to check for allowing the desired fields, and
then none of the other regular db fields. Unfortunately this isn''t
satisfactory, because attr_protected could have been used instead, which
of course wouldn''t prevent mass assignment to any whatever=(val) method.
I''m thinking