Skip to content

Instantly share code, notes, and snippets.

@deathbob
Created February 27, 2012 15:22
Show Gist options
  • Save deathbob/1924579 to your computer and use it in GitHub Desktop.
Save deathbob/1924579 to your computer and use it in GitHub Desktop.
# What's the rspec 1 version of this?
# The context here is I'm maintaining a Rails 2.3 project, where there are very few tests, and the ones that exist are some
# test::unit, some rspec. We're trying to standardize on rspec going forward and port the existing test::unit stuff to
# rspec as time allows.
# I think I have to use rspec 1 because it's a rails 2.3 project.
# I tried a spec/views/users/activate.html.erb_spec.rb file, but ran into trouble when I couldn't figure out how to set up
# all the state necessary without things feeling very brittle.
# Because I was setting up all the state for the view, I could imagine a scenario where the controller code changed,
# which would cause the view to blow up in real life, even though the test for the view would continue to pass, because
# all of its setup and state didn't exercise the controller at all.
# Maybe that's an indictment of the code itself, but such is life.
# I found integrate_views but a friend told me to stay away from that because he had used it and it cause other specs to
# break.
# I hadn't investigated that yet myself, should I just use integrate_views to replicate this ?
require 'test_helper'
class UserActivationTest < ActionController::IntegrationTest
test "activation success" do
# activate GET /activate/:screen_name/:activation_code {:controller=>"users", :action=>"activate"}
@user = Factory.create(:user)
@user.game_account_type = 2
@user.save
get "/activate/#{@user.screen_name}/#{@user.activation_code}"
assert assigns(:user)
assert flash[:notice] =~ /account activated/i
assert redirect?
follow_redirect!
assert_select "div#flash-notice", /account activated/i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment