From 282eb2ddee97ef5a5425a470ba771788c5bbe198 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Wed, 29 Apr 2015 14:55:03 +0000 Subject: [PATCH] Update to rspec 3.2 --- Gemfile.lock | 40 ++++++++++--------- spec/factories.rb | 6 +-- spec/integration/api/api_sign_in_spec.rb | 6 +-- .../api/cross_origin_request_spec.rb | 10 ++--- spec/integration/api/playlists_spec.rb | 8 ++-- spec/integration/api/tracks_spec.rb | 6 +-- spec/support/user_integration_helpers.rb | 2 +- 7 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a3fefef..4b60d46 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,29 +155,31 @@ GEM ffi (>= 0.5.0) rb-kqueue (0.2.3) ffi (>= 0.5.0) - rspec (2.99.0) - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.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-collection_matchers (1.1.2) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (2.99.2) - rspec-expectations (2.99.2) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.3) - rspec-rails (2.99.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-collection_matchers - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.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) 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/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 }