diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..83e16f8
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,2 @@
+--color
+--require spec_helper
diff --git a/.travis.yml b/.travis.yml
index c20722a..8bcfc97 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@ rvm:
- ruby-head
env:
- - COVERAGE=true
+ - RAILS_ENV=test COVERAGE=true
sudo: false
@@ -15,7 +15,8 @@ cache: bundler
services: mongodb
-script: bundle exec rake errbit:bootstrap spec
+before_script: bundle exec rake errbit:bootstrap
+script: bundle exec rspec
matrix:
allow_failures:
diff --git a/Gemfile b/Gemfile
index 62f7696..4ea6a99 100644
--- a/Gemfile
+++ b/Gemfile
@@ -56,8 +56,7 @@ gem 'yajl-ruby', :require => "yajl"
group :development, :test do
gem 'airbrake', :require => false
gem 'pry-rails'
-# gem 'rpm_contrib'
-# gem 'newrelic_rpm'
+ gem 'pry-byebug', platforms: [:mri]
gem 'quiet_assets'
end
@@ -75,7 +74,10 @@ group :development do
end
group :test do
- gem 'rspec-rails', require: false
+ gem 'rspec'
+ gem 'rspec-rails', '~> 3.0', require: false
+ gem 'rspec-activemodel-mocks'
+ gem 'rspec-its'
gem 'mongoid-rspec', require: false
gem 'fabrication'
gem 'capybara'
diff --git a/Gemfile.lock b/Gemfile.lock
index 8ea3100..44aeb2c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -45,7 +45,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
- addressable (2.3.5)
+ addressable (2.3.6)
airbrake (3.1.14)
builder
json
@@ -58,6 +58,9 @@ GEM
debug_inspector (>= 0.0.1)
bson (2.3.0)
builder (3.2.2)
+ byebug (2.7.0)
+ columnize (~> 0.3)
+ debugger-linecache (~> 1.2)
callsite (0.0.11)
campy (1.0.0)
capistrano (3.3.5)
@@ -75,7 +78,7 @@ GEM
capistrano (~> 3.1)
sshkit (~> 1.3)
capistrano-stats (1.1.1)
- capybara (2.1.0)
+ capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
@@ -91,6 +94,7 @@ GEM
execjs
coffee-script-source (1.8.0)
colorize (0.7.5)
+ columnize (0.9.0)
connection_pool (2.1.0)
coveralls (0.7.0)
multi_json (~> 1.3)
@@ -102,6 +106,7 @@ GEM
addressable
database_cleaner (1.2.0)
debug_inspector (0.0.2)
+ debugger-linecache (1.2.0)
decent_exposure (2.3.2)
devise (3.4.1)
bcrypt (~> 3.0)
@@ -110,14 +115,14 @@ GEM
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
- diff-lcs (1.2.4)
+ diff-lcs (1.2.5)
dotenv (0.9.0)
- draper (1.3.0)
+ draper (1.4.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
- request_store (~> 1.0.3)
- email_spec (1.5.0)
+ request_store (~> 1.0)
+ email_spec (1.6.0)
launchy (~> 2.1)
mail (~> 2.2)
erubis (2.7.0)
@@ -152,14 +157,14 @@ GEM
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
- json (1.8.1)
+ json (1.8.2)
jwt (0.1.8)
multi_json (>= 1.5)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.2)
- launchy (2.3.0)
+ launchy (2.4.3)
addressable (~> 2.3)
mail (2.6.3)
mime-types (>= 1.16, < 3)
@@ -169,23 +174,23 @@ GEM
railties
method_source (0.8.2)
mime-types (1.25.1)
- mini_portile (0.6.1)
- minitest (5.5.0)
+ mini_portile (0.6.2)
+ minitest (5.5.1)
mongoid (4.0.0)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
- mongoid-rspec (1.9.0)
- mongoid (>= 3.0.1)
+ mongoid-rspec (2.0.0)
+ mongoid (~> 4.0.0)
rake
- rspec (>= 2.14)
+ rspec (~> 3.1)
mongoid_rails_migrations (1.0.1)
activesupport (>= 3.2.0)
bundler (>= 1.0.0)
rails (>= 3.2.0)
railties (>= 3.2.0)
- moped (2.0.2)
+ moped (2.0.3)
bson (~> 2.2)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
@@ -195,7 +200,7 @@ GEM
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
- nokogiri (1.6.4.1)
+ nokogiri (1.6.5)
mini_portile (~> 0.6.0)
oauth2 (0.8.1)
faraday (~> 0.8)
@@ -232,6 +237,9 @@ GEM
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
+ pry-byebug (1.3.2)
+ byebug (~> 2.7)
+ pry (~> 0.9.12)
pry-rails (0.3.2)
pry (>= 0.9.10)
quiet_assets (1.0.2)
@@ -242,7 +250,7 @@ GEM
rack-ssl (1.4.0)
rack
rack-ssl-enforcer (0.2.6)
- rack-test (0.6.2)
+ rack-test (0.6.3)
rack (>= 1.0)
rails (4.1.8)
actionmailer (= 4.1.8)
@@ -265,28 +273,40 @@ GEM
rake (10.4.2)
rdoc (4.1.2)
json (~> 1.4)
- request_store (1.0.6)
+ request_store (1.1.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rest-client (1.6.8)
mime-types (~> 1.16)
rdoc (>= 2.4.2)
ri_cal (0.8.8)
- rspec (2.14.1)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
- rspec-core (2.14.6)
- rspec-expectations (2.14.3)
- diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.14.4)
- rspec-rails (2.14.0)
+ rspec (3.1.0)
+ rspec-core (~> 3.1.0)
+ rspec-expectations (~> 3.1.0)
+ rspec-mocks (~> 3.1.0)
+ rspec-activemodel-mocks (1.0.1)
+ activemodel (>= 3.0)
+ activesupport (>= 3.0)
+ rspec-mocks (>= 2.99, < 4.0)
+ 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-its (1.1.0)
+ rspec-core (>= 3.0.0)
+ rspec-expectations (>= 3.0.0)
+ rspec-mocks (3.1.3)
+ rspec-support (~> 3.1.0)
+ rspec-rails (3.1.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
+ 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)
rushover (0.3.0)
json
rest-client
@@ -340,7 +360,9 @@ GEM
useragent (0.9.0)
warden (1.2.3)
rack (>= 1.0)
- websocket-driver (0.3.3)
+ websocket-driver (0.5.1)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.1)
xmpp4r (0.5.5)
xpath (2.0.0)
nokogiri (~> 1.3)
@@ -391,6 +413,7 @@ DEPENDENCIES
omniauth-github
pjax_rails
poltergeist
+ pry-byebug
pry-rails
quiet_assets
rack-ssl
@@ -398,7 +421,10 @@ DEPENDENCIES
rails_autolink
railties (~> 4.1.8)
ri_cal
- rspec-rails
+ rspec
+ rspec-activemodel-mocks
+ rspec-its
+ rspec-rails (~> 3.0)
rushover
sass-rails
test-unit
diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb
index 1d8c1c5..30321d2 100644
--- a/spec/acceptance/acceptance_helper.rb
+++ b/spec/acceptance/acceptance_helper.rb
@@ -1,4 +1,3 @@
-require 'spec_helper'
require 'capybara/rspec'
require 'capybara/poltergeist'
diff --git a/spec/acceptance/sign_in_with_github_spec.rb b/spec/acceptance/sign_in_with_github_spec.rb
index e4002f6..6e77700 100644
--- a/spec/acceptance/sign_in_with_github_spec.rb
+++ b/spec/acceptance/sign_in_with_github_spec.rb
@@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper'
feature 'Sign in with GitHub' do
background do
- Errbit::Config.stub(:github_authentication) { true }
+ allow(Errbit::Config).to receive(:github_authentication).and_return(true)
Fabricate(:user, :github_login => 'nashby')
end
diff --git a/spec/controllers/api/v1/notices_controller_spec.rb b/spec/controllers/api/v1/notices_controller_spec.rb
index 759bd92..9d0c3a4 100644
--- a/spec/controllers/api/v1/notices_controller_spec.rb
+++ b/spec/controllers/api/v1/notices_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Api::V1::NoticesController do
-
+describe Api::V1::NoticesController, type: 'controller' do
context "when logged in" do
before do
@user = Fabricate(:user)
@@ -50,5 +47,4 @@ describe Api::V1::NoticesController do
end
end
-
end
diff --git a/spec/controllers/api/v1/problems_controller_spec.rb b/spec/controllers/api/v1/problems_controller_spec.rb
index 03a5b0e..2cb1ade 100644
--- a/spec/controllers/api/v1/problems_controller_spec.rb
+++ b/spec/controllers/api/v1/problems_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Api::V1::ProblemsController do
-
+describe Api::V1::ProblemsController, type: 'controller' do
context "when logged in" do
before do
@user = Fabricate(:user)
@@ -69,8 +66,6 @@ describe Api::V1::ProblemsController do
Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30))
end
-
-
it "should return JSON if JSON is requested" do
get :index, :auth_token => @user.authentication_token, :format => "json"
expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError)
@@ -86,17 +81,13 @@ describe Api::V1::ProblemsController do
expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError)
end
-
-
describe "given a date range" do
-
it "should return only the problems open during the date range" do
get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"}
expect(response).to be_success
problems = JSON.load response.body
expect(problems.length).to eq 2
end
-
end
it "should return all problems" do
@@ -105,8 +96,6 @@ describe Api::V1::ProblemsController do
problems = JSON.load response.body
expect(problems.length).to eq 4
end
-
end
end
-
end
diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb
index 77d53ba..f839181 100644
--- a/spec/controllers/apps_controller_spec.rb
+++ b/spec/controllers/apps_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe AppsController do
-
+describe AppsController, type: 'controller' do
it_requires_authentication
it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete}
@@ -218,7 +215,7 @@ describe AppsController do
describe "POST /apps" do
before do
@app = Fabricate(:app)
- App.stub(:new).and_return(@app)
+ allow(App).to receive(:new).and_return(@app)
end
context "when the create is successful" do
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index 02c7b92..3ee17e8 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe CommentsController do
+describe CommentsController, type: 'controller' do
let(:app) { Fabricate(:app) }
let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) }
diff --git a/spec/controllers/deploys_controller_spec.rb b/spec/controllers/deploys_controller_spec.rb
index e56129c..7937fa6 100644
--- a/spec/controllers/deploys_controller_spec.rb
+++ b/spec/controllers/deploys_controller_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe DeploysController do
+describe DeploysController, type: 'controller' do
render_views
context 'POST #create' do
@@ -21,7 +19,7 @@ describe DeploysController do
end
it 'creates a deploy' do
- App.stub(:find_by_api_key!).and_return(@app)
+ expect(App).to receive(:find_by_api_key!).and_return(@app)
expect(@app.deploys).to receive(:create!).
with({
:username => 'john.doe',
@@ -40,7 +38,6 @@ describe DeploysController do
expect(email.to).to include(@app.watchers.first.email)
expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe"
end
-
end
context "GET #index" do
@@ -59,6 +56,4 @@ describe DeploysController do
expect(response.body).to match(@deploy.app.name)
end
end
-
end
-
diff --git a/spec/controllers/devise_sessions_controller_spec.rb b/spec/controllers/devise_sessions_controller_spec.rb
index 64dc2fe..7ff91e7 100644
--- a/spec/controllers/devise_sessions_controller_spec.rb
+++ b/spec/controllers/devise_sessions_controller_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Devise::SessionsController do
+describe Devise::SessionsController, type: 'controller' do
render_views
describe "POST /users/sign_in" do
@@ -23,4 +21,3 @@ describe Devise::SessionsController do
end
end
end
-
diff --git a/spec/controllers/notices_controller_spec.rb b/spec/controllers/notices_controller_spec.rb
index 8effa42..7646555 100644
--- a/spec/controllers/notices_controller_spec.rb
+++ b/spec/controllers/notices_controller_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe NoticesController do
+describe NoticesController, type: 'controller' do
it_requires_authentication :for => { :locate => :get }
let(:notice) { Fabricate(:notice) }
@@ -78,6 +76,4 @@ describe NoticesController do
end
end
end
-
end
-
diff --git a/spec/controllers/problems_controller_spec.rb b/spec/controllers/problems_controller_spec.rb
index f125415..24f86d0 100644
--- a/spec/controllers/problems_controller_spec.rb
+++ b/spec/controllers/problems_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe ProblemsController do
-
+describe ProblemsController, type: 'controller' do
it_requires_authentication :for => {
:index => :get, :show => :get, :resolve => :put, :search => :get
},
@@ -218,38 +215,35 @@ describe ProblemsController do
before do
sign_in admin
- @problem = Fabricate(:err)
- App.stub(:find).with(@problem.app.id.to_s).and_return(@problem.app)
- @problem.app.problems.stub(:find).and_return(@problem.problem)
- @problem.problem.stub(:resolve!)
+ @err = Fabricate(:err)
end
- it 'finds the app and the problem' do
- expect(App).to receive(:find).with(@problem.app.id.to_s).and_return(@problem.app)
- expect(@problem.app.problems).to receive(:find).and_return(@problem.problem)
- put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
- expect(controller.app).to eq @problem.app
- expect(controller.problem).to eq @problem.problem
+ it 'finds the app and the err' do
+ expect(App).to receive(:find).with(@err.app.id.to_s).and_return(@err.app)
+ expect(@err.app.problems).to receive(:find).and_return(@err.problem)
+ put :resolve, :app_id => @err.app.id, :id => @err.problem.id
+ expect(controller.app).to eq @err.app
+ expect(controller.problem).to eq @err.problem
end
it "should resolve the issue" do
- expect(@problem.problem).to receive(:resolve!).and_return(true)
- put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
+ put :resolve, :app_id => @err.app.id, :id => @err.problem.id
+ expect(@err.problem.reload.resolved).to be(true)
end
it "should display a message" do
- put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
+ put :resolve, :app_id => @err.app.id, :id => @err.problem.id
expect(request.flash[:success]).to match(/Great news/)
end
it "should redirect to the app page" do
- put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
- expect(response).to redirect_to(app_path(@problem.app))
+ put :resolve, :app_id => @err.app.id, :id => @err.problem.id
+ expect(response).to redirect_to(app_path(@err.app))
end
it "should redirect back to problems page" do
request.env["HTTP_REFERER"] = problems_path
- put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id
+ put :resolve, :app_id => @err.app.id, :id => @err.problem.id
expect(response).to redirect_to(problems_path)
end
end
@@ -268,8 +262,8 @@ describe ProblemsController do
before do
problem.app.issue_tracker = issue_tracker
- controller.stub(:problem).and_return(problem)
- controller.stub(:current_user).and_return(admin)
+ allow(controller).to receive(:problem).and_return(problem)
+ allow(controller).to receive(:current_user).and_return(admin)
end
it "should redirect to problem page" do
@@ -461,7 +455,5 @@ describe ProblemsController do
expect(response).to redirect_to(edit_app_path(@app))
end
end
-
end
-
end
diff --git a/spec/controllers/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/users/omniauth_callbacks_controller_spec.rb
index 9337177..84ec87b 100644
--- a/spec/controllers/users/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/users/omniauth_callbacks_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Users::OmniauthCallbacksController do
-
+describe Users::OmniauthCallbacksController, type: 'controller' do
def stub_env_for_github_omniauth(login, token = nil)
# This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608
request.env["devise.mapping"] = Devise.mappings[:user]
@@ -12,7 +9,7 @@ describe Users::OmniauthCallbacksController do
:credentials => { :token => token }
)
}
- @controller.stub(:env).and_return(env)
+ allow(@controller).to receive(:env).and_return(env)
end
context 'Linking a GitHub account to a signed in user' do
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 1d91c4a..f9aa899 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe UsersController do
-
+describe UsersController, type: 'controller' do
it_requires_authentication
it_requires_admin_privileges :for => {
:index => :get,
@@ -16,7 +13,6 @@ describe UsersController do
let(:other_user) { Fabricate(:user) }
context 'Signed in as a regular user' do
-
before do
sign_in user
end
@@ -104,16 +100,12 @@ describe UsersController do
end
context "GET /users" do
-
it 'paginates all users' do
admin.update_attribute :per_page, 2
- users = 3.times {
- Fabricate(:user)
- }
+ 3.times { Fabricate(:user) }
get :index
expect(controller.users.to_a.size).to eq 2
end
-
end
context "GET /users/:id" do
@@ -140,7 +132,7 @@ describe UsersController do
context "POST /users" do
context "when the create is successful" do
- let(:attrs) { {:user => Fabricate.attributes_for(:user)} }
+ let(:attrs) { {:user => Fabricate.to_params(:user)} }
it "sets a message to display" do
post :create, attrs
@@ -156,7 +148,7 @@ describe UsersController do
attrs[:user][:admin] = true
post :create, attrs
expect(response).to be_redirect
- expect(User.find(controller.user.to_param).admin).to be_true
+ expect(User.find(controller.user.to_param).admin).to be(true)
end
it "should has auth token" do
@@ -205,7 +197,6 @@ describe UsersController do
end
context "DELETE /users/:id" do
-
context "with a destroy success" do
let(:user_destroy) { double(:destroy => true) }
@@ -236,8 +227,10 @@ describe UsersController do
describe "#user_params" do
context "with current user not admin" do
before {
- controller.stub(:current_user).and_return(user)
- controller.stub(:params).and_return(ActionController::Parameters.new(user_param))
+ allow(controller).to receive(:current_user).and_return(user)
+ allow(controller).to receive(:params).and_return(
+ ActionController::Parameters.new(user_param)
+ )
}
let(:user_param) { {'user' => { :name => 'foo', :admin => true }} }
it 'not have admin field' do
@@ -261,7 +254,5 @@ describe UsersController do
end
end
end
-
end
-
end
diff --git a/spec/controllers/watchers_controller_spec.rb b/spec/controllers/watchers_controller_spec.rb
index b77b4ab..f0545fb 100644
--- a/spec/controllers/watchers_controller_spec.rb
+++ b/spec/controllers/watchers_controller_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe WatchersController do
+describe WatchersController, type: 'controller' do
let(:app) do
a = Fabricate(:app)
Fabricate(:user_watcher, :app => a)
@@ -8,7 +6,6 @@ describe WatchersController do
end
describe "DELETE /apps/:app_id/watchers/:id/destroy" do
-
context "with admin user" do
before(:each) do
sign_in Fabricate(:admin)
diff --git a/spec/decorators/app_decorator_spec.rb b/spec/decorators/app_decorator_spec.rb
index 6418f9f..f317983 100644
--- a/spec/decorators/app_decorator_spec.rb
+++ b/spec/decorators/app_decorator_spec.rb
@@ -1,17 +1,11 @@
-require 'spec_helper'
-
describe AppDecorator do
-
describe "#email_at_notices" do
-
it 'return the list separate by comma' do
expect(AppDecorator.new(double(:email_at_notices => [2,3])).email_at_notices).to eql '2, 3'
end
-
end
describe "#notify_user_display" do
-
it 'return display:none if notify' do
expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;'
end
@@ -19,11 +13,9 @@ describe AppDecorator do
it 'return blank if no notify' do
expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql ''
end
-
end
describe "#notify_err_display" do
-
it 'return display:none if no notify' do
expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;'
end
@@ -31,7 +23,5 @@ describe AppDecorator do
it 'return blank if no notify' do
expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql ''
end
-
end
-
end
diff --git a/spec/decorators/issue_tracker_decorator_spec.rb b/spec/decorators/issue_tracker_decorator_spec.rb
index 72a58b8..315c3bc 100644
--- a/spec/decorators/issue_tracker_decorator_spec.rb
+++ b/spec/decorators/issue_tracker_decorator_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe IssueTrackerDecorator do
let(:fake_tracker) do
Class.new(ErrbitPlugin::IssueTracker) do
diff --git a/spec/decorators/issue_tracker_field_decorator.rb b/spec/decorators/issue_tracker_field_decorator.rb
index 8307fc2..e9476ad 100644
--- a/spec/decorators/issue_tracker_field_decorator.rb
+++ b/spec/decorators/issue_tracker_field_decorator.rb
@@ -1,14 +1,11 @@
-require 'spec_helper'
-
describe IssueTrackerFieldDecorator do
-
describe "#label" do
it 'return the label of field_info by default' do
expect(IssueTrackerFieldDecorator.new(:foo, {:label => 'hello'}).label).to eq 'hello'
end
+
it 'return the key of field if no label define' do
expect(IssueTrackerFieldDecorator.new(:foo, {}).label).to eq 'foo'
end
end
-
end
diff --git a/spec/decorators/watcher_decorator_spec.rb b/spec/decorators/watcher_decorator_spec.rb
index 6abaa6a..1983363 100644
--- a/spec/decorators/watcher_decorator_spec.rb
+++ b/spec/decorators/watcher_decorator_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe WatcherDecorator do
describe "#email_choosen" do
context "with email define" do
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 25c1666..ca5d063 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the AbcHelper. For example:
diff --git a/spec/helpers/backtrace_line_helper.rb b/spec/helpers/backtrace_line_helper.rb
index f09de7c..45ab917 100644
--- a/spec/helpers/backtrace_line_helper.rb
+++ b/spec/helpers/backtrace_line_helper.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe BacktraceLineHelper do
describe "in app lines" do
let(:notice) do
diff --git a/spec/helpers/navigation_helper_spec.rb b/spec/helpers/navigation_helper_spec.rb
index ff35528..716ec16 100644
--- a/spec/helpers/navigation_helper_spec.rb
+++ b/spec/helpers/navigation_helper_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe NavigationHelper do
describe '#page_count_from_end' do
it 'returns the page number when counting from the last occurrence of a notice' do
diff --git a/spec/helpers/problems_helper_spec.rb b/spec/helpers/problems_helper_spec.rb
index cb46e03..bbb86b6 100644
--- a/spec/helpers/problems_helper_spec.rb
+++ b/spec/helpers/problems_helper_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe ProblemsHelper do
describe '#truncated_problem_message' do
it 'is html safe' do
@@ -24,8 +22,8 @@ describe ProblemsHelper do
context "default config" do
before do
- Errbit::Config.stub(:use_gravatar).and_return(true)
- Errbit::Config.stub(:gravatar_default).and_return('identicon')
+ allow(Errbit::Config).to receive(:use_gravatar).and_return(true)
+ allow(Errbit::Config).to receive(:gravatar_default).and_return('identicon')
end
it "should render image_tag with correct alt and src" do
@@ -69,7 +67,7 @@ describe ProblemsHelper do
let(:email_hash) { Digest::MD5.hexdigest email }
it "should return the http url" do
- ActionController::TestRequest.any_instance.stub :ssl? => true
+ allow(controller.request).to receive(:ssl?).and_return(true)
expect(helper.gravatar_url(email)).to eq("https://secure.gravatar.com/avatar/#{email_hash}?d=identicon")
end
end
diff --git a/spec/interactors/problem_destroy_spec.rb b/spec/interactors/problem_destroy_spec.rb
index 6d128af..2f7bfb3 100644
--- a/spec/interactors/problem_destroy_spec.rb
+++ b/spec/interactors/problem_destroy_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe ProblemDestroy do
let(:problem_destroy) {
ProblemDestroy.new(problem)
@@ -8,9 +6,9 @@ describe ProblemDestroy do
context "in unit way" do
let(:problem) {
problem = Problem.new
- problem.stub(:errs).and_return(double(:criteria, :only => [err_1, err_2]))
- problem.stub(:comments).and_return(double(:criteria, :only => [comment_1, comment_2]))
- problem.stub(:delete)
+ allow(problem).to receive(:errs).and_return(double(:criteria, :only => [err_1, err_2]))
+ allow(problem).to receive(:comments).and_return(double(:criteria, :only => [comment_1, comment_2]))
+ allow(problem).to receive(:delete)
problem
}
let(:err_1) { Err.new }
@@ -73,5 +71,4 @@ describe ProblemDestroy do
expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty
end
end
-
end
diff --git a/spec/interactors/problem_merge_spec.rb b/spec/interactors/problem_merge_spec.rb
index 6da3964..9dcf653 100644
--- a/spec/interactors/problem_merge_spec.rb
+++ b/spec/interactors/problem_merge_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe ProblemMerge do
let(:problem) { Fabricate(:problem_with_errs) }
let(:problem_1) { Fabricate(:problem_with_errs) }
diff --git a/spec/interactors/problem_updater_cache_spec.rb b/spec/interactors/problem_updater_cache_spec.rb
index 679a95b..5b56166 100644
--- a/spec/interactors/problem_updater_cache_spec.rb
+++ b/spec/interactors/problem_updater_cache_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe ProblemUpdaterCache do
let(:problem) { Fabricate(:problem_with_errs) }
let(:first_errs) { problem.errs }
diff --git a/spec/interactors/resolved_problem_clearer_spec.rb b/spec/interactors/resolved_problem_clearer_spec.rb
index 983812f..5738b12 100644
--- a/spec/interactors/resolved_problem_clearer_spec.rb
+++ b/spec/interactors/resolved_problem_clearer_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe ResolvedProblemClearer do
let(:resolved_problem_clearer) {
ResolvedProblemClearer.new
@@ -21,7 +19,7 @@ describe ResolvedProblemClearer do
}
end
it 'not repair database' do
- Mongoid.default_session.stub(:command).and_call_original
+ allow(Mongoid.default_session).to receive(:command).and_call_original
expect(Mongoid.default_session).to_not receive(:command).with({:repairDatabase => 1})
resolved_problem_clearer.execute
end
@@ -29,8 +27,8 @@ describe ResolvedProblemClearer do
context "with problem resolve" do
before do
- Mongoid.default_session.stub(:command).and_call_original
- Mongoid.default_session.stub(:command).with({:repairDatabase => 1})
+ allow(Mongoid.default_session).to receive(:command).and_call_original
+ allow(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1})
problems.first.resolve!
problems.second.resolve!
end
@@ -46,7 +44,6 @@ describe ResolvedProblemClearer do
end
it 'repair database' do
- Mongoid.default_session.stub(:command).and_call_original
expect(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1})
resolved_problem_clearer.execute
end
diff --git a/spec/interactors/user_destroy_spec.rb b/spec/interactors/user_destroy_spec.rb
index 3b10c8c..b3f9025 100644
--- a/spec/interactors/user_destroy_spec.rb
+++ b/spec/interactors/user_destroy_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
describe UserDestroy do
let(:app) { Fabricate(
:app,
diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb
index cf8fe18..c0d2798 100644
--- a/spec/mailers/mailer_spec.rb
+++ b/spec/mailers/mailer_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
shared_examples "a notification email" do
it "should have X-Mailer header" do
expect(@email).to have_header('X-Mailer', 'Errbit')
@@ -36,6 +34,7 @@ describe Mailer do
let!(:user) { Fabricate(:admin) }
before do
+ ActionMailer::Base.deliveries = []
notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js")
notice.app.update_attributes(
:asset_host => "http://example.com",
@@ -78,12 +77,12 @@ describe Mailer do
include EmailSpec::Matchers
let!(:notice) { Fabricate(:notice) }
- let!(:comment) { Fabricate.build(:comment, :err => notice.problem) }
+ let!(:comment) { Fabricate(:comment, :err => notice.problem) }
let!(:watcher) { Fabricate(:watcher, :app => comment.app) }
let(:recipients) { ['recipient@example.com', 'another@example.com']}
before do
- comment.stub(:notification_recipients).and_return(recipients)
+ expect(comment).to receive(:notification_recipients).and_return(recipients)
Fabricate(:notice, :err => notice.err)
@email = Mailer.comment_notification(comment).deliver
end
diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb
index 983dd32..7420f42 100644
--- a/spec/models/app_spec.rb
+++ b/spec/models/app_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe App do
-
+describe App, type: 'model' do
context "Attributes" do
it { should have_field(:_id).of_type(String) }
it { should have_field(:name).of_type(String) }
@@ -112,12 +109,12 @@ describe App do
context '#github_repo?' do
it 'is true when there is a github_repo' do
app = Fabricate(:app, :github_repo => "errbit/errbit")
- expect(app.github_repo?).to be_true
+ expect(app.github_repo?).to be(true)
end
it 'is false when no github_repo' do
app = Fabricate(:app)
- expect(app.github_repo?).to be_false
+ expect(app.github_repo?).to be(false)
end
end
@@ -137,19 +134,19 @@ describe App do
it "should be true if notify on errs and there are notification recipients" do
app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false)
2.times { Fabricate(:watcher, :app => app) }
- expect(app.emailable?).to be_true
+ expect(app.emailable?).to be(true)
end
it "should be false if notify on errs is disabled" do
app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false)
2.times { Fabricate(:watcher, :app => app) }
- expect(app.emailable?).to be_false
+ expect(app.emailable?).to be(false)
end
it "should be false if there are no notification recipients" do
app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false)
expect(app.watchers).to be_empty
- expect(app.emailable?).to be_false
+ expect(app.emailable?).to be(false)
end
end
diff --git a/spec/models/backtrace_line_normalizer_spec.rb b/spec/models/backtrace_line_normalizer_spec.rb
index 0a1ab86..b3cd6ad 100644
--- a/spec/models/backtrace_line_normalizer_spec.rb
+++ b/spec/models/backtrace_line_normalizer_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe BacktraceLineNormalizer do
+describe BacktraceLineNormalizer, type: 'model' do
subject { described_class.new(raw_line).call }
describe "sanitize" do
diff --git a/spec/models/backtrace_line_spec.rb b/spec/models/backtrace_line_spec.rb
index 736a9ab..197b5cf 100644
--- a/spec/models/backtrace_line_spec.rb
+++ b/spec/models/backtrace_line_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe BacktraceLine do
+describe BacktraceLine, type: 'model' do
subject { described_class.new(raw_line) }
describe "root at the start of decorated filename" do
diff --git a/spec/models/backtrace_spec.rb b/spec/models/backtrace_spec.rb
index cdad627..1d93853 100644
--- a/spec/models/backtrace_spec.rb
+++ b/spec/models/backtrace_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Backtrace do
+describe Backtrace, type: 'model' do
subject { described_class.new }
its(:fingerprint) { should be_present }
@@ -19,7 +17,7 @@ describe Backtrace do
}
let(:fingerprint) { "fingerprint" }
- before { subject.stub(:fingerprint => fingerprint) }
+ before { allow(subject).to receive(:fingerprint).and_return(fingerprint) }
its(:similar) { should == similar_backtrace }
end
@@ -30,10 +28,10 @@ describe Backtrace do
let(:attributes) { double :attributes }
let(:backtrace) { double :backtrace }
- before { described_class.stub(:new => backtrace) }
+ before { allow(described_class).to receive(:new).and_return(backtrace) }
context "no similar backtrace" do
- before { backtrace.stub(:similar => nil) }
+ before { allow(backtrace).to receive(:similar).and_return(nil) }
it "create new backtrace" do
expect(described_class).to receive(:create).with(attributes)
@@ -43,7 +41,7 @@ describe Backtrace do
context "similar backtrace exist" do
let(:similar_backtrace) { double :similar_backtrace }
- before { backtrace.stub(:similar => similar_backtrace) }
+ before { allow(backtrace).to receive(:similar).and_return(similar_backtrace) }
it { should == similar_backtrace }
end
diff --git a/spec/models/comment_observer_spec.rb b/spec/models/comment_observer_spec.rb
index 4082822..bbf6621 100644
--- a/spec/models/comment_observer_spec.rb
+++ b/spec/models/comment_observer_spec.rb
@@ -1,11 +1,9 @@
-require 'spec_helper'
-
-describe "Callback on Comment" do
+describe "Callback on Comment", type: 'model' do
context 'when a Comment is saved' do
let(:comment) { Fabricate.build(:comment) }
context 'and it is emailable?' do
- before { comment.stub(:emailable?).and_return(true) }
+ before { allow(comment).to receive(:emailable?).and_return(true) }
it 'should send an email notification' do
expect(Mailer).to receive(:comment_notification).
@@ -16,7 +14,7 @@ describe "Callback on Comment" do
end
context 'and it is not emailable?' do
- before { comment.stub(:emailable?).and_return(false) }
+ before { allow(comment).to receive(:emailable?).and_return(false) }
it 'should not send an email notification' do
expect(Mailer).to_not receive(:comment_notification)
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index 9cfffe1..8ad3fb4 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Comment do
+describe Comment, type: 'model' do
context 'validations' do
it 'should require a body' do
comment = Fabricate.build(:comment, :body => nil)
@@ -37,19 +35,19 @@ describe Comment do
end
it 'should be true if app is emailable? and there are notification recipients' do
- expect(comment.emailable?).to be_true
+ expect(comment.emailable?).to be(true)
end
it 'should be false if app is not emailable?' do
app.update_attribute(:notify_on_errs, false)
expect(comment.notification_recipients).to be_any
- expect(comment.emailable?).to be_false
+ expect(comment.emailable?).to be(false)
end
it 'should be false if there are no notification recipients' do
watcher.destroy
- expect(app.emailable?).to be_true
- expect(comment.emailable?).to be_false
+ expect(app.emailable?).to be(true)
+ expect(comment.emailable?).to be(false)
end
end
end
diff --git a/spec/models/deploy_observer_spec.rb b/spec/models/deploy_observer_spec.rb
index 7972275..e7b6a54 100644
--- a/spec/models/deploy_observer_spec.rb
+++ b/spec/models/deploy_observer_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe "Callback on Deploy" do
+describe "Callback on Deploy", type: 'model' do
context 'when a Deploy is saved' do
context 'and the app should notify on deploys' do
it 'should send an email notification' do
diff --git a/spec/models/deploy_spec.rb b/spec/models/deploy_spec.rb
index 856fd70..b6f329f 100644
--- a/spec/models/deploy_spec.rb
+++ b/spec/models/deploy_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Deploy do
-
+describe Deploy, type: 'model' do
context 'validations' do
it 'requires a username' do
deploy = Fabricate.build(:deploy, :username => nil)
@@ -36,7 +33,6 @@ describe Deploy do
expect(@staging_errs.all?{|problem| problem.reload.resolved?}).to eq false
end
end
-
end
it "should produce a shortened revision with 7 characters" do
diff --git a/spec/models/err_spec.rb b/spec/models/err_spec.rb
index 383ad16..07a7351 100644
--- a/spec/models/err_spec.rb
+++ b/spec/models/err_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Err do
-
+describe Err, type: 'model' do
context 'validations' do
it 'requires a fingerprint' do
err = Fabricate.build(:err, :fingerprint => nil)
@@ -15,5 +12,4 @@ describe Err do
expect(err.errors[:problem_id]).to include("can't be blank")
end
end
-
end
diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb
index f8237bd..de4d243 100644
--- a/spec/models/error_report_spec.rb
+++ b/spec/models/error_report_spec.rb
@@ -1,4 +1,3 @@
-require 'spec_helper'
require 'airbrake/version'
require 'airbrake/backtrace'
require 'airbrake/notice'
@@ -41,22 +40,22 @@ describe ErrorReport do
end
describe "#backtrace" do
-
it 'should have valid backtrace' do
expect(error_report.backtrace).to be_valid
end
end
describe "#fingerprint_strategy" do
- after(:all) {
- error_report.fingerprint_strategy = Fingerprint::Sha1
- }
-
it "should be possible to change how fingerprints are generated" do
- strategy = double()
- strategy.should_receive(:generate){ 'fingerprints' }
- error_report.fingerprint_strategy = strategy
- error_report.generate_notice!
+ def error_report.fingerprint_strategy
+ Class.new do
+ def self.generate(*args)
+ 'fingerprintzzz'
+ end
+ end
+ end
+
+ expect(error_report.error.fingerprint).to eq('fingerprintzzz')
end
end
@@ -68,6 +67,7 @@ describe ErrorReport do
app.reload.problems.count
}.by(1)
end
+
context "with notice generate by Airbrake gem" do
let(:xml) { Airbrake::Notice.new(
:exception => Exception.new,
@@ -112,73 +112,74 @@ describe ErrorReport do
expect(subject.user_attributes['email']).to eq 'mr.bean@example.com'
expect(subject.user_attributes['username']).to eq 'mrbean'
end
+
it 'valid env_vars' do
- # XML:
- expect(subject.env_vars).to have_key('SCRIPT_NAME')
- expect(subject.env_vars['SCRIPT_NAME']).to be_nil # blank ends up nil
-
- # XML representation:
- #
- # false
- # true
- # /
- #
- #
- #
- #
- expected = {
- 'secure' => 'false',
- 'httponly' => 'true',
- 'path' => '/',
- 'expire_after' => nil,
- 'domain' => nil,
- 'id' => nil
- }
- expect(subject.env_vars).to have_key('rack_session_options')
- expect(subject.env_vars['rack_session_options']).to eql(expected)
- end
+ # XML:
+ expect(subject.env_vars).to have_key('SCRIPT_NAME')
+ expect(subject.env_vars['SCRIPT_NAME']).to be_nil # blank ends up nil
+
+ # XML representation:
+ #
+ # false
+ # true
+ # /
+ #
+ #
+ #
+ #
+ expected = {
+ 'secure' => 'false',
+ 'httponly' => 'true',
+ 'path' => '/',
+ 'expire_after' => nil,
+ 'domain' => nil,
+ 'id' => nil
+ }
+ expect(subject.env_vars).to have_key('rack_session_options')
+ expect(subject.env_vars['rack_session_options']).to eql(expected)
+ end
end
+ end
+
+ it 'save a notice assignes to err' do
+ error_report.generate_notice!
+ expect(error_report.notice.err).to be_a(Err)
+ end
- it 'save a notice assignes to err' do
+ it 'memoize the notice' do
+ expect {
error_report.generate_notice!
- expect(error_report.notice.err).to be_a(Err)
- end
+ error_report.generate_notice!
+ }.to change {
+ Notice.count
+ }.by(1)
+ end
- it 'memoize the notice' do
- expect {
- error_report.generate_notice!
- error_report.generate_notice!
- }.to change {
- Notice.count
- }.by(1)
- end
+ it 'find the correct err for the notice' do
+ err = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true))
- it 'find the correct err for the notice' do
- err = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true))
+ allow(error_report).to receive(:fingerprint).and_return(err.fingerprint)
- ErrorReport.any_instance.stub(:fingerprint).and_return(err.fingerprint)
+ expect {
+ error_report.generate_notice!
+ }.to change {
+ error_report.error.resolved?
+ }.from(true).to(false)
+ end
- expect {
- error_report.generate_notice!
- }.to change {
- error_report.error.resolved?
- }.from(true).to(false)
+ context "with notification service configured" do
+ before do
+ app.notify_on_errs = true
+ app.watchers.build(:email => 'foo@example.com')
+ app.save
end
-
- context "with notification service configured" do
- before do
- app.notify_on_errs = true
- app.watchers.build(:email => 'foo@example.com')
- app.save
- end
- it 'send email' do
- notice = error_report.generate_notice!
- email = ActionMailer::Base.deliveries.last
- expect(email.to).to include(app.watchers.first.email)
- expect(email.subject).to include(notice.message.truncate(50))
- expect(email.subject).to include("[#{app.name}]")
- expect(email.subject).to include("[#{notice.environment_name}]")
- end
+ it 'send email' do
+ notice = error_report.generate_notice!
+ email = ActionMailer::Base.deliveries.last
+ expect(email.to).to include(app.watchers.first.email)
+ expect(email.subject).to include(notice.message.truncate(50))
+ expect(email.subject).to include("[#{app.name}]")
+ expect(email.subject).to include("[#{notice.environment_name}]")
end
context "with xml without request section" do
@@ -270,8 +271,6 @@ describe ErrorReport do
expect(error_report.should_keep?).to be false
end
end
-
end
-
end
end
diff --git a/spec/models/fabricators_spec.rb b/spec/models/fabricators_spec.rb
index 9cf15ec..b06f091 100644
--- a/spec/models/fabricators_spec.rb
+++ b/spec/models/fabricators_spec.rb
@@ -1,5 +1,3 @@
-require 'spec_helper'
-
Fabrication::Config.fabricator_path.each do |folder|
Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file|
require file
diff --git a/spec/models/fingerprint/md5_spec.rb b/spec/models/fingerprint/md5_spec.rb
index 63599be..3209de5 100644
--- a/spec/models/fingerprint/md5_spec.rb
+++ b/spec/models/fingerprint/md5_spec.rb
@@ -1,6 +1,4 @@
-require 'spec_helper'
-
-describe Fingerprint::MD5 do
+describe Fingerprint::MD5, type: 'model' do
context 'being created' do
let(:backtrace) do
Backtrace.create(:raw => [
diff --git a/spec/models/fingerprint/sha1_spec.rb b/spec/models/fingerprint/sha1_spec.rb
index be834a9..fb06fb5 100644
--- a/spec/models/fingerprint/sha1_spec.rb
+++ b/spec/models/fingerprint/sha1_spec.rb
@@ -1,7 +1,4 @@
-require 'spec_helper'
-
-describe Fingerprint::Sha1 do
-
+describe Fingerprint::Sha1, type: 'model' do
context '#generate' do
let(:backtrace) {
Backtrace.create(:raw => [
@@ -80,8 +77,5 @@ describe Fingerprint::Sha1 do
should eq "# #