Displaying 5 results from an estimated 5 matches for "default_attributes".
2008 Mar 17
4
RSpec''ing model association callbacks
...ry.create_user()
comment_1 = Factory.create_comment(:author =>
user)
comment_2 = Factory.create_comment(:author =>
user)
user.destroy
comment_1.should be nil
comment_2.should be nil
end
end
----------------- Factory Module
def self.create_user(attributes = {})
default_attributes = {
:first_name => "Foo",
:second_name => "Bar",
:user_name => "FooBar",
:email => "foo at bar.com"
}
User.create! default_attributes.merge(attributes)
end
def self.create_comment(attributes = {})
default_a...
2008 Jan 11
5
Missing methods
We have a custom implementation of the Mother Object idea. It''s inside
of a module, basically like this:
module Factory
%w(account friendship person invitation message asset email_address
birth).each do |klass|
eval <<-EOF
def self.create_#{klass}(attributes = {})
default_attributes = valid_#{klass}_attributes
#{klass.camelize}.create! default_attributes.merge(attributes)
end
EOF
end
def valid_message_attributes(options = {})
{
#some message options
}
end
#more valid_x_attributes methods
end
When I require this file in a spec file, Factory.create_person wor...
2007 Dec 28
2
Arity?
Hello,
First off, nice improvements hemant! Thanks for all the hard work. I
just whipped up a new worker for a scheduled job that sends digest
emails. Very smooth.
However, moving some of my old backgroundrb into new backgroundrb
isn''t going quite as smoothly. I have a import worker that takes a
number of parameters and then is started dynamically. Here''s the a
2006 Mar 24
0
Connecting to SQL server on Mac OS X
...odbc and rb-dbi. I can connect to my SQL Server from tsql, but
ActiveRecord won''t connect, and from in irb I get this error:
irb(main):003:0> dbh = DBI.connect(''dbi:ODBC:MYDSN'',''MYUSER'',''MYPASS'')
NoMethodError: undefined method `default_attributes'' for
#<ODBC::Driver:0x485a24 @attrs={}, @name=nil>
from /opt/local/lib/ruby/vendor_ruby/1.8/dbi/dbi.rb:580:in
`connect''
from /opt/local/lib/ruby/vendor_ruby/1.8/dbi/dbi.rb:384:in
`connect''
from (irb):3
Can anyone help? After 3 hour...
2007 Dec 06
43
Mocks? Really?
OK, so i''ve played a bit with mocks and mock_models in controller and
view tests and i have a question. Is this statement really correct:
"We highly recommend that you exploit the mock framework here rather
than providing real model objects in order to keep the view specs
isolated from changes to your models."
(http://rspec.rubyforge.org/documentation/rails/writing/views.html