diff --git a/.gitignore b/.gitignore index 75308ca..16ddf48 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ -/Gemfile-custom.rb -/Gemfile.lock /config/database.yml +/config/secrets.yml /data/ /log/*.log /tmp/ diff --git a/Gemfile b/Gemfile index 215fb9b..e7d5b2a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,29 @@ -source 'http://rubygems.org' +source 'https://rubygems.org' + +gem 'rails', '~> 4.2.1' +gem 'pg' +gem 'bcrypt' +gem 'unicorn-rails' + +gem 'haml' +gem 'rabl' -gem 'rails', '~> 4.0' -gem 'pg', '~> 0.17' -gem 'haml', '~> 4.0' -gem 'bcrypt', '~> 3.0' -gem 'rabl', '~> 0.6' group :development, :test do - gem 'rspec-rails', '~> 2.6' - gem 'spork', '~> 1.0rc' - gem 'capybara', '~> 2.2' - gem 'factory_girl_rails', '~> 4.4' - gem 'shoulda-matchers', '~> 2.5' + gem 'pry-rails' end -eval File.read('Gemfile-custom.rb') if File.exist?('Gemfile-custom.rb') +group :test do + gem 'rspec-rails' + gem 'rspec-activemodel-mocks' + + gem 'spork', github: 'tjouan/spork', branch: 'rspec-3' + gem 'capybara' + gem 'factory_girl_rails' + gem 'shoulda-matchers' + + gem 'rb-kqueue', require: false + gem 'guard', require: false + gem 'guard-rspec', require: false + gem 'guard-spork', require: false +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..4b60d46 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,230 @@ +GIT + remote: git://github.com/tjouan/spork.git + revision: 49ab62dd1e3f250cc438be928cf47f6dd0763923 + branch: rspec-3 + specs: + spork (1.0.0rc4) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.1) + actionview (= 4.2.1) + activesupport (= 4.2.1) + rack (~> 1.6) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.1) + activesupport (= 4.2.1) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.1) + activesupport (= 4.2.1) + globalid (>= 0.3.0) + activemodel (4.2.1) + activesupport (= 4.2.1) + builder (~> 3.1) + activerecord (4.2.1) + activemodel (= 4.2.1) + activesupport (= 4.2.1) + arel (~> 6.0) + activesupport (4.2.1) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + arel (6.0.0) + bcrypt (3.1.10) + builder (3.2.2) + capybara (2.4.4) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + celluloid (0.16.0) + timers (~> 4.0.0) + childprocess (0.5.6) + ffi (~> 1.0, >= 1.0.11) + coderay (1.1.0) + diff-lcs (1.2.5) + erubis (2.7.0) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) + ffi (1.9.8) + formatador (0.2.5) + globalid (0.3.5) + activesupport (>= 4.1.0) + guard (2.12.5) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.5.0) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) + guard-spork (2.1.0) + childprocess (>= 0.2.3) + guard (~> 2.0) + guard-compat (~> 1.0) + spork (>= 0.8.4) + haml (4.0.6) + tilt + hitimes (1.2.2) + i18n (0.7.0) + json (1.8.2) + kgio (2.9.3) + listen (2.10.0) + celluloid (~> 0.16.0) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + loofah (2.0.1) + nokogiri (>= 1.5.9) + lumberjack (1.0.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + method_source (0.8.2) + mime-types (2.5) + mini_portile (0.6.2) + minitest (5.6.1) + nenv (0.2.0) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + notiffany (0.0.6) + nenv (~> 0.1) + shellany (~> 0.0) + pg (0.18.1) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-rails (0.3.4) + pry (>= 0.9.10) + rabl (0.11.6) + activesupport (>= 2.3.14) + rack (1.6.0) + rack-test (0.6.3) + rack (>= 1.0) + rails (4.2.1) + actionmailer (= 4.2.1) + actionpack (= 4.2.1) + actionview (= 4.2.1) + activejob (= 4.2.1) + activemodel (= 4.2.1) + activerecord (= 4.2.1) + activesupport (= 4.2.1) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.1) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.6) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.2) + loofah (~> 2.0) + railties (4.2.1) + actionpack (= 4.2.1) + activesupport (= 4.2.1) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + raindrops (0.13.0) + rake (10.4.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + rb-kqueue (0.2.3) + ffi (>= 0.5.0) + rspec (3.2.0) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-activemodel-mocks (1.0.1) + activemodel (>= 3.0) + activesupport (>= 3.0) + rspec-mocks (>= 2.99, < 4.0) + rspec-core (3.2.3) + rspec-support (~> 3.2.0) + rspec-expectations (3.2.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-mocks (3.2.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-rails (3.2.1) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-support (~> 3.2.0) + rspec-support (3.2.2) + shellany (0.0.1) + shoulda-matchers (2.8.0) + activesupport (>= 3.0.0) + slop (3.6.0) + sprockets (3.0.3) + rack (~> 1.0) + sprockets-rails (2.2.4) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.1) + timers (4.0.1) + hitimes + tzinfo (1.2.2) + thread_safe (~> 0.1) + unicorn (4.9.0) + kgio (~> 2.6) + rack + raindrops (~> 0.7) + unicorn-rails (2.2.0) + rack + unicorn + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + bcrypt + capybara + factory_girl_rails + guard + guard-rspec + guard-spork + haml + pg + pry-rails + rabl + rails (~> 4.2.1) + rb-kqueue + rspec-activemodel-mocks + rspec-rails + shoulda-matchers + spork! + unicorn-rails diff --git a/app/controllers/api/playlists_controller.rb b/app/controllers/api/playlists_controller.rb index 89d0881..8f83019 100644 --- a/app/controllers/api/playlists_controller.rb +++ b/app/controllers/api/playlists_controller.rb @@ -1,7 +1,5 @@ module API class PlaylistsController < ApplicationController - respond_to :json - def index @playlists = Playlist.all end diff --git a/bin/rails b/bin/rails index 71755b8..fad8d8b 100755 --- a/bin/rails +++ b/bin/rails @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/config/application.rb b/config/application.rb index d6d9e6d..55cb828 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,5 +19,8 @@ module Scube # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 5e5f0c1..6b750f0 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index 5eb742d..ee8d90d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the Rails application. -Scube::Application.initialize! +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 45657fe..b55e214 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -Scube::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on @@ -19,11 +19,23 @@ Scube::Application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index ea700d0..2aa88a8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,11 +1,11 @@ -Scube::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers + # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true @@ -16,11 +16,13 @@ Scube::Application.configure do # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -29,20 +31,21 @@ Scube::Application.configure do # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs. + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Set to :debug to see everything in the log. + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. config.log_level = :info # Prepend all log lines with the following tags. @@ -55,26 +58,22 @@ Scube::Application.configure do # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets. - # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) + # config.action_controller.asset_host = 'http://assets.example.com' # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found). + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Disable automatic flushing of the log to improve performance. - # config.autoflush_log = false - # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 70c5a9e..1c19f08 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -Scube::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's @@ -12,9 +12,9 @@ Scube::Application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -31,6 +31,12 @@ Scube::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Randomize the order test cases are executed. + config.active_support.test_order = :random + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7f70458 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e..dc18996 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index bc77e55..449749e 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Scube::Application.config.session_store :cookie_store, key: '_scube_session' +Rails.application.config.session_store :cookie_store, key: '_scube_session' diff --git a/config/routes.rb b/config/routes.rb index d253a8f..19e7381 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -Scube::Application.routes.draw do +Rails.application.routes.draw do namespace :api do resources :sounds, only: [:show] resources :tracks, only: [:index] diff --git a/spec/controllers/api/playlists_controller_spec.rb b/spec/controllers/api/playlists_controller_spec.rb index 05b75e1..84599e7 100644 --- a/spec/controllers/api/playlists_controller_spec.rb +++ b/spec/controllers/api/playlists_controller_spec.rb @@ -19,7 +19,7 @@ describe API::PlaylistsController do end it 'lists all playlists' do - expect(do_get).to have(2).items + expect(do_get.size).to eq 2 end it 'lists playlists with their id' do diff --git a/spec/controllers/api/tracks_controller_spec.rb b/spec/controllers/api/tracks_controller_spec.rb index b31008a..7aa8059 100644 --- a/spec/controllers/api/tracks_controller_spec.rb +++ b/spec/controllers/api/tracks_controller_spec.rb @@ -19,7 +19,7 @@ describe API::TracksController do end it 'lists all tracks' do - expect(do_get).to have(2).items + expect(do_get.size).to eq 2 end it 'lists tracks with their id' do diff --git a/spec/factories.rb b/spec/factories.rb index 0d2c2d3..6a5c9ce 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,7 +1,7 @@ def build_sound_file - file = File.new("#{Rails.root}/spec/fixtures/test.mp3") - file.stub(content_type: 'audio/mpeg') - file + File.new("#{Rails.root}/spec/fixtures/test.mp3").tap do |o| + o.define_singleton_method(:content_type) { 'audio/mpeg' } + end end FactoryGirl.define do diff --git a/spec/integration/api/api_sign_in_spec.rb b/spec/integration/api/api_sign_in_spec.rb index 34196a9..76398de 100644 --- a/spec/integration/api/api_sign_in_spec.rb +++ b/spec/integration/api/api_sign_in_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'API sign in' do +describe 'API sign in' do let(:user) { FactoryGirl.create(:user) } def do_create @@ -10,7 +10,7 @@ feature 'API sign in' do } end - scenario 'signs the user in with valid credentials' do + it 'signs the user in with valid credentials' do do_create expect(response).to be_success @@ -18,7 +18,7 @@ feature 'API sign in' do end [:email, :password].each do |attr| - scenario "rejects authentication with invalid credentials (#{attr})" do + it "rejects authentication with invalid credentials (#{attr})" do allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID') do_create diff --git a/spec/integration/api/cross_origin_request_spec.rb b/spec/integration/api/cross_origin_request_spec.rb index 6fa0f55..9339c57 100644 --- a/spec/integration/api/cross_origin_request_spec.rb +++ b/spec/integration/api/cross_origin_request_spec.rb @@ -1,19 +1,19 @@ require 'spec_helper' -feature 'API cross origin request' do +describe 'API cross origin request' do include UserIntegrationHelpers let(:user) { FactoryGirl.create(:user) } let(:origin) { 'http://origin.example/' } - background do + before do post sessions_path, session: { email: user.email, password: user.password } end - scenario 'preflight request' do + it 'responds to preflight request' do @integration_session.send( :process, :options, @@ -30,7 +30,7 @@ feature 'API cross origin request' do .to eq 'Content-Type, Content-Length, X-Requested-With' end - scenario 'basic request' do + it 'responds to basic request' do # FIXME: replace with a more stable/generic action get api_playlists_path(format: :json), nil, 'Origin' => origin @@ -40,7 +40,7 @@ feature 'API cross origin request' do .to eq 'Content-Length' end - scenario 'request without origin' do + it 'responds to request without origin' do # FIXME: replace with a more stable/generic action get api_playlists_path(format: :json) diff --git a/spec/integration/api/playlists_spec.rb b/spec/integration/api/playlists_spec.rb index 33cf9b0..d6135dc 100644 --- a/spec/integration/api/playlists_spec.rb +++ b/spec/integration/api/playlists_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' -feature 'API playlists' do +describe 'API playlists' do include UserIntegrationHelpers - background { api_sign_in } + before { api_sign_in } - scenario 'creates playlist' do + it 'creates playlist' do playlist = FactoryGirl.attributes_for :playlist - post api_playlists_path, + post_via_redirect api_playlists_path, format: :json, playlist: playlist diff --git a/spec/integration/api/tracks_spec.rb b/spec/integration/api/tracks_spec.rb index 09e18ea..063812d 100644 --- a/spec/integration/api/tracks_spec.rb +++ b/spec/integration/api/tracks_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -feature 'API tracks' do +describe 'API tracks' do include UserIntegrationHelpers - background { api_sign_in } + before { api_sign_in } - scenario 'lists tracks' do + it 'lists tracks' do track_1 = FactoryGirl.create(:track_with_sound, name: 'Track 1') track_2 = FactoryGirl.create(:track, name: 'Track 2') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e9381ee..a8d21fd 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,8 +1,7 @@ require 'spec_helper' describe User do - subject { user } - let(:user) { FactoryGirl.build(:user) } + subject(:user) { FactoryGirl.build(:user) } it { should be_valid } it { should have_many :playlists } @@ -12,11 +11,14 @@ describe User do context 'when a user with the same email address already exists' do let(:old_user) { FactoryGirl.create(:user, email: 'unique@example.net') } - subject { FactoryGirl.build(:user, email: old_user.email) } + subject(:user) { FactoryGirl.build(:user, email: old_user.email) } it { should_not be_valid } - it { should have(1).error_on(:email) } + it 'has an error on email attribute' do + user.valid? + expect(user.errors[:email].size).to eq 1 + end end context 'when password_confirmation does not match password' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd64829..14fc638 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,7 @@ Spork.prefork do Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } RSpec.configure do |config| + config.infer_spec_type_from_file_location! config.mock_with :rspec config.use_transactional_fixtures = true Rails.configuration.sounds_path = "#{Rails.root}/tmp/spec/data/sounds" diff --git a/spec/support/user_integration_helpers.rb b/spec/support/user_integration_helpers.rb index 71aebcd..5fdef02 100644 --- a/spec/support/user_integration_helpers.rb +++ b/spec/support/user_integration_helpers.rb @@ -10,7 +10,7 @@ module UserIntegrationHelpers def api_sign_in user = FactoryGirl.create :user - post api_sessions_path, format: :json, session: { + post_via_redirect api_sessions_path, format: :json, session: { email: user.email, password: user.password }