Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

*.komodoproject
.DS_Store
.project
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ group :test, :development do
gem 'guard'
gem 'guard-spork'

gem 'rb-readline'

gem 'guard-rspec'
gem 'rspec-rails'

gem 'capybara'

gem 'growl', :require => false
gem 'ruby_gntp'
end
23 changes: 23 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ GEM
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.2.4)
ffi (~> 1.0.6)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
Expand Down Expand Up @@ -75,6 +84,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
nokogiri (1.5.0)
orm_adapter (0.0.5)
polyglot (0.3.3)
rack (1.3.5)
Expand Down Expand Up @@ -102,6 +112,7 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rb-readline (0.4.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.7.0)
Expand All @@ -117,12 +128,19 @@ GEM
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.7.0)
ruby_gntp (0.3.4)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
selenium-webdriver (2.15.0)
childprocess (>= 0.2.1)
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
spork (0.9.0.rc9)
sprockets (2.0.3)
hike (~> 1.2)
Expand All @@ -142,11 +160,14 @@ GEM
multi_json (>= 1.0.2)
warden (1.1.0)
rack (>= 1.0)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
coffee-rails (~> 3.1.1)
devise
factory_girl_rails
Expand All @@ -156,7 +177,9 @@ DEPENDENCIES
guard-spork
jquery-rails
rails (= 3.1.3)
rb-readline
rspec-rails
ruby_gntp
sass-rails (~> 3.1.5)
spork (>= 0.9.0.rc8)
sqlite3
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%= form_tag user_session_path do %>
<%= text_field_tag "user[email]", '', class: "input-small", placeholder: "Email" %>
<%= password_field_tag "user[password]", '', class: "input-small", placeholder: "Password" %>
<%= button_tag "Sign in", class: "btn" %>
<%= button_tag "Sign in", class: "btn", id: "header_sign_in" %>
<% end %>
<% end %>
</div>
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

FactoryGirl.define do
factory :user do
sequence(:email) { |n| "test#{n}@example.com" }
password "secret"
end
end
78 changes: 78 additions & 0 deletions spec/integration/sign_in_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
require 'spec_helper'

describe 'home page' do
it 'logs in with invalid credentials' do
visit '/'

user = create(:user)

fill_in('user[email]', :with => user.email)
fill_in('user[password]', :with => 'this_is_not_a_valid_password')
click_button('header_sign_in')

current_path.should == '/users/sign_in'
end

it 'logs in and out using valid credentials' do
visit '/'

user = create(:user)

fill_in('user[email]', :with => user.email)
fill_in('user[password]', :with => user.password)
click_button('header_sign_in')

current_path.should == '/'
page.should have_content(user.email)

click_link('Sign out')

current_path.should == '/'
page.should have_no_content(user.email)
end

it 'logs in with invalid credentails and then logs into /users/sign_in with invalid credentials' do
visit '/'

user = create(:user)

fill_in('user[email]', :with => user.email)
fill_in('user[password]', :with => 'this_is_not_a_valid_password')
click_button('header_sign_in')

current_path.should == '/users/sign_in'

within("form[@id='user_new']") do
fill_in('user[email]', :with => 'testing')
fill_in('user[password]', :with => 'testing')
click_button('Sign in')
end

current_path.should == '/users/sign_in'
end

it 'logs in with invalid credentails and then logs into /users/sign_in with valid credentials' do
visit '/'

user = create(:user)

fill_in('user[email]', :with => user.email)
fill_in('user[password]', :with => 'this_is_not_a_valid_password')
click_button('header_sign_in')

current_path.should == '/users/sign_in'

within("form[@id='user_new']") do
fill_in('user[email]', :with => user.email)
fill_in('user[password]', :with => user.password)
click_button('Sign in')
end

current_path.should == '/'

click_link('Sign out')

current_path.should == '/'
page.should have_no_content(user.email)
end
end
63 changes: 63 additions & 0 deletions spec/integration/signup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'spec_helper'

# simple sign up macro for a user
def sign_up(user)
within "#user_new" do
fill_in "user_email", with: user.email
fill_in "user_password", with: user.password
fill_in "user_password_confirmation", with: user.password_confirmation

click_button 'Sign up'
end
end

describe "the signup process", type: :request do

context "with valid parameters" do
before :each do
@user = FactoryGirl.build(:user)
end

it "signs me up" do
visit new_user_registration_path

@user.password_confirmation = @user.password
sign_up(@user)

page.should have_content(@user.email)
current_path.should eq(root_path)
end
end

context "with invalid parameters" do
before do
visit new_user_registration_path
end

it "should require an email" do
user = build(:user, email: nil)
sign_up user
page.should have_content("Email can't be blank")
end

it "should require a password" do
user = build(:user, password: nil)
sign_up user
page.should have_content("Password can't be blank")
end

it "should confirm the password" do
user = build(:user)
sign_up user
page.should have_content("Password doesn't match confirmation")
end

it "should not allow a user to sign up more than once" do
first = create(:user)
user = build(:user, email: first.email)
sign_up user
page.should have_content("Email has already been taken")
end
end

end
17 changes: 16 additions & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
require 'spec_helper'

describe User do
pending "add some examples to (or delete) #{__FILE__}"

it "should require an email address" do
user = build(:user, email: nil)
user.should_not be_valid
end

it "should only allow a valid email" do
user = build(:user, email: "bad/email")
user.should_not be_valid
end

it "should require a password" do
user = build(:user, password: nil)
user.should_not be_valid
end

end
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
require 'rspec/rails'
require 'rspec/autorun'

# Add this to load Capybara integration:
require 'capybara/rspec'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Expand All @@ -34,5 +37,8 @@

# Require Factory Girls
config.include FactoryGirl::Syntax::Methods

# include devise test helpers
config.include Devise::TestHelpers, :type => :controller
end
end
end