Displaying 20 results from an estimated 400 matches similar to: "Ruby on Rails Tutorial Chapter 6 RSpec tests failing"
2007 May 01
2
Problem validating boolean
Hi
I''ve got a problem validating a boolean and I can''t see what the
problem is. Here''s my model:
class FinanceAgreement < ActiveRecord::Base
belongs_to :asset
validates_presence_of :finance_company
validates_inclusion_of :balance, :in => 0.01..10_000_000
validates_inclusion_of :term, :in => 1..600
validates_numericality_of
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 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 =
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'',
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,
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 =
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.
2007 Oct 17
16
rspec causing validates_presence_of to validate twice?
I had posted this on the regular Rails list, but upon trying this in
script/console, it seems like the behavior only exists when running rspec.
I''m getting some weird behavior in one of my models. I have a model
defined something like this
class User < ActiveRecord::Base
attr_accessor :password
validates_presence_of :password
end
If I validate the model without specifying a
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 <
2007 Nov 01
3
autotest debugger?
Hi,
I keep facing problems with autotest, and I don''t know what''s happening
in the background, is there anyway to know what''s happening while
testing?
Example:
@user = User.new
@user.email = "testcom"
@user.errors.on(:email).should_not be_empty
...throws error failure
- You have a nil object when you didn''t expect it!
- You might have expected an
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 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
2009 Jun 13
2
removing Mocha; 'spec spec' fails but the specific model file passes
I happened to mix ryan bates'' authentication scaffold with
rspec_scaffold on a demo project.
and ran into the problem of mixing mock frameworks...ryan uses mocha.
So, as a learning experience, I choose to redo ryan''s tests without
mocha but ran into a strange problem with tests of the User model.
With debugging you can see....
If you run just the user_spec.rb file, everything
2007 Jan 22
1
Observed models cause failures with DRBSpec ?
Hi all !
I don''t believe I am the only one using model observers, right ?
Well, here''s a nice one:
$ drbspec spec
.
Finished in 0.125322 seconds
1 specification, 0 failures
$ drbspec spec
F
1)
''A user with an inactive and an active project should be able to
return active projects only'' FAILED
[] should == [#<Spec::Mocks::Mock:0xb75590bc
2007 Aug 12
3
Scope and specing models
Hello all, I''m currently having an issue with some specs, specifically scope
issues (probably more of a scope issue than a spec issue at this point)...
Here''s the error:
ActiveRecord::AssociationTypeMismatch in ''A new User should know what role
it has''
Role expected, got NilClass
D:/ruby/projects/restful_authentication_test/config/../app/models/role.rb:5:in
2007 May 25
0
still seeing strange behaviour with spec_server
hi all
a few days ago i reported spec_server didn''t appear to be running
specs and the command itself was running slowly. I''ve since tried it
on a new system with a clean install of ubuntu 7.04, rails 1.2.3 and
rspec 1.0.2 and I''m seeing the same behavior.
*** without spec_server ***
x at holly:~/rails/test$ time ruby script/spec spec/models/user_spec.rb
.
Finished in
2011 Feb 07
0
Error loading rubygems
Hi,
During an operation (rspec related) that required loading rubygems
(from config/boot.rb file) I got the following error message:
~/config/boot.rb:1:in `require'': no such file to load -- rubygems
(LoadError)
~/config/boot.rb:1
from ~/config/application.rb:1:in `require''
from ~/config/application.rb:1
from ~/config/environment.rb:2:in `require''
from
2008 Jun 04
8
Not running correct specs under autotest:
I know this isn''t autotest-users but I''m not sure where else to bring this up:
[["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 2008]]
[["app/controllers/contents_controller.rb", Wed Jun 04 14:11:03 +0100 2008]]
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S
script/spec -O spec/spec.opts spec/models/user_spec.rb
2009 Oct 08
0
autospec cannont find gems
I am trying to install rspec for rails and have the following gems
install
C:\INSTAN~3.0-W\rails_apps\katai>gem list --local
*** LOCAL GEMS ***
actionmailer (2.3.4, 2.0.2)
actionpack (2.3.4, 2.0.2)
activerecord (2.3.4, 2.0.2)
activeresource (2.3.4, 2.0.2)
activesupport (2.3.4, 2.0.2)
authlogic (2.1.2)
autotest-rails (4.1.0)
builder (2.1.2)
capistrano (2.5.9, 2.1.0)
cgi_multipart_eof_fix
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,