Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.join(File.dirname(__FILE__), "helper")
- Story "users visiting the homepage", %{
- As an user
- I should see information based on based on authentication
- So that I can see relative content
- }, :type => RailsStory do
- Scenario "anonymous user visting the home page" do
- Given "the user is anonymous" do
- @current_user.should be_nil #example of checking
- end
- When "visiting home page" do
- get "/"
- end
- Then "user should see", "site_pages/_frontpage" do |partial|
- response.should render_template(partial)
- end
- And "the page should show", "Sign up and become a member!", do |message|
- response.should have_text(/#{message}/)
- end
- end
- Scenario "authenticated user visting the home page" do
- Given "the user is", "anonymous" do | login |
- @current_user.should be_nil #example of checking
- end
- When "visiting home page" do
- get "/"
- end
- Then "user should see", "site_pages/_anon_welcome" do |partial|
- response.should render_template(partial)
- end
- And "the page should show", "Sign up and become a member!", do |message|
- response.should have_text(/#{message}/)
- end
- end
- Scenario "vistiing the about page" do
- Given "the user named", "Jon" do |login|
- @user = current_user login
- end
- Given "the user is logged in" do
- post_via_redirect "/session", :login => "Jon", :password => "testing"
- end
- When "visiting home page" do
- get "/"
- end
- Then "user should see", "site_pages/_user_welcome" do |partial|
- response.should render_template(partial)
- end
- And "the page should show", "Welcome back! #{@user.name}", do |message|
- response.should have_text(/#{message}/)
- end
- end
- end
- def current_user(login)
- user = User.create!(
- :login => login,
- :email => "[email protected]",
- :password => "testing",
- :password_confirmation => "testing")
- user
- end
- end
Add Comment
Please, Sign In to add comment