Skip to content

Commit

Permalink
Merge branch 'chore/upgrade-rspec'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdehamer committed Feb 23, 2015
2 parents 52f4f66 + 516a794 commit 248c04a
Show file tree
Hide file tree
Showing 38 changed files with 254 additions and 279 deletions.
11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ gem 'zeroclipboard-rails'


group :test, :development do
gem 'rspec-rails', '2.14.2'
gem 'capybara', '2.3.0'
gem 'teaspoon', '0.8.0'
gem 'phantomjs', '1.9.7.1'
gem 'rspec-rails'
gem 'its'
gem 'capybara'
gem 'teaspoon'
gem 'phantomjs'
gem 'dotenv-rails', '0.11.1'
gem 'pry'
gem 'pry-byebug'
gem 'pry-stack_explorer'
end

group :test do
gem 'webmock', '1.18.0'
gem 'webmock'
gem 'sinatra', '1.4.5'
gem 'coveralls', '0.7.0'
end
59 changes: 34 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GEM
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
capybara (2.3.0)
capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
Expand Down Expand Up @@ -72,11 +72,13 @@ GEM
dotenv-rails (0.11.1)
dotenv (= 0.11.1)
erubis (2.7.0)
execjs (2.2.1)
execjs (2.2.2)
haml (4.0.5)
tilt
hike (1.2.3)
i18n (0.7.0)
its (0.2.0)
rspec-core
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
Expand All @@ -89,11 +91,12 @@ GEM
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.0)
mini_portile (0.6.1)
minitest (5.5.1)
multi_json (1.10.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
netrc (0.8.0)
nokogiri (1.6.5)
mini_portile (~> 0.6.0)
phantomjs (1.9.7.1)
pry (0.10.1)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -129,23 +132,28 @@ GEM
activesupport (= 4.1.7)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rake (10.4.0)
ref (1.0.5)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
rest-client (1.7.2)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec-core (3.1.7)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-rails (3.1.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
safe_yaml (1.0.3)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
safe_yaml (1.0.4)
sass (3.3.9)
simplecov (0.9.1)
docile (~> 1.1.0)
Expand Down Expand Up @@ -176,13 +184,13 @@ GEM
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tins (1.1.0)
tins (1.3.3)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
webmock (1.18.0)
webmock (1.20.4)
addressable (>= 2.3.6)
crack (>= 0.3.2)
xpath (2.0.0)
Expand All @@ -195,23 +203,24 @@ PLATFORMS

DEPENDENCIES
activeresource (= 4.0.0)
capybara (= 2.3.0)
capybara
coveralls (= 0.7.0)
ctl_base_ui
dotenv-rails (= 0.11.1)
haml (= 4.0.5)
its
kramdown (= 1.4.0)
phantomjs (= 1.9.7.1)
phantomjs
pry
pry-byebug
pry-stack_explorer
puma (= 2.8.2)
rails (= 4.1.7)
rspec-rails (= 2.14.2)
rspec-rails
sass (= 3.3.9)
sinatra (= 1.4.5)
teaspoon (= 0.8.0)
teaspoon
therubyracer (= 0.12.1)
uglifier (= 2.5.1)
webmock (= 1.18.0)
webmock
zeroclipboard-rails
6 changes: 3 additions & 3 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
context 'when request is XHR' do

before do
controller.request.stub(xhr?: true)
allow(controller.request).to receive(:xhr?).and_return(true)
end

it 'returns a 500 status code' do
Expand Down Expand Up @@ -57,7 +57,7 @@ def index
context 'when request is XHR' do

before do
controller.request.stub(xhr?: true)
allow(controller.request).to receive(:xhr?).and_return(true)
end

it 'returns panamax API connection message in the response body' do
Expand All @@ -83,7 +83,7 @@ def index
context 'when the request is XHR' do

before do
controller.request.stub(xhr?: true)
allow(controller.request).to receive(:xhr?).and_return(true)
end

context 'when a message is provided' do
Expand Down
43 changes: 22 additions & 21 deletions spec/controllers/apps_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
let(:fake_delete_response) { double(:fake_delete_response, body: 'test', status: 200) }

before do
controller.stub(:show_url)
App.stub(:find).and_return(dummy_app)
dummy_app.stub(:id).and_return(77)
dummy_app.stub(:categories).and_return([Category.new(id: 33, name: 'Test3', position: 3),
Category.new(id: 22, name: 'Test2', position: 2),
Category.new(id: 11, name: 'Test1', position: 1)
])
allow(controller).to receive(:show_url)
allow(App).to receive(:find).and_return(dummy_app)
allow(dummy_app).to receive(:id).and_return(77)
allow(dummy_app).to receive(:categories).and_return([
Category.new(id: 33, name: 'Test3', position: 3),
Category.new(id: 22, name: 'Test2', position: 2),
Category.new(id: 11, name: 'Test1', position: 1)
])
end

describe 'POST #create' do
before do
App.stub(:create).and_return(dummy_app)
allow(App).to receive(:create).and_return(dummy_app)
end

it 'creates an application' do
Expand All @@ -35,7 +36,7 @@

context 'when the created app is valid' do
before do
dummy_app.stub(:valid?).and_return(true)
allow(dummy_app).to receive(:valid?).and_return(true)
end

it 'redirects to the show page' do
Expand All @@ -52,7 +53,7 @@

context 'when app is not valid' do
before do
App.stub(:create).and_return(false)
allow(App).to receive(:create).and_return(false)
end

it 'renders the show template' do
Expand All @@ -71,8 +72,8 @@
end

before do
App.stub(:find).and_return(dummy_app)
dummy_app.stub(:save)
allow(App).to receive(:find).and_return(dummy_app)
allow(dummy_app).to receive(:save)
end

it 'retrieves the app to be updated' do
Expand All @@ -93,7 +94,7 @@

describe '#destroy' do
before do
dummy_app.stub(:destroy)
allow(dummy_app).to receive(:destroy)
end

it 'uses the applications service to destroy the application' do
Expand All @@ -115,7 +116,7 @@
describe 'GET #index' do
let(:apps) { [App.new] }
before do
App.stub(:all).and_return(apps)
allow(App).to receive(:all).and_return(apps)
end

it 'retrieves all the applications' do
Expand All @@ -142,7 +143,7 @@
end

it 'returns a 404 if the app is not found' do
App.stub(:find).and_raise(ActiveResource::ResourceNotFound.new(double('err', code: '404')))
allow(App).to receive(:find).and_raise(ActiveResource::ResourceNotFound.new(double('err', code: '404')))
get :show, id: 77
expect(response.status).to eq 404
end
Expand All @@ -151,7 +152,7 @@
describe 'GET #documentation' do

it 'renders the apps documentation with the documentation layout' do
dummy_app.stub(:documentation_to_html).and_return('<p>some instructions</a>')
allow(dummy_app).to receive(:documentation_to_html).and_return('<p>some instructions</a>')
get :documentation, id: 77
expect(response).to render_template('documentation', layout: 'plain')
end
Expand Down Expand Up @@ -179,7 +180,7 @@
end

before do
dummy_app.stub(:post).and_return(template_response)
allow(dummy_app).to receive(:post).and_return(template_response)
end

it 'retrieve the template' do
Expand All @@ -203,7 +204,7 @@
end

before do
dummy_app.stub(:get).and_return(journal_lines)
allow(dummy_app).to receive(:get).and_return(journal_lines)
end

it 'retrieve the journal' do
Expand Down Expand Up @@ -232,7 +233,7 @@

context 'when successful' do
before do
dummy_app.stub(:put).and_return(true)
allow(dummy_app).to receive(:put).and_return(true)
end

it 'redirects to the applications index view when format is html' do
Expand All @@ -253,7 +254,7 @@

context 'when unsuccessful' do
before do
dummy_app.stub(:put).and_return(false)
allow(dummy_app).to receive(:put).and_return(false)
end

it 'returns status 302 when format is html' do
Expand All @@ -275,7 +276,7 @@
context 'when an ActiveResource::ServerError occurs' do

before do
dummy_app.stub(:put).and_raise(
allow(dummy_app).to receive(:put).and_raise(
ActiveResource::ServerError.new(nil, 'oops'))
end

Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/categories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
end

before do
Category.stub(:find).and_return(dummy_category)
Category.stub(:create).and_return(dummy_category)
allow(Category).to receive(:find).and_return(dummy_category)
allow(Category).to receive(:create).and_return(dummy_category)
end

it 'creates the category' do
Expand All @@ -43,8 +43,8 @@
end

before do
Category.stub(:find).and_return(dummy_category)
dummy_category.stub(:save)
allow(Category).to receive(:find).and_return(dummy_category)
allow(dummy_category).to receive(:save)
end

it 'retrieves the category to be updated' do
Expand All @@ -65,8 +65,8 @@

describe 'DELETE #destroy' do
before do
Category.stub(:find).and_return(dummy_category)
dummy_category.stub(:destroy)
allow(Category).to receive(:find).and_return(dummy_category)
allow(dummy_category).to receive(:destroy)
end

it 'retrieves the category to be updated' do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
end

before do
I18n.stub(:t).and_return('test')
allow(I18n).to receive(:t).and_return('test')
end

describe 'GET #index' do
it 'assigns values to the resources instance variable' do
[App, TemplateRepo, LocalImage, Registry, DeploymentTarget].each do |resource|
resource.stub(:all).and_return(double(length: 1))
allow(resource).to receive(:all).and_return(double(length: 1))
end

get :index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
subject { response }
let(:format) { :html }
let(:post_create) { post :create, deployment_target_id: '19', format: format }
before { DeploymentTargetMetadataRefresh.stub(:create).and_call_original }
before { allow(DeploymentTargetMetadataRefresh).to receive(:create).and_call_original }

context 'when refresh is successful' do
before { post_create }
Expand Down Expand Up @@ -43,7 +43,7 @@

context 'when refresh fails' do
before do
DeploymentTargetMetadataRefresh.stub(:create).and_raise(error)
allow(DeploymentTargetMetadataRefresh).to receive(:create).and_raise(error)
post_create
end

Expand Down
Loading

0 comments on commit 248c04a

Please sign in to comment.