Test/Spec has a wonderful - if largely unnoticed - feature: you can specify the superclass of contexts. The default is the ole' Test::Unit::TestCase, but that won't always do.
Let's say, hypothetically, you wanted to write some integration tests for your not-quite-shiny Rails app. You'd use ApplicationController::IntegrationTest, right? That way you can do things like
and it would look up the routings and just do the right thing. Awesome.
get "/posts/34.html"
Except... things aren't quite so simple when using test/spec. Therefore, I bring you an illustrious, illustrative example:
require File.dirname(__FILE__) + '/../test_helper'
class UserStoriesTest < ActionController::IntegrationTest
fixtures :people, :openid_authentications, :password_authentications
context "User Stories", ActionController::IntegrationTest do
context "a person coming to the site to log in", ActionController::IntegrationTest do
specify "should see the welcome page" do
get '/'
template.should.be 'welcome/index'
status.should.be 200
end
specify "should be able to successfully log in with email and password..." do
post_via_redirect '/login.html', {:email => 'pete.thomas@xahoo.com', :password => 'test'}
template.should.be 'people/home'
status.should.be 200
end
end
end
end
5 comments:
Мuch agreeԁ. I leaгn а little something completеly neω and comρlex on websites I come upon on httρ://100esѕays.
blogspot.com/ on a daily baѕiѕ. It's always helpful to read through posts from fellow authors and use items from other websites.
Here is my website ... obvio
Heу there, my name's Modesto and sometimes I write about the same thing on my blog. I actually do have a few questions for you if you do not mind. Is it just me or does it seem like many of the responses seem like they are coming out of brain dead individuals? :-P And, if you are writing on other social sites such as web 2.0 site list, I hope to keep up with you. Perhaps you could post some links to any of them?
My page 26146
I am genuinely thankful to the holder of this website who has shared this great article
at here.
Feel free to visit my site top law firms phoenix
What's up friends, its wonderful paragraph regarding teachingand completely
defined, keep it up all the time.
My page fort worth wedding dj ()
It's actually a great and helpful piece of information. I am satisfied that you just shared this useful information for us.
Thanks for sharing.
Post a Comment