I am testing a Ruby Rails website and wanted to get started with Unit and Functional testing.
Cucumber and RSpec are worth a look. They encourage testing in a behaviour-driven, example-based style.
RSpec is a library for unit-level testing:
describe "hello_world"
it "should say hello to the world" do
# RSpec comes with its own mock-object framework built in,
# though it lets you use others if you prefer
world = mock("World", :population => 6e9)
world.should_receive(:hello)
hello_world(world)
end
end
It has special support for Rails (e.g. it can test models, views and controllers in isolation) and can replace the testing mechanisms built in to Rails.
Cucumber (formerly known as the RSpec Story Runner) lets you write high-level acceptance tests in (fairly) plain English that you could show to (and agree with) a customer, then run them:
Story: Commenting on articles
As a visitor to the blog
I want to post comments on articles
So that I can have my 15 minutes of fame
Scenario: Post a new comment
Given I am viewing an article
When I add a comment "Me too!"
And I fill in the CAPTCHA correctly
Then I should see a comment "Me too!"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With