I lived with the fact that my test ground to a halt when my tests ran code that had to send emails. It finally got so bad I started asking around about it.
I knew about a method to test ActionMailer and not send out emails... and I thought: why not apply these to ActionMailer when it's in the test environment? I ran my tests with rspec. Check out the pastie to see the code.
Showing posts with label test. Show all posts
Showing posts with label test. Show all posts
Friday, January 23, 2009
Tuesday, October 21, 2008
RSpec, attachment_fu
I've been looking for a solution to force RSpec tests to override the attachment_fu storage setting. Since I use s3, it was very inefficient when I'd run my tests because the assets would be saved in s3. Not only does it cost money, but it was very slow.
After spamming #rubyonrails I finally got an answer from _martinS_. He told me to do something like this: http://pastie.org/296895 - and it worked! I hope this helps you guys.
After spamming #rubyonrails I finally got an answer from _martinS_. He told me to do something like this: http://pastie.org/296895 - and it worked! I hope this helps you guys.
Thursday, December 13, 2007
rSpec and Relationships
I spend a good 3 hours figuring out why my spec tests were failing. Let me explain my scenario to you.
My scenario was pretty much like this: Student belongs to Class.
My test: a student should know what class it belongs to.
My student_spec:
My scenario was pretty much like this: Student belongs to Class.
My test: a student should know what class it belongs to.
My student_spec:
it "should know what class it belongs to"Failed! Apparently, you cannot insert into the array "<<". You need to do it like this:
@student = Student.new
@class = Class.new(:name => "Math")
@class.students << @student
@student.class.name.should == "Math"
end
@student.class = @classWell, I'm not that stupid that it'd take me 3 hours to figure that out! My test was longer of course! I just made it simple for example's sake. :P
Subscribe to:
Posts (Atom)