Skip to content

Instantly share code, notes, and snippets.

@Jimgerneer
Created June 2, 2012 00:02
Show Gist options
  • Save Jimgerneer/2855862 to your computer and use it in GitHub Desktop.
Save Jimgerneer/2855862 to your computer and use it in GitHub Desktop.
Opportunity spec
1 require_relative '../spec_helper'¬
2 require_relative '../../models/user'¬
3 ¬
4 describe Rook::User do¬
5 before do¬
6 @user = Rook::User.gen¬
7 end¬
8 ¬
9 it 'has a username' do¬
10 @user.username.must_equal 'DecoyDrone'¬
11 end¬
12 ¬
13 it 'has an id' do¬
14 @user.must_respond_to :id¬
15 end¬
16 ¬
17 it 'has an email' do¬
18 @user.email.must_equal '[email protected]
19 end¬
20 ¬
21 it 'has a password' do¬
22 @user.password.must_equal 'doobar'¬
23 end¬
24 ¬
25 it 'requires a correct password confirmation' do¬
26 invalid_user = Rook::User.make(:password_confirmation => 'wrong')¬
27 assert ! invalid_user.valid?¬
28 end¬
29 end¬
30 ¬
31 describe Rook::User do¬
32 ¬
33 before do¬
34 DataMapper.auto_migrate!¬
35 end¬
36 ¬
37 it 'usernames need to be at least 2 char long' do¬
38 invalid_user = Rook::User.make(:username => 's')¬
39 assert ! invalid_user.valid?¬
40 end¬
41 ¬
42 it 'requires a vaild email format' do¬
43 invalid_user1 = Rook::User.make(:email => 'wrong.com')¬
44 assert ! invalid_user1.valid?¬
45 invalid_user2 = Rook::User.make(:email => 'wrong@com')¬
46 assert ! invalid_user2.valid?¬
47 invalid_user3 = Rook::User.make(:email => '@wrong.com')¬
48 assert ! invalid_user3.valid?¬
49 end¬
50 ¬
51 it 'requires unique usernames on signup' do¬
52 invalid_user1 = Rook::User.gen(:username => 'decoy')¬
53 invalid_user2 = Rook::User.make(:username => 'decoy')¬
54 assert ! invalid_user2.valid?¬
55 end¬
56 ¬
57 it 'requires a unique email on signup' do¬
58 invalid_user1 = Rook::User.gen(:email => '[email protected]')¬
59 invalid_user2 = Rook::User.make(:email => '[email protected]')¬
60 assert ! invalid_user2.valid?¬
61 end¬
62 end¬
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment