Skip to content

Instantly share code, notes, and snippets.

@azuby
Created February 1, 2012 07:27
Show Gist options
  • Save azuby/1715643 to your computer and use it in GitHub Desktop.
Save azuby/1715643 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "User Registration" do
describe "signup" do
before(:each) do
#used by registrations controller
role = Factory(:basic_role)
company = Factory(:company)
company.code = "abc123"
company.save
#print company.code
end
describe "failure" do
it "should not make a new user" do
lambda do
visit new_user_registration_path
fill_in :company_code, :with => ""
fill_in :user_first_name, :with => ""
fill_in :user_last_name, :with => ""
fill_in :user_email, :with => ""
fill_in :user_password, :with => ""
fill_in :user_password_confirmation, :with => ""
click_button
response.should render_template('users/registrations/new')
response.should have_selector("div#error_explanation")
end.should_not change(User, :count)
end
end # describe failure
describe "success" do
it "should make a new user" do
lambda do
visit new_user_registration_path
fill_in :company_code, :with => "abc123"
fill_in :user_first_name, :with => "Example"
fill_in :user_last_name, :with => "User"
fill_in :user_email, :with => "[email protected]"
fill_in :user_password, :with => "secret"
fill_in :user_password_confirmation, :with => "secret"
click_button
response.should have_selector("div.flash",
:content => "Welcome")
response.should render_template('/timecard')
end.should change(User, :count).by(1)
end
end # describe success
end # describe signup
end # describe User Registration
Failures:
1) User Registration signup success should make a new user
Failure/Error: Unable to find matching line from backtrace
SystemStackError:
stack level too deep
# /home/adam/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/forwardable.rb:185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment