Update to rspec 3.2

This commit is contained in:
Thibault Jouan 2015-04-29 14:55:03 +00:00
parent 96246f87bf
commit 282eb2ddee
7 changed files with 40 additions and 38 deletions

View File

@ -155,29 +155,31 @@ GEM
ffi (>= 0.5.0) ffi (>= 0.5.0)
rb-kqueue (0.2.3) rb-kqueue (0.2.3)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rspec (2.99.0) rspec (3.2.0)
rspec-core (~> 2.99.0) rspec-core (~> 3.2.0)
rspec-expectations (~> 2.99.0) rspec-expectations (~> 3.2.0)
rspec-mocks (~> 2.99.0) rspec-mocks (~> 3.2.0)
rspec-activemodel-mocks (1.0.1) rspec-activemodel-mocks (1.0.1)
activemodel (>= 3.0) activemodel (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
rspec-mocks (>= 2.99, < 4.0) rspec-mocks (>= 2.99, < 4.0)
rspec-collection_matchers (1.1.2) rspec-core (3.2.3)
rspec-expectations (>= 2.99.0.beta1) rspec-support (~> 3.2.0)
rspec-core (2.99.2) rspec-expectations (3.2.1)
rspec-expectations (2.99.2) diff-lcs (>= 1.2.0, < 2.0)
diff-lcs (>= 1.1.3, < 2.0) rspec-support (~> 3.2.0)
rspec-mocks (2.99.3) rspec-mocks (3.2.1)
rspec-rails (2.99.0) diff-lcs (>= 1.2.0, < 2.0)
actionpack (>= 3.0) rspec-support (~> 3.2.0)
activemodel (>= 3.0) rspec-rails (3.2.1)
activesupport (>= 3.0) actionpack (>= 3.0, < 4.3)
railties (>= 3.0) activesupport (>= 3.0, < 4.3)
rspec-collection_matchers railties (>= 3.0, < 4.3)
rspec-core (~> 2.99.0) rspec-core (~> 3.2.0)
rspec-expectations (~> 2.99.0) rspec-expectations (~> 3.2.0)
rspec-mocks (~> 2.99.0) rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
shellany (0.0.1) shellany (0.0.1)
shoulda-matchers (2.8.0) shoulda-matchers (2.8.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)

View File

@ -1,7 +1,7 @@
def build_sound_file def build_sound_file
file = File.new("#{Rails.root}/spec/fixtures/test.mp3") File.new("#{Rails.root}/spec/fixtures/test.mp3").tap do |o|
file.stub(content_type: 'audio/mpeg') o.define_singleton_method(:content_type) { 'audio/mpeg' }
file end
end end
FactoryGirl.define do FactoryGirl.define do

View File

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
feature 'API sign in' do describe 'API sign in' do
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryGirl.create(:user) }
def do_create def do_create
@ -10,7 +10,7 @@ feature 'API sign in' do
} }
end end
scenario 'signs the user in with valid credentials' do it 'signs the user in with valid credentials' do
do_create do_create
expect(response).to be_success expect(response).to be_success
@ -18,7 +18,7 @@ feature 'API sign in' do
end end
[:email, :password].each do |attr| [: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') allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
do_create do_create

View File

@ -1,19 +1,19 @@
require 'spec_helper' require 'spec_helper'
feature 'API cross origin request' do describe 'API cross origin request' do
include UserIntegrationHelpers include UserIntegrationHelpers
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryGirl.create(:user) }
let(:origin) { 'http://origin.example/' } let(:origin) { 'http://origin.example/' }
background do before do
post sessions_path, session: { post sessions_path, session: {
email: user.email, email: user.email,
password: user.password password: user.password
} }
end end
scenario 'preflight request' do it 'responds to preflight request' do
@integration_session.send( @integration_session.send(
:process, :process,
:options, :options,
@ -30,7 +30,7 @@ feature 'API cross origin request' do
.to eq 'Content-Type, Content-Length, X-Requested-With' .to eq 'Content-Type, Content-Length, X-Requested-With'
end end
scenario 'basic request' do it 'responds to basic request' do
# FIXME: replace with a more stable/generic action # FIXME: replace with a more stable/generic action
get api_playlists_path(format: :json), nil, 'Origin' => origin get api_playlists_path(format: :json), nil, 'Origin' => origin
@ -40,7 +40,7 @@ feature 'API cross origin request' do
.to eq 'Content-Length' .to eq 'Content-Length'
end end
scenario 'request without origin' do it 'responds to request without origin' do
# FIXME: replace with a more stable/generic action # FIXME: replace with a more stable/generic action
get api_playlists_path(format: :json) get api_playlists_path(format: :json)

View File

@ -1,14 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature 'API playlists' do describe 'API playlists' do
include UserIntegrationHelpers include UserIntegrationHelpers
background { api_sign_in } before { api_sign_in }
scenario 'creates playlist' do it 'creates playlist' do
playlist = FactoryGirl.attributes_for :playlist playlist = FactoryGirl.attributes_for :playlist
post api_playlists_path, post_via_redirect api_playlists_path,
format: :json, format: :json,
playlist: playlist playlist: playlist

View File

@ -1,11 +1,11 @@
require 'spec_helper' require 'spec_helper'
feature 'API tracks' do describe 'API tracks' do
include UserIntegrationHelpers 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_1 = FactoryGirl.create(:track_with_sound, name: 'Track 1')
track_2 = FactoryGirl.create(:track, name: 'Track 2') track_2 = FactoryGirl.create(:track, name: 'Track 2')

View File

@ -10,7 +10,7 @@ module UserIntegrationHelpers
def api_sign_in def api_sign_in
user = FactoryGirl.create :user user = FactoryGirl.create :user
post api_sessions_path, format: :json, session: { post_via_redirect api_sessions_path, format: :json, session: {
email: user.email, email: user.email,
password: user.password password: user.password
} }