2014-08-30 17:38:47 +00:00
|
|
|
require 'rails_helper'
|
2011-11-23 21:30:09 +00:00
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
shared_examples_for 'guest user trying to modify' do
|
2014-10-12 18:36:31 +00:00
|
|
|
it { should redirect_to(new_login_path) }
|
|
|
|
specify { expect(flash[:notice]).to match(/log in to proceed/) }
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'non-owner user trying to modify' do
|
2014-07-05 12:59:42 +00:00
|
|
|
it { should redirect_to(root_path) }
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
specify { expect(flash[:alert]).to match(/can't/) }
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
2011-11-23 21:30:09 +00:00
|
|
|
describe AsciicastsController do
|
2013-11-18 13:29:18 +00:00
|
|
|
|
2014-02-12 19:51:01 +00:00
|
|
|
let(:user) { stub_model(User, username: 'nick') }
|
2012-04-09 21:44:10 +00:00
|
|
|
let(:asciicast) { stub_model(Asciicast, :id => 666) }
|
2011-11-23 21:30:09 +00:00
|
|
|
|
2012-04-09 21:44:10 +00:00
|
|
|
subject { response }
|
|
|
|
|
|
|
|
describe '#index' do
|
2012-12-09 20:25:45 +00:00
|
|
|
before do
|
2013-11-18 13:29:18 +00:00
|
|
|
get :index, category: 'featured', order: 'recency', page: '2'
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
2014-01-18 10:44:13 +00:00
|
|
|
it { should be_success }
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#show' do
|
2013-08-13 17:49:48 +00:00
|
|
|
let(:view_counter) { double('view_counter', :increment => nil) }
|
|
|
|
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2013-09-25 14:58:44 +00:00
|
|
|
allow(controller).to receive(:view_counter) { view_counter }
|
2015-04-26 13:30:42 +00:00
|
|
|
expect(Asciicast).to receive(:find_by_id_or_secret_token!).and_return(asciicast)
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
let(:asciicast_presenter) { double('asciicast_presenter') }
|
|
|
|
let(:user) { double('user') }
|
2013-06-13 20:26:27 +00:00
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
before do
|
|
|
|
allow(controller).to receive(:render)
|
|
|
|
allow(controller).to receive(:current_user) { user }
|
|
|
|
allow(AsciicastPagePresenter).to receive(:build).
|
2015-03-30 10:02:21 +00:00
|
|
|
with(controller, asciicast, user, hash_including('speed' => '3.0')).
|
2014-03-05 09:05:45 +00:00
|
|
|
and_return(asciicast_presenter)
|
2013-08-13 17:49:48 +00:00
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
get :show, id: asciicast.id, format: :html, speed: 3.0
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
it { should be_success }
|
2013-08-13 17:49:48 +00:00
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
it 'should be counted as a visit' do
|
|
|
|
expect(view_counter).to have_received(:increment).
|
|
|
|
with(asciicast, cookies)
|
2013-06-13 20:41:06 +00:00
|
|
|
end
|
|
|
|
|
2014-03-05 09:05:45 +00:00
|
|
|
it "renders template with AsciicastPagePresenter as page" do
|
|
|
|
expect(controller).to have_received(:render).
|
|
|
|
with(locals: { page: asciicast_presenter })
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#edit' do
|
2012-12-09 20:25:45 +00:00
|
|
|
let(:make_request) { get :edit, :id => asciicast.id }
|
|
|
|
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2015-04-26 13:30:42 +00:00
|
|
|
expect(Asciicast).to receive(:find_by_id_or_secret_token!).and_return(asciicast)
|
2012-04-09 21:44:10 +00:00
|
|
|
asciicast.user = user
|
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
context 'for owner user' do
|
|
|
|
before do
|
|
|
|
login_as user
|
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should be_success }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest user' do
|
|
|
|
before do
|
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'guest user trying to modify'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for other user' do
|
|
|
|
before do
|
|
|
|
login_as stub_model(User)
|
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'non-owner user trying to modify'
|
|
|
|
end
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#update' do
|
2014-02-12 19:22:20 +00:00
|
|
|
let(:make_request) {
|
|
|
|
put :update, id: asciicast.id, asciicast: { title: 'title'}
|
|
|
|
}
|
2012-12-09 20:25:45 +00:00
|
|
|
|
2014-11-27 12:30:08 +00:00
|
|
|
let(:asciicast_updater) { double(:asciicast_updater) }
|
|
|
|
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2014-11-27 12:30:08 +00:00
|
|
|
allow(controller).to receive(:asciicast_updater) { asciicast_updater }
|
2015-04-26 13:30:42 +00:00
|
|
|
expect(Asciicast).to receive(:find_by_id_or_secret_token!).and_return(asciicast)
|
2012-04-09 21:44:10 +00:00
|
|
|
asciicast.user = user
|
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
context 'for owner user' do
|
|
|
|
before do
|
|
|
|
login_as user
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when update succeeds' do
|
|
|
|
before do
|
2014-11-27 12:30:08 +00:00
|
|
|
expect(asciicast_updater).to receive(:update).and_return(true)
|
2012-12-09 20:25:45 +00:00
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should redirect_to(asciicast_path(asciicast)) }
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
specify { expect(flash[:notice]).to match(/was updated/) }
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when update fails' do
|
|
|
|
before do
|
2014-11-27 12:30:08 +00:00
|
|
|
expect(asciicast_updater).to receive(:update).and_return(false)
|
2012-12-09 20:25:45 +00:00
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should render_template(:edit) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest user' do
|
|
|
|
before do
|
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'guest user trying to modify'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for other user' do
|
|
|
|
before do
|
|
|
|
login_as stub_model(User)
|
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'non-owner user trying to modify'
|
|
|
|
end
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#destroy' do
|
2012-12-09 20:25:45 +00:00
|
|
|
let(:make_request) { delete :destroy, :id => asciicast.id }
|
|
|
|
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2015-04-26 13:30:42 +00:00
|
|
|
expect(Asciicast).to receive(:find_by_id_or_secret_token!).and_return(asciicast)
|
2012-04-09 21:44:10 +00:00
|
|
|
asciicast.user = user
|
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
context 'for owner user' do
|
|
|
|
before do
|
|
|
|
login_as user
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when destroy succeeds' do
|
|
|
|
before do
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
expect(asciicast).to receive(:destroy).and_return(true)
|
2012-12-09 20:25:45 +00:00
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
2014-10-12 18:36:31 +00:00
|
|
|
it { should redirect_to(public_profile_path(username: 'nick')) }
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
specify { expect(flash[:notice]).to match(/was deleted/) }
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when destroy fails' do
|
|
|
|
before do
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
expect(asciicast).to receive(:destroy).and_return(false)
|
2012-12-09 20:25:45 +00:00
|
|
|
make_request
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should redirect_to(asciicast_path(asciicast)) }
|
Use new rspec syntax in all specs
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index a115b7d..09d150b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -46,12 +46,12 @@ def retrieve
describe "action raise unauthorized" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :foo
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -59,11 +59,11 @@ def retrieve
context "when typical request" do
it "redirects to login_path" do
- @controller.should_receive(:store_location)
+ expect(@controller).to receive(:store_location)
get :foo
- flash[:notice].should == "Please sign in to proceed"
+ expect(flash[:notice]).to eq("Please sign in to proceed")
should redirect_to(login_path)
end
@@ -72,12 +72,12 @@ def retrieve
context "when action raise forbidden" do
context "when xhr" do
- before { request.stub(:xhr?).and_return(true) }
+ before { allow(request).to receive(:xhr?).and_return(true) }
it "response with 401" do
get :bar
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -86,7 +86,7 @@ def retrieve
it "redirects to root_path" do
get :bar
- flash[:alert].should == "This action is forbidden"
+ expect(flash[:alert]).to eq("This action is forbidden")
should redirect_to(root_path)
end
@@ -97,8 +97,8 @@ def retrieve
it 'stores current request path to be later retrieved' do
get :store
get :retrieve
- assigns[:location].should == '/fake/store'
- assigns[:location_again].should == 'NOWAI!'
+ expect(assigns[:location]).to eq('/fake/store')
+ expect(assigns[:location_again]).to eq('NOWAI!')
end
end
@@ -106,7 +106,7 @@ def retrieve
context 'when there is no stored location' do
it 'redirects to given location' do
path = double
- @controller.should_receive(:redirect_to).with(path)
+ expect(@controller).to receive(:redirect_to).with(path)
@controller.send(:redirect_back_or_to, path)
end
end
@@ -115,8 +115,8 @@ def retrieve
it 'redirects to stored location' do
stored_path = double
path = double
- @controller.stub(:get_stored_location => stored_path)
- @controller.should_receive(:redirect_to).with(stored_path)
+ allow(@controller).to receive(:get_stored_location).and_return(stored_path)
+ expect(@controller).to receive(:redirect_to).with(stored_path)
@controller.send(:redirect_back_or_to, path)
end
end
diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb
index 5741ec2..c37e69b 100644
--- a/spec/controllers/asciicasts_controller_spec.rb
+++ b/spec/controllers/asciicasts_controller_spec.rb
@@ -2,12 +2,12 @@
shared_examples_for 'guest user trying to modify' do
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
shared_examples_for 'non-owner user trying to modify' do
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /can't/ }
+ specify { expect(flash[:alert]).to match(/can't/) }
end
describe AsciicastsController do
@@ -45,7 +45,7 @@
before do
allow(controller).to receive(:view_counter) { view_counter }
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.title = 'some tit'
end
@@ -66,7 +66,7 @@
with(asciicast, cookies)
end
- specify { assigns(:asciicast).should == asciicast_decorator }
+ specify { expect(assigns(:asciicast)).to eq(asciicast_decorator) }
end
context 'for json request' do
@@ -98,7 +98,7 @@
let(:make_request) { get :edit, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -133,7 +133,7 @@
let(:make_request) { put :update, :id => asciicast.id, :asciicast => { } }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -144,17 +144,17 @@
context 'when update succeeds' do
before do
- asciicast.should_receive(:update_attributes).and_return(true)
+ expect(asciicast).to receive(:update_attributes).and_return(true)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:notice].should =~ /was updated/ }
+ specify { expect(flash[:notice]).to match(/was updated/) }
end
context 'when update fails' do
before do
- asciicast.should_receive(:update_attributes).and_return(false)
+ expect(asciicast).to receive(:update_attributes).and_return(false)
make_request
end
@@ -184,7 +184,7 @@
let(:make_request) { delete :destroy, :id => asciicast.id }
before do
- Asciicast.should_receive(:find).and_return(asciicast)
+ expect(Asciicast).to receive(:find).and_return(asciicast)
asciicast.user = user
end
@@ -195,22 +195,22 @@
context 'when destroy succeeds' do
before do
- asciicast.should_receive(:destroy).and_return(true)
+ expect(asciicast).to receive(:destroy).and_return(true)
make_request
end
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /was deleted/ }
+ specify { expect(flash[:notice]).to match(/was deleted/) }
end
context 'when destroy fails' do
before do
- asciicast.should_receive(:destroy).and_return(false)
+ expect(asciicast).to receive(:destroy).and_return(false)
make_request
end
it { should redirect_to(asciicast_path(asciicast)) }
- specify { flash[:alert].should =~ /again/ }
+ specify { expect(flash[:alert]).to match(/again/) }
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index 6dcd6e7..e82d5ea 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -10,7 +10,7 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
@@ -21,14 +21,14 @@
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
describe 'when there are no casts at all' do
it "returns http success" do
get 'show'
- response.should be_success
+ expect(response).to be_success
end
end
end
diff --git a/spec/controllers/user_tokens_controller_spec.rb b/spec/controllers/user_tokens_controller_spec.rb
index 2a43c4a..6774f87 100644
--- a/spec/controllers/user_tokens_controller_spec.rb
+++ b/spec/controllers/user_tokens_controller_spec.rb
@@ -24,14 +24,14 @@
let(:user) { nil }
it { should redirect_to(login_path) }
- specify { flash[:notice].should =~ /sign in to proceed/ }
+ specify { expect(flash[:notice]).to match(/sign in to proceed/) }
end
context "when # of claimed asciicasts is nil" do
let(:claimed_num) { nil }
it 'displays error page' do
- response.should render_template(:error)
+ expect(response).to render_template(:error)
end
end
@@ -39,14 +39,14 @@
let(:claimed_num) { 0 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Authenticated/ }
+ specify { expect(flash[:notice]).to match(/Authenticated/) }
end
context "when # of claimed asciicast is > 0" do
let(:claimed_num) { 1 }
it { should redirect_to(profile_path(user)) }
- specify { flash[:notice].should =~ /Claimed #{claimed_num}/ }
+ specify { expect(flash[:notice]).to match(/Claimed #{claimed_num}/) }
end
end
diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb
index 19e6af1..05264d7 100644
--- a/spec/decorators/asciicast_decorator_spec.rb
+++ b/spec/decorators/asciicast_decorator_spec.rb
@@ -230,7 +230,7 @@
}
before do
- asciicast.stub(:id => 123)
+ allow(asciicast).to receive(:id).and_return(123)
end
it 'should be an async script tag including asciicast id' do
diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb
index ce4f912..0bbfd6c 100644
--- a/spec/features/playback_spec.rb
+++ b/spec/features/playback_spec.rb
@@ -26,7 +26,7 @@ def inject_on_finished_callback
visit asciicast_path(asciicast, speed: 5)
find(".play-button").find(".arrow").click
inject_on_finished_callback
- page.should have_selector('body .finished')
+ expect(page).to have_selector('body .finished')
end
end
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index e6e128f..11f56e0 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,7 +3,7 @@
describe Comment do
it "factory should be valid" do
- FactoryGirl.build(:comment).should be_valid
+ expect(FactoryGirl.build(:comment)).to be_valid
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index a6c845e..88ee9a8 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -96,8 +96,8 @@
it 'returns created UserToken' do
ut = user.add_user_token(token)
- ut.should be_kind_of(UserToken)
- ut.id.should_not be(nil)
+ expect(ut).to be_kind_of(UserToken)
+ expect(ut.id).not_to be(nil)
end
end
@@ -107,7 +107,7 @@
it 'returns existing UserToken' do
ut = user.add_user_token(token)
- ut.should == existing_token
+ expect(ut).to eq(existing_token)
end
end
end
diff --git a/spec/models/user_token_spec.rb b/spec/models/user_token_spec.rb
index f1e76e6..a106311 100644
--- a/spec/models/user_token_spec.rb
+++ b/spec/models/user_token_spec.rb
@@ -2,6 +2,6 @@
describe UserToken do
it "has valid factory" do
- FactoryGirl.build(:user_token).should be_valid
+ expect(FactoryGirl.build(:user_token)).to be_valid
end
end
diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb
index 351f928..91f713f 100644
--- a/spec/routing/connect_spec.rb
+++ b/spec/routing/connect_spec.rb
@@ -2,7 +2,7 @@
describe 'connect routing' do
it 'routes /connect/:user_token to user_tokens#create for user_token' do
- { :get => '/connect/jolka-misio' }.should route_to(
+ expect({ :get => '/connect/jolka-misio' }).to route_to(
:controller => 'user_tokens',
:action => 'create',
:user_token => 'jolka-misio'
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index 6b26434..fa31720 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,7 +1,7 @@
module Asciinema
module ControllerMacros
def login_as(user)
- controller.stub(:current_user => user)
+ allow(controller).to receive(:current_user).and_return(user)
end
end
end
2013-12-09 16:16:38 +00:00
|
|
|
specify { expect(flash[:alert]).to match(/again/) }
|
2012-12-09 20:25:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest user' do
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2012-12-09 20:25:45 +00:00
|
|
|
make_request
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
it_should_behave_like 'guest user trying to modify'
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
context 'for other user' do
|
2012-04-09 21:44:10 +00:00
|
|
|
before do
|
2012-12-09 20:25:45 +00:00
|
|
|
login_as stub_model(User)
|
|
|
|
make_request
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
|
2012-12-09 20:25:45 +00:00
|
|
|
it_should_behave_like 'non-owner user trying to modify'
|
2012-04-09 21:44:10 +00:00
|
|
|
end
|
|
|
|
end
|
2013-11-18 12:01:35 +00:00
|
|
|
|
2011-11-23 21:30:09 +00:00
|
|
|
end
|