I hate to be that guy , but the Rspec tests should be written more like the following: describe 'Article' do let(:article) { Article.new } describe '#slug' do before(:each) do article.title = "Testing with Test::Unit" end it 'does not contain non-alphabetical characters' do article.slug.should_not match(/[^\w-]/) end it 'does not contain capital letters' do article.slug.should_not match(/[A-Z]/) end it 'replaces spac…
Learn how to test Rails using Test::Unit instead of Rspec
21–30 of 51 posts
Re: Learn how to test Rails using Test::Unit instead of Rspec
#22Re: Learn how to test Rails using Test::Unit instead of Rspec
#23I hate to be that guy , but the Rspec tests should be written more like the following: describe 'Article' do let(:article) { Article.new } describe '#slug' do before(:each) do article.title = "Testing with Test::Unit" end it 'does not contain non-alphabetical characters' do article.slug.should_not match(/[^\w-]/) end it 'does not contain capital letters' do article.slug.should_not match(/[A-Z]/) end it 'replaces spac…
Re: Learn how to test Rails using Test::Unit instead of Rspec
#24When I learned Rails a few years ago, I was learning programming from scratch apart from some very early fumblings in BASIC and FORTRAN 20 years ago now. I was completely unfamiliar with the idea of testing. I had to learn it from the ground up. RSpec wasn't just more understandable it was, and remains, better documented. It's not just the official documentation. It's that there are tons of examples of how to test different use cases, what one should test, best practices.
Learning to test isn't just learning literally what a few methods do. It's understanding how to use those in myriad mix and match situations in order to provide good test coverage.
RSpec is easier to read before the test, it produces beautiful output that is readable and expressive, when you write good tests and test the right things.
After trying to struggle with Test::Unit and writing uncovered code for long stretches because I couldn't understand what to do, and then discovering RSpec, reading great blog posts, write-ups and documentation on it and finding comfort in RED-GREEN-REFACTOR I would only recommend RSpec for someone starting from scratch, as I did.
Re: Learn how to test Rails using Test::Unit instead of Rspec
#25My experience: I just started the process of converting our few hundred Test::Unit tests to Rspec simply because Test Unit documentation is terrible . Our tests need a lot of work and I'm not that experienced at writing test scripts. I have to learn this as I do it, and I struggled to find resources for learning Test::Unit. Every blog post, tutorial and guide I can find was written for Rspec. As much as I'd love to c…
Re: Learn how to test Rails using Test::Unit instead of Rspec
#26Fundamentally disagree with much of this article. Not just what _that_ guy said: https://news.ycombinator.com/item?id=5418460 When I learned Rails a few years ago, I was learning programming from scratch apart from some very early fumblings in BASIC and FORTRAN 20 years ago now. I was completely unfamiliar with the idea of testing. I had to learn it from the ground up. RSpec wasn't just more understandable it was, an…
As RSpec documentation goes this set of slides open in a window will help you tremendously:
http://kerryb.github.com/iprug-rspec-presentation/#1
It uses simple example and hits all the major points well.
Re: Learn how to test Rails using Test::Unit instead of Rspec
#27Re: Learn how to test Rails using Test::Unit instead of Rspec
#28My experience: I just started the process of converting our few hundred Test::Unit tests to Rspec simply because Test Unit documentation is terrible . Our tests need a lot of work and I'm not that experienced at writing test scripts. I have to learn this as I do it, and I struggled to find resources for learning Test::Unit. Every blog post, tutorial and guide I can find was written for Rspec. As much as I'd love to c…
Hear hear. I am dreading the technical debt I have in test-unit, and meanwhile the (Rails) world is moving on to Minitest and the world appears to be settling on Rspec syntax regardless. Nowhere to be found is even a conversion HOWTO, so test-unit starts feeling even more like a ghetto, and increases my conversion anxiety, which is all too bad, since I like what I consider to be the simplicity of test-unit.
Minitest and Test::Unit are part of the same package since 1.9, with Test::Unit implemented as a simple compatibility layer on top of Minitest:
http://www.rubyinside.com/a-minitestspec-tutorial-elegant-sp...
The Minitest assertions are quite similar to the old Test::Unit assertions, a large number are identical:
http://rubydoc.info/stdlib/minitest/1.9.3/MiniTest/Assertion...
Re: Learn how to test Rails using Test::Unit instead of Rspec
#29Minitest::Spec is just an RSpec-like DSL built on top of Minitest, which is the successor to Test::Unit.
Re: Learn how to test Rails using Test::Unit instead of Rspec
#30I hate to be that guy , but the Rspec tests should be written more like the following: describe 'Article' do let(:article) { Article.new } describe '#slug' do before(:each) do article.title = "Testing with Test::Unit" end it 'does not contain non-alphabetical characters' do article.slug.should_not match(/[^\w-]/) end it 'does not contain capital letters' do article.slug.should_not match(/[A-Z]/) end it 'replaces spac…
describe Article do
describe '#slug' do
before do
subject.title = "Testing with Test::Unit"
end
its(:slug) { should_not match(/[^\w-]/) }
its(:slug) { should_not match(/[A-Z]/) }
it 'replaces spaces with hyphens'
end
end