diff --git a/Appraisals b/Appraisals index 35488995a..7c86bbf52 100644 --- a/Appraisals +++ b/Appraisals @@ -1,5 +1,5 @@ -['3.0.12', '3.1.4', '3.2.3'].each do |rails_version| +['3.0.15', '3.1.6', '3.2.6'].each do |rails_version| appraise "#{rails_version}" do - gem "rails", rails_version + gem 'rails', rails_version end end diff --git a/Gemfile b/Gemfile index c80ee3697..d65e2a669 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ -source "http://rubygems.org" +source 'http://rubygems.org' gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 62b063dbe..dda9c4ad1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,40 +3,40 @@ PATH specs: clearance (0.16.2) bcrypt-ruby - diesel (~> 0.1.5) + diesel (= 0.1.5) rails (>= 3.0) GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.1) - actionpack (= 3.2.1) - mail (~> 2.4.0) - actionpack (3.2.1) - activemodel (= 3.2.1) - activesupport (= 3.2.1) + actionmailer (3.2.6) + actionpack (= 3.2.6) + mail (~> 2.4.4) + actionpack (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-test (~> 0.6.1) - sprockets (~> 2.1.2) - activemodel (3.2.1) - activesupport (= 3.2.1) + sprockets (~> 2.1.3) + activemodel (3.2.6) + activesupport (= 3.2.6) builder (~> 3.0.0) - activerecord (3.2.1) - activemodel (= 3.2.1) - activesupport (= 3.2.1) - arel (~> 3.0.0) + activerecord (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.1) - activemodel (= 3.2.1) - activesupport (= 3.2.1) - activesupport (3.2.1) + activeresource (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + activesupport (3.2.6) i18n (~> 0.6) multi_json (~> 1.0) - addressable (2.2.6) + addressable (2.3.1) appraisal (0.4.1) bundler rake @@ -57,47 +57,46 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.0) - ffi (~> 1.0.6) - cucumber (1.1.4) + childprocess (0.3.4) + ffi (~> 1.0, >= 1.0.6) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.7.1) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.1.1) capybara (>= 1.1.1) cucumber (>= 1.1.0) nokogiri (>= 1.5.0) - database_cleaner (0.7.1) + database_cleaner (0.8.0) diesel (0.1.5) railties diff-lcs (1.1.3) erubis (2.7.0) - factory_girl (3.1.1) + factory_girl (3.5.0) activesupport (>= 3.0.0) - factory_girl_rails (3.1.0) - factory_girl (~> 3.1.0) + factory_girl_rails (3.5.0) + factory_girl (~> 3.5.0) railties (>= 3.0.0) - ffi (1.0.11) - gherkin (2.7.6) + ffi (1.1.0) + gherkin (2.11.1) json (>= 1.4.6) hike (1.2.1) i18n (0.6.0) - journey (1.0.3) - json (1.6.6) - launchy (2.0.5) - addressable (~> 2.2.6) + journey (1.0.4) + json (1.7.3) + libwebsocket (0.1.4) + addressable mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) - mime-types (1.17.2) + mime-types (1.19) mocha (0.10.5) metaclass (~> 0.0.1) - multi_json (1.0.4) - nokogiri (1.5.0) + multi_json (1.3.6) + nokogiri (1.5.5) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -106,52 +105,51 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.1) - actionmailer (= 3.2.1) - actionpack (= 3.2.1) - activerecord (= 3.2.1) - activeresource (= 3.2.1) - activesupport (= 3.2.1) + rails (3.2.6) + actionmailer (= 3.2.6) + actionpack (= 3.2.6) + activerecord (= 3.2.6) + activeresource (= 3.2.6) + activesupport (= 3.2.6) bundler (~> 1.0) - railties (= 3.2.1) - railties (3.2.1) - actionpack (= 3.2.1) - activesupport (= 3.2.1) + railties (= 3.2.6) + railties (3.2.6) + actionpack (= 3.2.6) + activesupport (= 3.2.6) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.6) + thor (>= 0.14.6, < 2.0) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) - rspec-rails (2.9.0) + rspec-mocks (2.11.1) + rspec-rails (2.11.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.9.0) - rubyzip (0.9.5) - selenium-webdriver (2.18.0) + rspec (~> 2.11.0) + rubyzip (0.9.9) + selenium-webdriver (2.25.0) childprocess (>= 0.2.5) - ffi (~> 1.0.9) - multi_json (~> 1.0.4) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) rubyzip - shoulda-matchers (1.1.0) + shoulda-matchers (1.2.0) activesupport (>= 3.0.0) - sprockets (2.1.2) + sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) - thor (0.14.6) + sqlite3 (1.3.6) + thor (0.15.4) tilt (1.3.3) timecop (0.3.5) treetop (1.4.10) @@ -165,17 +163,16 @@ PLATFORMS ruby DEPENDENCIES - appraisal (~> 0.4.1) - aruba (~> 0.4.11) - bourne (~> 1.1.2) - bundler (~> 1.1) - capybara (~> 1.1.2) + appraisal (= 0.4.1) + aruba (= 0.4.11) + bourne (= 1.1.2) + bundler (= 1.1.3) + capybara (= 1.1.2) clearance! - cucumber-rails (~> 1.1.1) - database_cleaner - factory_girl_rails (~> 3.1.0) - launchy - rspec-rails (~> 2.9.0) - shoulda-matchers (~> 1.1.0) - sqlite3 - timecop + cucumber-rails (= 1.1.1) + database_cleaner (= 0.8.0) + factory_girl_rails (= 3.5.0) + rspec-rails (= 2.11.0) + shoulda-matchers (= 1.2.0) + sqlite3 (= 1.3.6) + timecop (= 0.3.5) diff --git a/README.md b/README.md index 9f2f07fd8..30a2292cc 100644 --- a/README.md +++ b/README.md @@ -179,14 +179,14 @@ for the default behavior. To override a view, create your own: - app/views/clearance_mailer/change_password.html.erb - app/views/passwords/create.html.erb - app/views/passwords/edit.html.erb - app/views/passwords/new.html.erb - app/views/sessions/_form.html.erb - app/views/sessions/new.html.erb - app/views/users/_form.html.erb - app/views/users/new.html.erb + app/views/clearance_mailer/change_password.html.erb + app/views/passwords/create.html.erb + app/views/passwords/edit.html.erb + app/views/passwords/new.html.erb + app/views/sessions/_form.html.erb + app/views/sessions/new.html.erb + app/views/users/_form.html.erb + app/views/users/new.html.erb There is a shortcut to copy all Clearance views into your app: @@ -350,13 +350,12 @@ Credits ![thoughtbot](http://thoughtbot.com/images/tm/logo.png) -Clearance is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community) - +Clearance is maintained by [thoughtbot, inc](http://thoughtbot.com/community). Thank you to all [the contributors](https://github.com/thoughtbot/clearance/contributors)! -The names and logos for thoughtbot are trademarks of thoughtbot, inc. - License ------- Clearance is copyright © 2009-2012 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file. + +The names and logos for thoughtbot are trademarks of thoughtbot, inc. diff --git a/clearance.gemspec b/clearance.gemspec index 4a911489b..d9a2bdb64 100644 --- a/clearance.gemspec +++ b/clearance.gemspec @@ -3,37 +3,35 @@ require 'clearance/version' require 'date' Gem::Specification.new do |s| - s.name = %q{clearance} - s.version = Clearance::VERSION - s.email = %q{support@thoughtbot.com} - s.homepage = %q{http://github.com/thoughtbot/clearance} - - s.authors = ["Dan Croak", "Mike Burns", "Jason Morrison", "Joe Ferris", "Eugene Bolshakov", "Nick Quaranto", "Josh Nichols", "Mike Breen", "Jon Yurek", "Chad Pytel"] - s.date = Date.today.to_s - s.summary = %q{Rails authentication & authorization with email & password.} + s.add_dependency 'bcrypt-ruby' + s.add_dependency 'diesel', '0.1.5' + s.add_dependency 'rails', '>= 3.0' + s.add_development_dependency 'appraisal', '0.4.1' + s.add_development_dependency 'aruba', '0.4.11' + s.add_development_dependency 'bourne', '1.1.2' + s.add_development_dependency 'bundler', '1.1.3' + s.add_development_dependency 'capybara', '1.1.2' + s.add_development_dependency 'cucumber-rails', '1.1.1' + s.add_development_dependency 'database_cleaner', '0.8.0' + s.add_development_dependency 'factory_girl_rails', '3.5.0' + s.add_development_dependency 'rspec-rails', '2.11.0' + s.add_development_dependency 'shoulda-matchers', '1.2.0' + s.add_development_dependency 'sqlite3', '1.3.6' + s.add_development_dependency 'timecop', '0.3.5' + s.authors = [ + 'Dan Croak', 'Mike Burns', 'Jason Morrison', 'Joe Ferris', 'Eugene Bolshakov', + 'Nick Quaranto', 'Josh Nichols', 'Mike Breen', 'Jon Yurek', 'Chad Pytel' + ] + s.date = Date.today.to_s s.description = %q{Rails authentication & authorization with email & password.} + s.email = %q{support@thoughtbot.com} s.extra_rdoc_files = %w(LICENSE README.md) - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,features}/*`.split("\n") - - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - - s.add_dependency('rails', '>= 3.0') - s.add_dependency('diesel', '~> 0.1.5') - s.add_dependency('bcrypt-ruby') - - s.add_development_dependency('bundler', '~> 1.1') - s.add_development_dependency('appraisal', '~> 0.4.1') - s.add_development_dependency('cucumber-rails', '~> 1.1.1') - s.add_development_dependency('rspec-rails', '~> 2.9.0') - s.add_development_dependency('sqlite3') - s.add_development_dependency('bourne', '~> 1.1.2') - s.add_development_dependency('timecop') - s.add_development_dependency('capybara', '~> 1.1.2') - s.add_development_dependency('factory_girl_rails', '~> 3.1.0') - s.add_development_dependency('shoulda-matchers', '~> 1.1.0') - s.add_development_dependency('database_cleaner') - s.add_development_dependency('launchy') - s.add_development_dependency('aruba', '~> 0.4.11') + s.files = `git ls-files`.split('\n') + s.homepage = %q{http://github.com/thoughtbot/clearance} + s.name = %q{clearance} + s.rdoc_options = ['--charset=UTF-8'] + s.require_paths = ['lib'] + s.summary = %q{Rails authentication & authorization with email & password.} + s.test_files = `git ls-files -- {features,spec}/*`.split('\n') + s.version = Clearance::VERSION end diff --git a/features/support/env.rb b/features/support/env.rb index f103fdeba..2ef42bda9 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -29,25 +29,8 @@ Capybara.default_selector = :css Capybara.save_and_open_page_path = 'tmp' -# By default, any exception happening in your Rails application will bubble up -# to Cucumber so that your scenario will fail. This is a different from how -# your application behaves in the production environment, where an error page will -# be rendered instead. -# -# Sometimes we want to override this default behaviour and allow Rails to rescue -# exceptions and display an error page (just like when the app is running in production). -# Typical scenarios where you want to do this is when you test your error pages. -# There are two ways to allow Rails to rescue exceptions: -# -# 1) Tag your scenario (or feature) with @allow-rescue -# -# 2) Set the value below to true. Beware that doing this globally is not -# recommended as it will mask a lot of errors for you! -# ActionController::Base.allow_rescue = false -# Remove/comment out the lines below if your app doesn't have a database. -# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. begin DatabaseCleaner.strategy = :transaction rescue NameError diff --git a/gemfiles/3.0.12.gemfile b/gemfiles/3.0.15.gemfile similarity index 62% rename from gemfiles/3.0.12.gemfile rename to gemfiles/3.0.15.gemfile index b29dd4135..11c791e99 100644 --- a/gemfiles/3.0.12.gemfile +++ b/gemfiles/3.0.15.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "3.0.12" +gem "rails", "3.0.15" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/3.0.12.gemfile.lock b/gemfiles/3.0.15.gemfile.lock similarity index 53% rename from gemfiles/3.0.12.gemfile.lock rename to gemfiles/3.0.15.gemfile.lock index 385641756..8c3e50603 100644 --- a/gemfiles/3.0.12.gemfile.lock +++ b/gemfiles/3.0.15.gemfile.lock @@ -3,19 +3,19 @@ PATH specs: clearance (0.16.2) bcrypt-ruby - diesel (~> 0.1.5) + diesel (= 0.1.5) rails (>= 3.0) GEM remote: http://rubygems.org/ specs: abstract (1.0.0) - actionmailer (3.0.12) - actionpack (= 3.0.12) + actionmailer (3.0.15) + actionpack (= 3.0.15) mail (~> 2.2.19) - actionpack (3.0.12) - activemodel (= 3.0.12) - activesupport (= 3.0.12) + actionpack (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.5.0) @@ -23,20 +23,20 @@ GEM rack-mount (~> 0.6.14) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.12) - activesupport (= 3.0.12) + activemodel (3.0.15) + activesupport (= 3.0.15) builder (~> 2.1.2) i18n (~> 0.5.0) - activerecord (3.0.12) - activemodel (= 3.0.12) - activesupport (= 3.0.12) + activerecord (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) arel (~> 2.0.10) tzinfo (~> 0.3.23) - activeresource (3.0.12) - activemodel (= 3.0.12) - activesupport (= 3.0.12) - activesupport (3.0.12) - addressable (2.2.7) + activeresource (3.0.15) + activemodel (= 3.0.15) + activesupport (= 3.0.15) + activesupport (3.0.15) + addressable (2.3.1) appraisal (0.4.1) bundler rake @@ -57,99 +57,97 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.1) - ffi (~> 1.0.6) - cucumber (1.1.9) + childprocess (0.3.4) + ffi (~> 1.0, >= 1.0.6) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.9.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.1.1) capybara (>= 1.1.1) cucumber (>= 1.1.0) nokogiri (>= 1.5.0) - database_cleaner (0.7.2) + database_cleaner (0.8.0) diesel (0.1.5) railties diff-lcs (1.1.3) erubis (2.6.6) abstract (>= 1.0.0) - factory_girl (3.1.1) + factory_girl (3.5.0) activesupport (>= 3.0.0) - factory_girl_rails (3.1.0) - factory_girl (~> 3.1.0) + factory_girl_rails (3.5.0) + factory_girl (~> 3.5.0) railties (>= 3.0.0) - ffi (1.0.11) - gherkin (2.9.3) + ffi (1.1.0) + gherkin (2.11.1) json (>= 1.4.6) i18n (0.5.0) - json (1.6.6) - launchy (2.1.0) - addressable (~> 2.2.6) + json (1.7.3) + libwebsocket (0.1.4) + addressable mail (2.2.19) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) - mime-types (1.18) + mime-types (1.19) mocha (0.10.5) metaclass (~> 0.0.1) - multi_json (1.2.0) - nokogiri (1.5.2) + multi_json (1.3.6) + nokogiri (1.5.5) polyglot (0.3.3) rack (1.2.5) rack-mount (0.6.14) rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) - rails (3.0.12) - actionmailer (= 3.0.12) - actionpack (= 3.0.12) - activerecord (= 3.0.12) - activeresource (= 3.0.12) - activesupport (= 3.0.12) + rails (3.0.15) + actionmailer (= 3.0.15) + actionpack (= 3.0.15) + activerecord (= 3.0.15) + activeresource (= 3.0.15) + activesupport (= 3.0.15) bundler (~> 1.0) - railties (= 3.0.12) - railties (3.0.12) - actionpack (= 3.0.12) - activesupport (= 3.0.12) + railties (= 3.0.15) + railties (3.0.15) + actionpack (= 3.0.15) + activesupport (= 3.0.15) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.4) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) - rspec-rails (2.9.0) + rspec-mocks (2.11.1) + rspec-rails (2.11.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.9.0) - rubyzip (0.9.6.1) - selenium-webdriver (2.20.0) + rspec (~> 2.11.0) + rubyzip (0.9.9) + selenium-webdriver (2.25.0) childprocess (>= 0.2.5) - ffi (~> 1.0) + libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip - shoulda-matchers (1.1.0) + shoulda-matchers (1.2.0) activesupport (>= 3.0.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) + sqlite3 (1.3.6) thor (0.14.6) timecop (0.3.5) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) + tzinfo (0.3.33) xpath (0.1.4) nokogiri (~> 1.3) @@ -157,18 +155,17 @@ PLATFORMS ruby DEPENDENCIES - appraisal (~> 0.4.1) - aruba (~> 0.4.11) - bourne (~> 1.1.2) - bundler (~> 1.1) - capybara (~> 1.1.2) + appraisal (= 0.4.1) + aruba (= 0.4.11) + bourne (= 1.1.2) + bundler (= 1.1.3) + capybara (= 1.1.2) clearance! - cucumber-rails (~> 1.1.1) - database_cleaner - factory_girl_rails (~> 3.1.0) - launchy - rails (= 3.0.12) - rspec-rails (~> 2.9.0) - shoulda-matchers (~> 1.1.0) - sqlite3 - timecop + cucumber-rails (= 1.1.1) + database_cleaner (= 0.8.0) + factory_girl_rails (= 3.5.0) + rails (= 3.0.15) + rspec-rails (= 2.11.0) + shoulda-matchers (= 1.2.0) + sqlite3 (= 1.3.6) + timecop (= 0.3.5) diff --git a/gemfiles/3.2.3.gemfile b/gemfiles/3.1.6.gemfile similarity index 63% rename from gemfiles/3.2.3.gemfile rename to gemfiles/3.1.6.gemfile index c2c293162..c08ef53bb 100644 --- a/gemfiles/3.2.3.gemfile +++ b/gemfiles/3.1.6.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "3.2.3" +gem "rails", "3.1.6" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/3.1.4.gemfile.lock b/gemfiles/3.1.6.gemfile.lock similarity index 53% rename from gemfiles/3.1.4.gemfile.lock rename to gemfiles/3.1.6.gemfile.lock index aa29da512..cf66edc86 100644 --- a/gemfiles/3.1.4.gemfile.lock +++ b/gemfiles/3.1.6.gemfile.lock @@ -3,41 +3,41 @@ PATH specs: clearance (0.16.2) bcrypt-ruby - diesel (~> 0.1.5) + diesel (= 0.1.5) rails (>= 3.0) GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.4) - actionpack (= 3.1.4) - mail (~> 2.3.0) - actionpack (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) + actionmailer (3.1.6) + actionpack (= 3.1.6) + mail (~> 2.3.3) + actionpack (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) builder (~> 3.0.0) erubis (~> 2.7.0) i18n (~> 0.6) rack (~> 1.3.6) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.3) - activemodel (3.1.4) - activesupport (= 3.1.4) + sprockets (~> 2.0.4) + activemodel (3.1.6) + activesupport (= 3.1.6) builder (~> 3.0.0) i18n (~> 0.6) - activerecord (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) + activerecord (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) arel (~> 2.2.3) tzinfo (~> 0.3.29) - activeresource (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) - activesupport (3.1.4) - multi_json (~> 1.0) - addressable (2.2.7) + activeresource (3.1.6) + activemodel (= 3.1.6) + activesupport (= 3.1.6) + activesupport (3.1.6) + multi_json (>= 1.0, < 1.3) + addressable (2.3.1) appraisal (0.4.1) bundler rake @@ -58,46 +58,45 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.1) - ffi (~> 1.0.6) - cucumber (1.1.9) + childprocess (0.3.4) + ffi (~> 1.0, >= 1.0.6) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.9.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.1.1) capybara (>= 1.1.1) cucumber (>= 1.1.0) nokogiri (>= 1.5.0) - database_cleaner (0.7.2) + database_cleaner (0.8.0) diesel (0.1.5) railties diff-lcs (1.1.3) erubis (2.7.0) - factory_girl (3.1.1) + factory_girl (3.5.0) activesupport (>= 3.0.0) - factory_girl_rails (3.1.0) - factory_girl (~> 3.1.0) + factory_girl_rails (3.5.0) + factory_girl (~> 3.5.0) railties (>= 3.0.0) - ffi (1.0.11) - gherkin (2.9.3) + ffi (1.1.0) + gherkin (2.11.1) json (>= 1.4.6) hike (1.2.1) i18n (0.6.0) - json (1.6.6) - launchy (2.1.0) - addressable (~> 2.2.6) + json (1.7.3) + libwebsocket (0.1.4) + addressable mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) - mime-types (1.18) + mime-types (1.19) mocha (0.10.5) metaclass (~> 0.0.1) multi_json (1.2.0) - nokogiri (1.5.2) + nokogiri (1.5.5) polyglot (0.3.3) rack (1.3.6) rack-cache (1.2) @@ -108,17 +107,17 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.1.4) - actionmailer (= 3.1.4) - actionpack (= 3.1.4) - activerecord (= 3.1.4) - activeresource (= 3.1.4) - activesupport (= 3.1.4) + rails (3.1.6) + actionmailer (= 3.1.6) + actionpack (= 3.1.6) + activerecord (= 3.1.6) + activeresource (= 3.1.6) + activesupport (= 3.1.6) bundler (~> 1.0) - railties (= 3.1.4) - railties (3.1.4) - actionpack (= 3.1.4) - activesupport (= 3.1.4) + railties (= 3.1.6) + railties (3.1.6) + actionpack (= 3.1.6) + activesupport (= 3.1.6) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -126,40 +125,39 @@ GEM rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) - rspec-rails (2.9.0) + rspec-mocks (2.11.1) + rspec-rails (2.11.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.9.0) - rubyzip (0.9.6.1) - selenium-webdriver (2.20.0) + rspec (~> 2.11.0) + rubyzip (0.9.9) + selenium-webdriver (2.25.0) childprocess (>= 0.2.5) - ffi (~> 1.0) + libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip - shoulda-matchers (1.1.0) + shoulda-matchers (1.2.0) activesupport (>= 3.0.0) - sprockets (2.0.3) + sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) + sqlite3 (1.3.6) thor (0.14.6) tilt (1.3.3) timecop (0.3.5) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) + tzinfo (0.3.33) xpath (0.1.4) nokogiri (~> 1.3) @@ -167,18 +165,17 @@ PLATFORMS ruby DEPENDENCIES - appraisal (~> 0.4.1) - aruba (~> 0.4.11) - bourne (~> 1.1.2) - bundler (~> 1.1) - capybara (~> 1.1.2) + appraisal (= 0.4.1) + aruba (= 0.4.11) + bourne (= 1.1.2) + bundler (= 1.1.3) + capybara (= 1.1.2) clearance! - cucumber-rails (~> 1.1.1) - database_cleaner - factory_girl_rails (~> 3.1.0) - launchy - rails (= 3.1.4) - rspec-rails (~> 2.9.0) - shoulda-matchers (~> 1.1.0) - sqlite3 - timecop + cucumber-rails (= 1.1.1) + database_cleaner (= 0.8.0) + factory_girl_rails (= 3.5.0) + rails (= 3.1.6) + rspec-rails (= 2.11.0) + shoulda-matchers (= 1.2.0) + sqlite3 (= 1.3.6) + timecop (= 0.3.5) diff --git a/gemfiles/3.1.4.gemfile b/gemfiles/3.2.6.gemfile similarity index 63% rename from gemfiles/3.1.4.gemfile rename to gemfiles/3.2.6.gemfile index 23dcd18c2..c09e4667e 100644 --- a/gemfiles/3.1.4.gemfile +++ b/gemfiles/3.2.6.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "rails", "3.1.4" +gem "rails", "3.2.6" gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/3.2.3.gemfile.lock b/gemfiles/3.2.6.gemfile.lock similarity index 52% rename from gemfiles/3.2.3.gemfile.lock rename to gemfiles/3.2.6.gemfile.lock index c8ae956e6..4cb791e2c 100644 --- a/gemfiles/3.2.3.gemfile.lock +++ b/gemfiles/3.2.6.gemfile.lock @@ -3,40 +3,40 @@ PATH specs: clearance (0.16.2) bcrypt-ruby - diesel (~> 0.1.5) + diesel (= 0.1.5) rails (>= 3.0) GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.3) - actionpack (= 3.2.3) + actionmailer (3.2.6) + actionpack (= 3.2.6) mail (~> 2.4.4) - actionpack (3.2.3) - activemodel (= 3.2.3) - activesupport (= 3.2.3) + actionpack (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) rack-cache (~> 1.2) rack-test (~> 0.6.1) - sprockets (~> 2.1.2) - activemodel (3.2.3) - activesupport (= 3.2.3) + sprockets (~> 2.1.3) + activemodel (3.2.6) + activesupport (= 3.2.6) builder (~> 3.0.0) - activerecord (3.2.3) - activemodel (= 3.2.3) - activesupport (= 3.2.3) + activerecord (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.3) - activemodel (= 3.2.3) - activesupport (= 3.2.3) - activesupport (3.2.3) + activeresource (3.2.6) + activemodel (= 3.2.6) + activesupport (= 3.2.6) + activesupport (3.2.6) i18n (~> 0.6) multi_json (~> 1.0) - addressable (2.2.7) + addressable (2.3.1) appraisal (0.4.1) bundler rake @@ -57,47 +57,46 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.1) - ffi (~> 1.0.6) - cucumber (1.1.9) + childprocess (0.3.4) + ffi (~> 1.0, >= 1.0.6) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.9.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.1.1) capybara (>= 1.1.1) cucumber (>= 1.1.0) nokogiri (>= 1.5.0) - database_cleaner (0.7.2) + database_cleaner (0.8.0) diesel (0.1.5) railties diff-lcs (1.1.3) erubis (2.7.0) - factory_girl (3.1.1) + factory_girl (3.5.0) activesupport (>= 3.0.0) - factory_girl_rails (3.1.0) - factory_girl (~> 3.1.0) + factory_girl_rails (3.5.0) + factory_girl (~> 3.5.0) railties (>= 3.0.0) - ffi (1.0.11) - gherkin (2.9.3) + ffi (1.1.0) + gherkin (2.11.1) json (>= 1.4.6) hike (1.2.1) i18n (0.6.0) - journey (1.0.3) - json (1.6.6) - launchy (2.1.0) - addressable (~> 2.2.6) + journey (1.0.4) + json (1.7.3) + libwebsocket (0.1.4) + addressable mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) - mime-types (1.18) + mime-types (1.19) mocha (0.10.5) metaclass (~> 0.0.1) - multi_json (1.2.0) - nokogiri (1.5.2) + multi_json (1.3.6) + nokogiri (1.5.5) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) @@ -106,58 +105,57 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.3) - actionmailer (= 3.2.3) - actionpack (= 3.2.3) - activerecord (= 3.2.3) - activeresource (= 3.2.3) - activesupport (= 3.2.3) + rails (3.2.6) + actionmailer (= 3.2.6) + actionpack (= 3.2.6) + activerecord (= 3.2.6) + activeresource (= 3.2.6) + activesupport (= 3.2.6) bundler (~> 1.0) - railties (= 3.2.3) - railties (3.2.3) - actionpack (= 3.2.3) - activesupport (= 3.2.3) + railties (= 3.2.6) + railties (3.2.6) + actionpack (= 3.2.6) + activesupport (= 3.2.6) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.6) + thor (>= 0.14.6, < 2.0) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) - rspec-rails (2.9.0) + rspec-mocks (2.11.1) + rspec-rails (2.11.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.9.0) - rubyzip (0.9.6.1) - selenium-webdriver (2.20.0) + rspec (~> 2.11.0) + rubyzip (0.9.9) + selenium-webdriver (2.25.0) childprocess (>= 0.2.5) - ffi (~> 1.0) + libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip - shoulda-matchers (1.1.0) + shoulda-matchers (1.2.0) activesupport (>= 3.0.0) - sprockets (2.1.2) + sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) - thor (0.14.6) + sqlite3 (1.3.6) + thor (0.15.4) tilt (1.3.3) timecop (0.3.5) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) + tzinfo (0.3.33) xpath (0.1.4) nokogiri (~> 1.3) @@ -165,18 +163,17 @@ PLATFORMS ruby DEPENDENCIES - appraisal (~> 0.4.1) - aruba (~> 0.4.11) - bourne (~> 1.1.2) - bundler (~> 1.1) - capybara (~> 1.1.2) + appraisal (= 0.4.1) + aruba (= 0.4.11) + bourne (= 1.1.2) + bundler (= 1.1.3) + capybara (= 1.1.2) clearance! - cucumber-rails (~> 1.1.1) - database_cleaner - factory_girl_rails (~> 3.1.0) - launchy - rails (= 3.2.3) - rspec-rails (~> 2.9.0) - shoulda-matchers (~> 1.1.0) - sqlite3 - timecop + cucumber-rails (= 1.1.1) + database_cleaner (= 0.8.0) + factory_girl_rails (= 3.5.0) + rails (= 3.2.6) + rspec-rails (= 2.11.0) + shoulda-matchers (= 1.2.0) + sqlite3 (= 1.3.6) + timecop (= 0.3.5) diff --git a/lib/clearance/user.rb b/lib/clearance/user.rb index 7093fbfa6..f33c06d59 100644 --- a/lib/clearance/user.rb +++ b/lib/clearance/user.rb @@ -105,7 +105,7 @@ def password_optional? end def password_required? - warn "[DEPRECATION] password_required?: use !password_optional? instead" + warn '[DEPRECATION] password_required?: use !password_optional? instead' !password_optional? end end diff --git a/spec/clearance/constraints/signed_in_spec.rb b/spec/clearance/constraints/signed_in_spec.rb index 7d333d32e..4edc581c9 100644 --- a/spec/clearance/constraints/signed_in_spec.rb +++ b/spec/clearance/constraints/signed_in_spec.rb @@ -3,9 +3,9 @@ describe Clearance::Constraints::SignedIn do it 'returns true when user is signed in' do user = create(:user) - signed_in_constraint = Clearance::Constraints::SignedIn.new - signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_true + signed_in_constraint.matches?(request_with_remember_token(user.remember_token)). + should be_true end it 'returns false when user is not signed in' do @@ -15,8 +15,9 @@ it 'yields a signed-in user to a provided block' do user = create(:user, :email => 'before@example.com') + signed_in_constraint = Clearance::Constraints::SignedIn.new do |user| - user.update_attribute(:email, 'after@example.com') + user.update_attribute :email, 'after@example.com' end signed_in_constraint.matches?(request_with_remember_token(user.remember_token)) @@ -27,7 +28,7 @@ user = create(:user, :email => 'before@example.com') signed_in_constraint = Clearance::Constraints::SignedIn.new do |user| - user.update_attribute(:email, 'after@example.com') + user.update_attribute :email, 'after@example.com' end signed_in_constraint.matches?(request_without_remember_token) @@ -36,17 +37,15 @@ it 'matches if the user-provided block returns true' do user = create(:user) - signed_in_constraint = Clearance::Constraints::SignedIn.new { |user| true } - - signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_true + signed_in_constraint.matches?(request_with_remember_token(user.remember_token)). + should be_true end it 'does not match if the user-provided block returns false' do user = create(:user) - signed_in_constraint = Clearance::Constraints::SignedIn.new { |user| false } - - signed_in_constraint.matches?(request_with_remember_token(user.remember_token)).should be_false + signed_in_constraint.matches?(request_with_remember_token(user.remember_token)). + should be_false end end diff --git a/spec/clearance/constraints/signed_out_spec.rb b/spec/clearance/constraints/signed_out_spec.rb index f4e2aa20d..e5e7bf180 100644 --- a/spec/clearance/constraints/signed_out_spec.rb +++ b/spec/clearance/constraints/signed_out_spec.rb @@ -8,8 +8,8 @@ it 'returns false when user is not signed out' do user = create(:user) - signed_out_constraint = Clearance::Constraints::SignedOut.new - signed_out_constraint.matches?(request_with_remember_token(user.remember_token)).should be_false + signed_out_constraint.matches?(request_with_remember_token(user.remember_token)). + should be_false end end diff --git a/spec/clearance/rack_session_spec.rb b/spec/clearance/rack_session_spec.rb index d37ca3429..4affa0270 100644 --- a/spec/clearance/rack_session_spec.rb +++ b/spec/clearance/rack_session_spec.rb @@ -1,23 +1,24 @@ require 'spec_helper' describe Clearance::RackSession do - it "injects a clearance session into the environment" do - expected_session = "the session" - expected_session.stubs(:add_cookie_to_headers) - Clearance::Session.stubs(:new => expected_session) - headers = { "X-Roaring-Lobster" => "Red" } + it 'injects a clearance session into the environment' do + expected_session = 'the session' + expected_session.stubs :add_cookie_to_headers + Clearance::Session.stubs :new => expected_session + headers = { 'X-Roaring-Lobster' => 'Red' } app = Rack::Builder.new do use Clearance::RackSession run lambda { |env| Rack::Response.new(env[:clearance], 200, headers).finish } end - env = Rack::MockRequest.env_for("/") + env = Rack::MockRequest.env_for('/') response = Rack::MockResponse.new(*app.call(env)) Clearance::Session.should have_received(:new).with(env) response.body.should == expected_session - expected_session.should have_received(:add_cookie_to_headers).with(has_entries(headers)) + expected_session.should have_received(:add_cookie_to_headers). + with(has_entries(headers)) end end diff --git a/spec/clearance/session_spec.rb b/spec/clearance/session_spec.rb index 7d3fc62af..8ded3e93b 100644 --- a/spec/clearance/session_spec.rb +++ b/spec/clearance/session_spec.rb @@ -4,95 +4,101 @@ before { Timecop.freeze } after { Timecop.return } - it "finds a user from a cookie" do + it 'finds a user from a cookie' do user = create(:user) env = env_with_remember_token(user.remember_token) - session = Clearance::Session.new(env) session.should be_signed_in session.current_user.should == user end - it "returns nil for an unknown user" do + it 'returns nil for an unknown user' do user = create(:user) - env = env_with_remember_token("bogus") - + env = env_with_remember_token('bogus') session = Clearance::Session.new(env) session.should be_signed_out session.current_user.should be_nil end - it "returns nil without a remember token" do + it 'returns nil without a remember token' do env = env_without_remember_token session = Clearance::Session.new(env) session.should be_signed_out session.current_user.should be_nil end - it "signs in a given user" do + it 'signs in a given user' do user = create(:user) session = Clearance::Session.new(env_without_remember_token) session.sign_in user session.current_user.should == user end - it "sets a remember token cookie with a default expiration of 1 year from now" do + it 'sets a remember token cookie with a default expiration of 1 year from now' do user = create(:user) headers = {} session = Clearance::Session.new(env_without_remember_token) session.sign_in user session.add_cookie_to_headers headers - headers.should set_cookie("remember_token", user.remember_token, 1.year.from_now) + headers.should set_cookie('remember_token', user.remember_token, 1.year.from_now) end - it "sets a remember token cookie with a custom expiration" do + it 'sets a remember token cookie with a custom expiration' do custom_expiration = 1.day.from_now + with_custom_expiration 1.day.from_now do user = create(:user) headers = {} session = Clearance::Session.new(env_without_remember_token) session.sign_in user session.add_cookie_to_headers headers - headers.should set_cookie("remember_token", user.remember_token, 1.day.from_now) - Clearance.configuration.cookie_expiration.call.should be_within(100).of(1.year.from_now) + headers.should set_cookie('remember_token', user.remember_token, 1.day.from_now) + Clearance.configuration.cookie_expiration.call.should be_within(100). + of(1.year.from_now) end end - it "doesn't set a remember token when signed out" do + it 'does not set a remember token when signed out' do headers = {} session = Clearance::Session.new(env_without_remember_token) session.add_cookie_to_headers headers - headers.should_not set_cookie("remember_token") + headers.should_not set_cookie('remember_token') end - it "signs out a user" do + it 'signs out a user' do user = create(:user) old_remember_token = user.remember_token env = env_with_remember_token(old_remember_token) - session = Clearance::Session.new(env) session.sign_out session.current_user.should be_nil user.reload.remember_token.should_not == old_remember_token end + def env_with_cookies(cookies) + Rack::MockRequest.env_for '/', 'HTTP_COOKIE' => serialize_cookies(cookies) + end + def env_with_remember_token(token) - env_with_cookies("remember_token" => token) + env_with_cookies 'remember_token' => token end def env_without_remember_token env_with_cookies({}) end - def env_with_cookies(cookies) - Rack::MockRequest.env_for("/", "HTTP_COOKIE" => serialize_cookies(cookies)) + def restore_default_config + Clearance.configuration = nil + Clearance.configure {} end def serialize_cookies(hash) header = {} + hash.each do |key, value| - Rack::Utils.set_cookie_header!(header, key, value) + Rack::Utils.set_cookie_header! header, key, value end + header['Set-Cookie'] end @@ -101,9 +107,4 @@ def with_custom_expiration(custom_duration) ensure restore_default_config end - - def restore_default_config - Clearance.configuration = nil - Clearance.configure {} - end end diff --git a/spec/controllers/denies_controller_spec.rb b/spec/controllers/denies_controller_spec.rb index 759a89434..2a35ea7a4 100644 --- a/spec/controllers/denies_controller_spec.rb +++ b/spec/controllers/denies_controller_spec.rb @@ -5,17 +5,17 @@ class DeniesController < ActionController::Base before_filter :authorize, :only => :show def new - render :text => "New page" + render :text => 'New page' end def show - render :text => "Show page" + render :text => 'Show page' end protected def authorize - deny_access("Access denied.") + deny_access 'Access denied.' end end @@ -31,30 +31,31 @@ def authorize Rails.application.reload_routes! end - context "signed in user" do + context 'signed in user' do before { sign_in } - it "allows access to new" do + it 'allows access to new' do get :new subject.should_not deny_access end - it "denies access to show" do + it 'denies access to show' do get :show subject.should deny_access(:redirect => '/') end end - context "visitor" do - it "allows access to new" do + context 'visitor' do + it 'allows access to new' do get :new subject.should_not deny_access end - it "denies access to show" do + it 'denies access to show' do get :show subject.should deny_access - subject.should deny_access(:redirect => sign_in_url, :flash => "Access denied.") + subject.should deny_access(:redirect => sign_in_url, + :flash => 'Access denied.') end end end diff --git a/spec/controllers/flashes_controller_spec.rb b/spec/controllers/flashes_controller_spec.rb index 5d1c21a22..38c5900ac 100644 --- a/spec/controllers/flashes_controller_spec.rb +++ b/spec/controllers/flashes_controller_spec.rb @@ -16,8 +16,8 @@ def view_flash describe FlashesController do before do Rails.application.routes.draw do - match "set_flash" => "flashes#set_flash" - match "view_flash" => "flashes#view_flash" + match 'set_flash' => 'flashes#set_flash' + match 'view_flash' => 'flashes#view_flash' end end @@ -25,8 +25,8 @@ def view_flash Rails.application.reload_routes! end - it "sets and views a flash" do - visit "/set_flash?message=hello" - page.should have_content("hello") + it 'sets and views a flash' do + visit '/set_flash?message=hello' + page.should have_content('hello') end end diff --git a/spec/controllers/forgeries_controller_spec.rb b/spec/controllers/forgeries_controller_spec.rb index 36bda4b1b..0df3402de 100644 --- a/spec/controllers/forgeries_controller_spec.rb +++ b/spec/controllers/forgeries_controller_spec.rb @@ -14,7 +14,7 @@ def create end describe ForgeriesController do - context "signed in user" do + context 'signed in user' do before do Rails.application.routes.draw do resources :forgeries @@ -22,26 +22,26 @@ def create end @user = create(:user) - @user.update_attribute(:remember_token, "old-token") - @request.cookies["remember_token"] = "old-token" - @request.session[:_csrf_token] = "golden-ticket" + @user.update_attribute(:remember_token, 'old-token') + @request.cookies['remember_token'] = 'old-token' + @request.session[:_csrf_token] = 'golden-ticket' end after do Rails.application.reload_routes! end - it "succeeds with authentic token" do - post :create, :authenticity_token => "golden-ticket" + it 'succeeds with authentic token' do + post :create, :authenticity_token => 'golden-ticket' subject.should redirect_to(:action => 'index') end - it "fails with invalid token" do - post :create, :authenticity_token => "hax0r" + it 'fails with invalid token' do + post :create, :authenticity_token => 'hax0r' subject.should deny_access end - it "fails with no token" do + it 'fails with no token' do post :create subject.should deny_access end diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index d91d32c18..61dd7aed5 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -3,40 +3,41 @@ describe Clearance::PasswordsController do include Shoulda::Matchers::ActionMailer - it { should route(:get, '/users/1/password/edit'). - to(:controller => 'clearance/passwords', :action => 'edit', :user_id => '1') } + it { + should route(:get, '/users/1/password/edit'). + to(:controller => 'clearance/passwords', :action => 'edit', :user_id => '1') + } - describe "a signed up user" do + describe 'a signed up user' do before do @user = create(:user) end - describe "on GET to #new" do + describe 'on GET to #new' do before { get :new, :user_id => @user.to_param } it { should respond_with(:success) } it { should render_template(:new) } end - describe "on POST to #create" do - describe "with correct email address" do + describe 'on POST to #create' do + describe 'with correct email address' do before do ActionMailer::Base.deliveries.clear post :create, :password => { :email => @user.email } end - it "should generate a token for the change your password email" do + it 'should generate a token for the change your password email' do @user.reload.confirmation_token.should_not be_nil end it { should have_sent_email.with_subject(/change your password/i) } - it { should respond_with(:success) } end - describe "with incorrect email address" do + describe 'with incorrect email address' do before do - email = "user1@example.com" + email = 'user1@example.com' (Clearance.configuration.user_model.exists?(['email = ?', email])).should_not be ActionMailer::Base.deliveries.clear @user.reload.confirmation_token.should == @user.confirmation_token @@ -44,11 +45,11 @@ post :create, :password => { :email => email } end - it "should not generate a token for the change your password email" do + it 'should not generate a token for the change your password email' do @user.reload.confirmation_token.should == @user.confirmation_token end - it "should not send a password reminder email" do + it 'should not send a password reminder email' do ActionMailer::Base.deliveries.should be_empty end @@ -58,19 +59,19 @@ end end - describe "a signed up user and forgotten password" do + describe 'a signed up user and forgotten password' do before do @user = create(:user) @user.forgot_password! end - describe "on GET to #edit with correct id and token" do + describe 'on GET to #edit with correct id and token' do before do get :edit, :user_id => @user.to_param, - :token => @user.confirmation_token + :token => @user.confirmation_token end - it "should find the user" do + it 'should find the user' do assigns(:user).should == @user end @@ -78,16 +79,16 @@ it { should render_template(:edit) } end - describe "on GET to #edit with correct id but blank token" do + describe 'on GET to #edit with correct id but blank token' do before do - get :edit, :user_id => @user.to_param, :token => "" + get :edit, :user_id => @user.to_param, :token => '' end it { should set_the_flash.to(/double check the URL/i).now } it { should render_template(:new) } end - describe "on GET to #edit with correct id but no token" do + describe 'on GET to #edit with correct id but no token' do before do get :edit, :user_id => @user.to_param end @@ -96,55 +97,46 @@ it { should render_template(:new) } end - describe "on PUT to #update with password" do + describe 'on PUT to #update with password' do before do - @new_password = "new_password" + @new_password = 'new_password' @user.encrypted_password.should_not == @new_password - - put(:update, - :user_id => @user, - :token => @user.confirmation_token, - :user => { - :password => @new_password - }) + put :update, :user_id => @user, :token => @user.confirmation_token, + :user => { :password => @new_password } @user.reload end - it "should update password" do + it 'should update password' do @user.encrypted_password.should == @new_password end - it "should clear confirmation token" do + it 'should clear confirmation token' do @user.confirmation_token.should be_nil end - it "should set remember token" do + it 'should set remember token' do @user.remember_token.should_not be_nil end it { should redirect_to_url_after_update } end - describe "on PUT to #update with blank password" do + describe 'on PUT to #update with blank password' do before do - put(:update, - :user_id => @user.to_param, - :token => @user.confirmation_token, - :user => { - :password => '' - }) + put :update, :user_id => @user.to_param, :token => @user.confirmation_token, + :user => { :password => '' } @user.reload end - it "should not update password to be blank" do + it 'should not update password to be blank' do @user.encrypted_password.should_not be_blank end - it "should not clear token" do + it 'should not clear token' do @user.confirmation_token.should_not be_nil end - it "should not be signed in" do + it 'should not be signed in' do cookies[:remember_token].should be_nil end @@ -153,16 +145,12 @@ it { should render_template(:edit) } end - describe "on PUT to #update with an empty token after the user sets a password" do + describe 'on PUT to #update with an empty token after the user sets a password' do before do - put :update, - :user_id => @user.to_param, - :token => @user.confirmation_token, - :user => { :password => 'good password' } - put :update, - :user_id => @user.to_param, - :token => [nil], - :user => { :password => 'new password' } + put :update, :user_id => @user.to_param, :token => @user.confirmation_token, + :user => { :password => 'good password' } + put :update, :user_id => @user.to_param, :token => [nil], + :user => { :password => 'new password' } end it { should set_the_flash.to(/double check the URL/i).now } @@ -170,7 +158,7 @@ end end - describe "given two users and user one signs in" do + describe 'given two users and user one signs in' do before do @user_one = create(:user) @user_two = create(:user) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index ffed64890..a10ce43ed 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Clearance::SessionsController do - describe "on GET to /sessions/new" do + describe 'on GET to /sessions/new' do before { get :new } it { should respond_with(:success) } @@ -9,95 +9,88 @@ it { should_not set_the_flash } end - describe "on POST to #create with good credentials" do + describe 'on POST to #create with good credentials' do before do @user = create(:user) - @user.update_attribute(:remember_token, "old-token") - post :create, :session => { - :email => @user.email, - :password => @user.password } + @user.update_attribute :remember_token, 'old-token' + post :create, :session => { :email => @user.email, :password => @user.password } end it { should redirect_to_url_after_create } - it "sets the user in the clearance session" do + it 'sets the user in the clearance session' do controller.current_user.should == @user end - it "should not change the remember token" do - @user.reload.remember_token.should == "old-token" + it 'should not change the remember token' do + @user.reload.remember_token.should == 'old-token' end end - describe "on POST to #create with good credentials and a session return url" do + describe 'on POST to #create with good credentials and a session return url' do before do @user = create(:user) @return_url = '/url_in_the_session' @request.session[:return_to] = @return_url - post :create, :session => { - :email => @user.email, - :password => @user.password } + post :create, :session => { :email => @user.email, :password => @user.password } end - it "redirects to the return URL" do + it 'redirects to the return URL' do should redirect_to(@return_url) end end - describe "on POST to #create with good credentials and a request return url" do + describe 'on POST to #create with good credentials and a request return url' do before do @user = create(:user) @return_url = '/url_in_the_request' - post :create, :session => { - :email => @user.email, - :password => @user.password }, - :return_to => @return_url + post :create, :session => { :email => @user.email, :password => @user.password }, + :return_to => @return_url end - it "redirects to the return URL" do + it 'redirects to the return URL' do should redirect_to(@return_url) end end - describe "on POST to #create with good credentials and a session return url and request return url" do + describe 'on POST to #create with good credentials and a session return url and request return url' do before do @user = create(:user) @return_url = '/url_in_the_session' @request.session[:return_to] = @return_url - post :create, :session => { - :email => @user.email, - :password => @user.password }, - :return_to => '/url_in_the_request' + post :create, :session => { :email => @user.email, :password => @user.password }, + :return_to => '/url_in_the_request' end - it "redirects to the return url" do + it 'redirects to the return url' do should redirect_to(@return_url) end end - describe "on DELETE to #destroy given a signed out user" do + describe 'on DELETE to #destroy given a signed out user' do before do sign_out delete :destroy end + it { should redirect_to_url_after_destroy } end - describe "on DELETE to #destroy with a cookie" do + describe 'on DELETE to #destroy with a cookie' do before do @user = create(:user) - @user.update_attribute(:remember_token, "old-token") - @request.cookies["remember_token"] = "old-token" + @user.update_attribute :remember_token, 'old-token' + @request.cookies['remember_token'] = 'old-token' delete :destroy end it { should redirect_to_url_after_destroy } - it "should reset the remember token" do - @user.reload.remember_token.should_not == "old-token" + it 'should reset the remember token' do + @user.reload.remember_token.should_not == 'old-token' end - it "should unset the current user" do + it 'should unset the current user' do @controller.current_user.should be_nil end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 3b1ce7176..4396b9e71 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe Clearance::UsersController do - describe "when signed out" do + describe 'when signed out' do before { sign_out } - describe "on GET to #new" do + describe 'on GET to #new' do before { get :new } it { should respond_with(:success) } @@ -12,18 +12,18 @@ it { should_not set_the_flash } end - describe "on GET to #new with email" do + describe 'on GET to #new with email' do before do - @email = "a@example.com" + @email = 'a@example.com' get :new, :user => { :email => @email } end - it "should set assigned user's email" do + it 'should set assigned user email' do assigns(:user).email.should == @email end end - describe "on POST to #create with valid attributes" do + describe 'on POST to #create with valid attributes' do before do user_attributes = FactoryGirl.attributes_for(:user) @old_user_count = User.count @@ -32,14 +32,14 @@ it { should assign_to(:user) } - it "should create a new user" do + it 'should create a new user' do User.count.should == @old_user_count + 1 end it { should redirect_to_url_after_create } end - describe "on POST to #create with valid attributes and a session return url" do + describe 'on POST to #create with valid attributes and a session return url' do before do user_attributes = FactoryGirl.attributes_for(:user) @old_user_count = User.count @@ -50,7 +50,7 @@ it { should assign_to(:user) } - it "should create a new user" do + it 'should create a new user' do User.count.should == @old_user_count + 1 end @@ -58,22 +58,24 @@ end end - describe "A signed-in user" do + describe 'A signed-in user' do before do @user = create(:user) sign_in_as @user end - describe "GET to new" do + describe 'GET to new' do before { get :new } - it "redirects to the home page" do + + it 'redirects to the home page' do should redirect_to(root_url) end end - describe "POST to create" do + describe 'POST to create' do before { post :create, :user => {} } - it "redirects to the home page" do + + it 'redirects to the home page' do should redirect_to(root_url) end end diff --git a/spec/factories.rb b/spec/factories.rb index 36144a3a9..333e25044 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,12 +1,10 @@ FactoryGirl.define do - sequence :email do |n| "user#{n}@example.com" end factory :user do email - password "password" + password 'password' end - end diff --git a/spec/mailers/clearance_mailer_spec.rb b/spec/mailers/clearance_mailer_spec.rb index 25c24510a..83f56c2ad 100644 --- a/spec/mailers/clearance_mailer_spec.rb +++ b/spec/mailers/clearance_mailer_spec.rb @@ -7,21 +7,21 @@ @email = ClearanceMailer.change_password(@user) end - it "should be from DO_NOT_REPLY" do + it 'is from DO_NOT_REPLY' do Clearance.configuration.mailer_sender.should =~ /#{@email.from[0]}/i end - it "should be sent to user" do + it 'is sent to user' do @email.to.first.should =~ /#{@user.email}/i end - it "should contain a link to edit the user's password" do + it 'contains a link to edit the password' do host = ActionMailer::Base.default_url_options[:host] regexp = %r{http://#{host}/users/#{@user.id}/password/edit\?token=#{@user.confirmation_token}} @email.body.to_s.should =~ regexp end - it "should set its subject" do + it 'should set its subject' do @email.subject.should =~ /Change your password/ end end diff --git a/spec/models/bcrypt_migration_from_sha1_spec.rb b/spec/models/bcrypt_migration_from_sha1_spec.rb index 63883ef05..f5099d373 100644 --- a/spec/models/bcrypt_migration_from_sha1_spec.rb +++ b/spec/models/bcrypt_migration_from_sha1_spec.rb @@ -9,32 +9,31 @@ end.new end - describe "#password=" do - let(:salt) { "salt" } - let(:password) { "password" } - let(:encrypted_password) { stub("encrypted password") } + describe '#password=' do + let(:salt) { 'salt' } + let(:password) { 'password' } + let(:encrypted_password) { stub('encrypted password') } before do subject.salt = salt subject.encrypted_password = Digest::SHA1.hexdigest("--#{salt}--#{password}--") - - BCrypt::Password.stubs(:create => encrypted_password) + BCrypt::Password.stubs :create => encrypted_password subject.password = password end - it "encrypts the password into a BCrypt-encrypted encrypted_password" do + it 'encrypts the password into a BCrypt-encrypted encrypted_password' do subject.encrypted_password.should == encrypted_password end - it "encrypts with BCrypt" do + it 'encrypts with BCrypt' do BCrypt::Password.should have_received(:create).with(password) end end - describe "#authenticated?" do - let(:password) { "password" } - let(:salt) { "salt" } - let(:sha1_hash) { Digest::SHA1.hexdigest("--#{salt}--#{password}--") } + describe '#authenticated?' do + let(:password) { 'password' } + let(:salt) { 'salt' } + let(:sha1_hash) { Digest::SHA1.hexdigest("--#{salt}--#{password}--") } context 'with a SHA1-encrypted password' do before do @@ -42,29 +41,29 @@ subject.encrypted_password = sha1_hash end - it "is authenticated" do + it 'is authenticated' do subject.should be_authenticated(password) end - it "changes the hash into a BCrypt-encrypted one" do - subject.authenticated?(password) + it 'changes the hash into a BCrypt-encrypted one' do + subject.authenticated? password subject.encrypted_password.should_not == sha1_hash end end - context "with a BCrypt-encrypted password" do + context 'with a BCrypt-encrypted password' do let(:bcrypt_hash) { ::BCrypt::Password.create(password) } before do subject.encrypted_password = bcrypt_hash end - it "is authenticated" do + it 'is authenticated' do subject.should be_authenticated(password) end - it "does not change the hash" do - subject.authenticated?(password) + it 'does not change the hash' do + subject.authenticated? password subject.encrypted_password.to_s.should == bcrypt_hash.to_s end end diff --git a/spec/models/bcrypt_spec.rb b/spec/models/bcrypt_spec.rb index b1cad7c09..af0cdc831 100644 --- a/spec/models/bcrypt_spec.rb +++ b/spec/models/bcrypt_spec.rb @@ -8,33 +8,32 @@ end.new end - describe "#password=" do - let(:password) { "password" } - let(:encrypted_password) { stub("encrypted password") } + describe '#password=' do + let(:password) { 'password' } + let(:encrypted_password) { stub('encrypted password') } before do - BCrypt::Password.stubs(:create => encrypted_password) - + BCrypt::Password.stubs :create => encrypted_password subject.password = password end - it "encrypts the password into encrypted_password" do + it 'encrypts the password into encrypted_password' do subject.encrypted_password.should == encrypted_password end - it "encrypts with BCrypt" do + it 'encrypts with BCrypt' do BCrypt::Password.should have_received(:create).with(password) end end - describe "#authenticated?" do - let(:password) { "password" } + describe '#authenticated?' do + let(:password) { 'password' } before do subject.password = password end - it "is authenticated with BCrypt" do + it 'is authenticated with BCrypt' do subject.should be_authenticated(password) end end diff --git a/spec/models/blowfish_spec.rb b/spec/models/blowfish_spec.rb index 3b9ef7833..6e64404e9 100644 --- a/spec/models/blowfish_spec.rb +++ b/spec/models/blowfish_spec.rb @@ -6,41 +6,39 @@ attr_accessor :salt, :encrypted_password include Clearance::PasswordStrategies::Blowfish - def generate_random_code; "code"; end + def generate_random_code; 'code'; end end.new end - describe "#password=" do - context "when the password is set" do - let(:salt) { "salt" } - let(:password) { "password" } + describe '#password=' do + context 'when the password is set' do + let(:salt) { 'salt' } + let(:password) { 'password' } before do subject.salt = salt subject.password = password end - it "doesn't initialize the salt" do + it 'does not initialize the salt' do subject.salt.should == salt end - it "encrypts the password using Blowfish into encrypted_password" do + it 'encrypts the password using Blowfish and the existing salt' do cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').encrypt cipher.key = Digest::SHA256.digest(salt) expected = cipher.update("--#{salt}--#{password}--") << cipher.final - subject.encrypted_password.should == expected end end - context "when the salt is not set" do + context 'when the salt is not set' do before do subject.salt = nil - subject.password = 'whatever' end - it "should initialize the salt" do + it 'should initialize the salt' do subject.salt.should_not be_nil end end diff --git a/spec/models/sha1_spec.rb b/spec/models/sha1_spec.rb index 0c22df2ab..cb26a90e1 100644 --- a/spec/models/sha1_spec.rb +++ b/spec/models/sha1_spec.rb @@ -10,23 +10,22 @@ def generate_random_code; "code"; end end.new end - describe "#password=" do - context "when the password is set" do - let(:salt) { "salt" } - let(:password) { "password" } + describe '#password=' do + context 'when the password is set' do + let(:salt) { 'salt' } + let(:password) { 'password' } before do - subject.salt = salt + subject.salt = salt subject.password = password end - it "doesn't initialize the salt" do + it 'does not initialize the salt' do subject.salt.should == salt end - it "encrypts the password using SHA1 and the existing salt into encrypted_password" do + it 'encrypts the password using SHA1 and the existing salt' do expected = Digest::SHA1.hexdigest("--#{salt}--#{password}--") - subject.encrypted_password.should == expected end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2cbd67056..c06370751 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4,129 +4,131 @@ it { should have_db_index(:email) } it { should have_db_index(:remember_token) } - describe "When signing up" do + describe 'when signing up' do it { should validate_presence_of(:email) } it { should validate_presence_of(:password) } - it { should allow_value("foo@example.co.uk").for(:email) } - it { should allow_value("foo@example.com").for(:email) } - it { should_not allow_value("foo@").for(:email) } - it { should_not allow_value("foo@example..com").for(:email) } - it { should_not allow_value("foo@.example.com").for(:email) } - it { should_not allow_value("foo").for(:email) } - it { should_not allow_value("example.com").for(:email) } - - it "should store email in down case" do - user = create(:user, :email => "John.Doe@example.com") - user.email.should == "john.doe@example.com" + it { should allow_value('foo@example.co.uk').for(:email) } + it { should allow_value('foo@example.com').for(:email) } + it { should_not allow_value('foo@').for(:email) } + it { should_not allow_value('foo@example..com').for(:email) } + it { should_not allow_value('foo@.example.com').for(:email) } + it { should_not allow_value('foo').for(:email) } + it { should_not allow_value('example.com').for(:email) } + + it 'stores email in down case' do + user = create(:user, :email => 'John.Doe@example.com') + user.email.should == 'john.doe@example.com' end end - describe "When multiple users have signed up" do + describe 'when multiple users have signed up' do before { create(:user) } it { should validate_uniqueness_of(:email) } end - describe "A user" do + describe 'a user' do before do - @user = create(:user) + @user = create(:user) @password = @user.password end - it "is authenticated with correct email and password" do - (Clearance.configuration.user_model.authenticate(@user.email, @password)).should be + it 'is authenticated with correct email and password' do + (Clearance.configuration.user_model.authenticate(@user.email, @password)). + should be @user.should be_authenticated(@password) end - it "is authenticated with correct uppercased email and correct password" do - (Clearance.configuration.user_model.authenticate(@user.email.upcase, @password)).should be + it 'is authenticated with correct uppercased email and correct password' do + (Clearance.configuration.user_model.authenticate(@user.email.upcase, @password)). + should be @user.should be_authenticated(@password) end - it "is authenticated with incorrect credentials" do - (Clearance.configuration.user_model.authenticate(@user.email, 'bad_password')).should_not be + it 'is authenticated with incorrect credentials' do + (Clearance.configuration.user_model.authenticate(@user.email, 'bad_password')). + should_not be @user.should_not be_authenticated('bad password') end end - describe "When resetting authentication with reset_remember_token!" do + describe 'when resetting authentication with reset_remember_token!' do before do @user = create(:user) - @user.remember_token = "old-token" + @user.remember_token = 'old-token' @user.reset_remember_token! end - it "should change the remember token" do - @user.remember_token.should_not == "old-token" + it 'changes the remember token' do + @user.remember_token.should_not == 'old-token' end end - describe "An email confirmed user" do + describe 'an email confirmed user' do before do @user = create(:user) @old_encrypted_password = @user.encrypted_password end - describe "who updates password" do + describe 'who updates password' do before do - @user.update_password("new_password") + @user.update_password('new_password') end - it "should change encrypted password" do + it 'changes encrypted password' do @user.encrypted_password.should_not == @old_encrypted_password end end end - it "should not generate the same remember token for users with the same password at the same time" do - Time.stubs(:now => Time.now) - password = 'secret' - first_user = create(:user, :password => password) + it 'does not generate same remember token for users with same password at same time' do + Time.stubs :now => Time.now + password = 'secret' + first_user = create(:user, :password => password) second_user = create(:user, :password => password) - second_user.remember_token.should_not == first_user.remember_token end - describe "An user" do + describe 'a user' do before do @user = create(:user) @old_encrypted_password = @user.encrypted_password end - describe "who requests password reminder" do + describe 'who requests password reminder' do before do @user.confirmation_token.should be_nil @user.forgot_password! end - it "generates confirmation token" do + it 'generates confirmation token' do @user.confirmation_token.should_not be_nil end - describe "and then updates password" do + describe 'and then updates password' do describe 'with password' do before do - @user.update_password("new_password") + @user.update_password 'new_password' end - it "changes encrypted password" do + it 'changes encrypted password' do @user.encrypted_password.should_not == @old_encrypted_password end - it "clears confirmation token" do + it 'clears confirmation token' do @user.confirmation_token.should be_nil end end describe 'with blank password' do before do - @user.update_password("") + @user.update_password '' end - it "does not change encrypted password" do + it 'does not change encrypted password' do @user.encrypted_password.should == @old_encrypted_password end - it "does not clear confirmation token" do + it 'does not clear confirmation token' do @user.confirmation_token.should_not be_nil end end @@ -134,7 +136,7 @@ end end - describe "a user with an optional email" do + describe 'a user with an optional email' do before do @user = User.new class << @user @@ -147,12 +149,13 @@ def email_optional? subject { @user } it { should allow_value(nil).for(:email) } - it { should allow_value("").for(:email) } + it { should allow_value('').for(:email) } end - describe "a user with an optional password" do + describe 'a user with an optional password' do before do @user = User.new + class << @user def password_optional? true @@ -163,16 +166,16 @@ def password_optional? subject { @user } it { should allow_value(nil).for(:password) } - it { should allow_value("").for(:password) } + it { should allow_value('').for(:password) } end - describe "user factory" do - it "should create a valid user with just an overridden password" do - build(:user, :password => "test").should be_valid + describe 'user factory' do + it 'should create a valid user with just an overridden password' do + build(:user, :password => 'test').should be_valid end end - describe "when user exists before Clearance was installed" do + describe 'when user exists before Clearance was installed' do before do @user = create(:user) sql = "update users set encrypted_password = NULL, remember_token = NULL where id = #{@user.id}" @@ -181,22 +184,22 @@ def password_optional? @user.reload.remember_token.should be_nil end - it "should generate remember token and save encrypted password on update_password" do + it 'generates remember token and save encrypted password on update_password' do @user.update_password('password') @user.encrypted_password.should_not be_nil @user.remember_token.should_not be_nil end end - describe "The password setter on a User" do - let(:password) { "a-password" } + describe 'the password setter on a User' do + let(:password) { 'a-password' } before { subject.send(:password=, password) } - it "sets password to the plain-text password" do + it 'sets password to the plain-text password' do subject.password.should == password end - it "also sets encrypted_password" do + it 'also sets encrypted_password' do subject.encrypted_password.should_not be_nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd7d8e3fb..2db6a545a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ -ENV["RAILS_ENV"] ||= "test" +ENV['RAILS_ENV'] ||= 'test' -PROJECT_ROOT = File.expand_path("../..", __FILE__) -$LOAD_PATH << File.join(PROJECT_ROOT, "lib") +PROJECT_ROOT = File.expand_path('../..', __FILE__) +$LOAD_PATH << File.join(PROJECT_ROOT, 'lib') require 'rails/all' require 'rails/test_help' @@ -14,13 +14,12 @@ require 'timecop' require 'factory_girl_rails' require 'shoulda-matchers' - require 'clearance/testing' -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} +Dir[Rails.root.join('spec/support/**/*.rb')].each {|f| require f} RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods config.mock_with :mocha config.use_transactional_fixtures = true - config.include FactoryGirl::Syntax::Methods end diff --git a/spec/support/clearance.rb b/spec/support/clearance.rb index 3582857a3..1fa6c89e7 100644 --- a/spec/support/clearance.rb +++ b/spec/support/clearance.rb @@ -25,10 +25,6 @@ def redirect_to_url_after_update def redirect_to_url_after_destroy redirect_to(@controller.send(:url_after_destroy)) end - - def redirect_to_url_already_confirmed - redirect_to(@controller.send(:url_already_confirmed)) - end end end end diff --git a/spec/support/cookies.rb b/spec/support/cookies.rb index 0640bcfff..e6f02fd77 100644 --- a/spec/support/cookies.rb +++ b/spec/support/cookies.rb @@ -1,21 +1,40 @@ RSpec::Matchers.define :set_cookie do |name, expected_value, expected_expires_at| + failure_message_for_should do + "Expected #{expectation} got #{result}" + end + match do |subject| @headers = subject @expected_name = name @expected_value = expected_value @expected_expires_at = expected_expires_at - extract_cookies find_expected_cookie parse_expiration parse_value parse_path - ensure_cookie_set ensure_expiration_correct ensure_path_is_correct end + def ensure_cookie_set + @value.should == @expected_value + end + + def ensure_expiration_correct + @expires_at.should_not be_nil + @expires_at.should be_within(100).of(@expected_expires_at) + end + + def ensure_path_is_correct + @path.should == "/" + end + + def expectation + "a cookie named #{@expected_name} with value #{@expected_value.inspect} expiring at #{@expected_expires_at.inspect}" + end + def extract_cookies @cookie_headers = @headers['Set-Cookie'] || [] @cookie_headers = [@cookie_headers] if @cookie_headers.respond_to?(:to_str) @@ -33,37 +52,16 @@ def parse_expiration end end - def parse_value - if @cookie && result = @cookie.match(/=(.*?)(?:;|$)/) - @value = result[1] - end - end - def parse_path if @cookie && result = @cookie.match(/; path=(.*?)(;|$)/) @path = result[1] end end - def ensure_cookie_set - @value.should == @expected_value - end - - def ensure_expiration_correct - @expires_at.should_not be_nil - @expires_at.should be_within(100).of(@expected_expires_at) - end - - def ensure_path_is_correct - @path.should == "/" - end - - failure_message_for_should do - "Expected #{expectation} got #{result}" - end - - def expectation - "a cookie named #{@expected_name} with value #{@expected_value.inspect} expiring at #{@expected_expires_at.inspect}" + def parse_value + if @cookie && result = @cookie.match(/=(.*?)(?:;|$)/) + @value = result[1] + end end def result diff --git a/spec/support/request_with_remember_token.rb b/spec/support/request_with_remember_token.rb index f541a56a7..2436865ab 100644 --- a/spec/support/request_with_remember_token.rb +++ b/spec/support/request_with_remember_token.rb @@ -1,14 +1,16 @@ module RememberTokenHelpers def request_with_remember_token(remember_token) - cookies = {'action_dispatch.cookies' => { - Clearance::Session::REMEMBER_TOKEN_COOKIE => remember_token - }} + cookies = { + 'action_dispatch.cookies' => { + Clearance::Session::REMEMBER_TOKEN_COOKIE => remember_token + } + } env = { :clearance => Clearance::Session.new(cookies) } - Rack::Request.new(env) + Rack::Request.new env end def request_without_remember_token - request_with_remember_token(nil) + request_with_remember_token nil end end