Showing posts with label rspec. Show all posts
Showing posts with label rspec. Show all posts

Friday, January 23, 2009

Speeding up emailing in tests

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.

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.

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:
it "should know what class it belongs to"
@student = Student.new
@class = Class.new(:name => "Math")
@class.students << @student
@student.class.name.should == "Math"
end
Failed! Apparently, you cannot insert into the array "<<". You need to do it like this:
@student.class = @class
Well, 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




Thursday, November 15, 2007

Learning Behaviour Driven Development

I've been doing a bunch of Google searches on Behaviour Driven Development (BDD) but all I've found were long articles and wordy introductions. I suppose some people learn that way but I'm way to lazy.

Thank goodness for screencasts. To dive into it, check out the website smartic.us' screencasts on rSpec.

Obviously, I don't know much. All I know is that rSpec is a gem used for testing. He dives straight into making a class and testing it. Or rather, testing it, then making the class. You'll see. :)