Fixed rspec warning info, refactor spec
This commit is contained in:
parent
0132f5c1d4
commit
d75b5fce18
2
Gemfile
2
Gemfile
|
@ -65,7 +65,7 @@ end
|
||||||
|
|
||||||
group :test, :development do
|
group :test, :development do
|
||||||
gem "rspec-rails", ">= 2.8.1"
|
gem "rspec-rails", ">= 2.8.1"
|
||||||
gem 'rails-controller-testing'
|
|
||||||
gem 'byebug'
|
gem 'byebug'
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
|
gem 'rails-controller-testing'
|
||||||
end
|
end
|
||||||
|
|
16
Gemfile.lock
16
Gemfile.lock
|
@ -128,7 +128,7 @@ GEM
|
||||||
guard-rails (0.8.0)
|
guard-rails (0.8.0)
|
||||||
guard (~> 2.11)
|
guard (~> 2.11)
|
||||||
guard-compat (~> 1.0)
|
guard-compat (~> 1.0)
|
||||||
guard-rspec (4.7.2)
|
guard-rspec (4.7.3)
|
||||||
guard (~> 2.1)
|
guard (~> 2.1)
|
||||||
guard-compat (~> 1.1)
|
guard-compat (~> 1.1)
|
||||||
rspec (>= 2.99.0, < 4.0)
|
rspec (>= 2.99.0, < 4.0)
|
||||||
|
@ -160,7 +160,7 @@ GEM
|
||||||
mime-types (3.1)
|
mime-types (3.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2016.0521)
|
mime-types-data (3.2016.0521)
|
||||||
mimemagic (0.3.1)
|
mimemagic (0.3.2)
|
||||||
mina (0.3.8)
|
mina (0.3.8)
|
||||||
open4 (~> 1.3.4)
|
open4 (~> 1.3.4)
|
||||||
rake
|
rake
|
||||||
|
@ -184,7 +184,7 @@ GEM
|
||||||
nokogiri (1.6.8)
|
nokogiri (1.6.8)
|
||||||
mini_portile2 (~> 2.1.0)
|
mini_portile2 (~> 2.1.0)
|
||||||
pkg-config (~> 1.1.7)
|
pkg-config (~> 1.1.7)
|
||||||
notiffany (0.1.0)
|
notiffany (0.1.1)
|
||||||
nenv (~> 0.1)
|
nenv (~> 0.1)
|
||||||
shellany (~> 0.0)
|
shellany (~> 0.0)
|
||||||
open4 (1.3.4)
|
open4 (1.3.4)
|
||||||
|
@ -246,7 +246,7 @@ GEM
|
||||||
rspec-core (~> 3.5.0)
|
rspec-core (~> 3.5.0)
|
||||||
rspec-expectations (~> 3.5.0)
|
rspec-expectations (~> 3.5.0)
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-mocks (~> 3.5.0)
|
||||||
rspec-core (3.5.1)
|
rspec-core (3.5.2)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.5.0)
|
||||||
rspec-expectations (3.5.0)
|
rspec-expectations (3.5.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
|
@ -266,7 +266,7 @@ GEM
|
||||||
rspec (~> 3.0, >= 3.0.0)
|
rspec (~> 3.0, >= 3.0.0)
|
||||||
sidekiq (>= 2.4.0)
|
sidekiq (>= 2.4.0)
|
||||||
rspec-support (3.5.0)
|
rspec-support (3.5.0)
|
||||||
ruby_dep (1.3.1)
|
ruby_dep (1.4.0)
|
||||||
sass (3.4.22)
|
sass (3.4.22)
|
||||||
sass-rails (5.0.6)
|
sass-rails (5.0.6)
|
||||||
railties (>= 4.0.0, < 6)
|
railties (>= 4.0.0, < 6)
|
||||||
|
@ -302,7 +302,7 @@ GEM
|
||||||
sprockets (3.7.0)
|
sprockets (3.7.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (> 1, < 3)
|
rack (> 1, < 3)
|
||||||
sprockets-es6 (0.9.0)
|
sprockets-es6 (0.9.1)
|
||||||
babel-source (>= 5.8.11)
|
babel-source (>= 5.8.11)
|
||||||
babel-transpiler
|
babel-transpiler
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
|
@ -314,12 +314,12 @@ GEM
|
||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tilt (2.0.5)
|
tilt (2.0.5)
|
||||||
turbolinks (5.0.0)
|
turbolinks (5.0.1)
|
||||||
turbolinks-source (~> 5)
|
turbolinks-source (~> 5)
|
||||||
turbolinks-source (5.0.0)
|
turbolinks-source (5.0.0)
|
||||||
tzinfo (1.2.2)
|
tzinfo (1.2.2)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (3.0.0)
|
uglifier (3.0.1)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
|
|
|
@ -53,7 +53,7 @@ You can run it like a Ruby on Rails project as usual:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
ruby -v
|
ruby -v
|
||||||
# 2.2.3
|
# 2.3.1
|
||||||
postgres --version
|
postgres --version
|
||||||
# 9.x.x
|
# 9.x.x
|
||||||
```
|
```
|
||||||
|
@ -106,8 +106,8 @@ You can read WBlog wiki for more information: [WBlog 的发布流程(Chinese onl
|
||||||
|
|
||||||
### Stack
|
### Stack
|
||||||
|
|
||||||
* Ruby on Rails 5.0.0.beta3
|
* Ruby on Rails 5.0.0
|
||||||
* Ruby 2.2.3
|
* Ruby 2.3.1
|
||||||
* Turbolinks / SJR
|
* Turbolinks / SJR
|
||||||
* Foundation 6
|
* Foundation 6
|
||||||
* mina
|
* mina
|
||||||
|
|
|
@ -75,7 +75,7 @@ WBlog 采用了 `mina` 作为自动化发布工具, 使用 `nginx`, `puma` 为
|
||||||
### 技术栈
|
### 技术栈
|
||||||
|
|
||||||
* Ruby on Rails 5.0.0
|
* Ruby on Rails 5.0.0
|
||||||
* Ruby 2.2.3
|
* Ruby 2.3.1
|
||||||
* Foundation 6
|
* Foundation 6
|
||||||
* mina
|
* mina
|
||||||
* slim
|
* slim
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
WBlog::Application.routes.draw do
|
WBlog::Application.routes.draw do
|
||||||
|
|
||||||
|
get 'hello/test'
|
||||||
|
|
||||||
resources :blogs, :only=>[:index, :show, :edit] do
|
resources :blogs, :only=>[:index, :show, :edit] do
|
||||||
collection do
|
collection do
|
||||||
get :rss
|
get :rss
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Admin::CommentsController do
|
RSpec.describe Admin::CommentsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Admin::DashboardController do
|
RSpec.describe Admin::DashboardController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
session[:login] = true
|
session[:login] = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Admin::PostsController do
|
RSpec.describe Admin::PostsController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
session[:login] = true
|
session[:login] = true
|
||||||
|
@ -8,14 +8,14 @@ describe Admin::PostsController do
|
||||||
it "preview should return ok" do
|
it "preview should return ok" do
|
||||||
post :preview
|
post :preview
|
||||||
expect(response.body).to eq("")
|
expect(response.body).to eq("")
|
||||||
post :preview, content: '123'
|
post :preview, params: { content: '123' }
|
||||||
expect(response.body).to eq("<p>123</p>\n")
|
expect(response.body).to eq("<p>123</p>\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "update" do
|
it "update" do
|
||||||
post = create(:post)
|
post = create(:post)
|
||||||
|
|
||||||
patch 'update', id: post.id, labels: 'think, go '
|
patch 'update', params: { id: post.id, labels: 'think, go ' }
|
||||||
expect(post.reload.labels.size).to eq(2)
|
expect(post.reload.labels.size).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,21 +27,21 @@ describe Admin::PostsController do
|
||||||
post.save!
|
post.save!
|
||||||
expect(label.posts.size).to eq(1)
|
expect(label.posts.size).to eq(1)
|
||||||
|
|
||||||
delete 'destroy', id: post.id
|
delete 'destroy', params: { id: post.id }
|
||||||
expect( Post.all.size ).to eq(0)
|
expect( Post.all.size ).to eq(0)
|
||||||
expect( label.reload.posts.size ).to eq(0)
|
expect( label.reload.posts.size ).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "create" do
|
it "create" do
|
||||||
post_params = attributes_for(:post)
|
post_params = attributes_for(:post)
|
||||||
post 'create', post_params.merge( labels: 'think, go ' )
|
post 'create', params: post_params.merge( labels: 'think, go ' )
|
||||||
|
|
||||||
post = Post.first
|
post = Post.first
|
||||||
expect( post.labels.size ).to eq(2)
|
expect( post.labels.size ).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "create fail and see labels_content" do
|
it "create fail and see labels_content" do
|
||||||
post 'create', labels: 'think, go '
|
post 'create', params: { labels: 'think, go ' }
|
||||||
expect( assigns(:post).labels_content ).to eq('think, go')
|
expect( assigns(:post).labels_content ).to eq('think, go')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Admin::SessionsController do
|
RSpec.describe Admin::SessionsController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
session[:login] = true
|
session[:login] = true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Admin::SubscribesController, :type => :controller do
|
RSpec.describe Admin::SubscribesController, :type => :controller do
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ RSpec.describe Admin::SubscribesController, :type => :controller do
|
||||||
describe "POST enable" do
|
describe "POST enable" do
|
||||||
it "returns http success" do
|
it "returns http success" do
|
||||||
subscribe = create(:subscribe)
|
subscribe = create(:subscribe)
|
||||||
post :enable, id: subscribe.id
|
post :enable, params: { id: subscribe.id }
|
||||||
expect(subscribe.reload.enable).to eq(true)
|
expect(subscribe.reload.enable).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ RSpec.describe Admin::SubscribesController, :type => :controller do
|
||||||
describe "POST disable" do
|
describe "POST disable" do
|
||||||
it "returns http success" do
|
it "returns http success" do
|
||||||
subscribe = create(:subscribe, enable: true)
|
subscribe = create(:subscribe, enable: true)
|
||||||
post :disable, id: subscribe.id
|
post :disable, params: { id: subscribe.id }
|
||||||
expect(subscribe.reload.enable).to eq(false)
|
expect(subscribe.reload.enable).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ArchivesController do
|
RSpec.describe ArchivesController, type: :controller do
|
||||||
|
|
||||||
it "get index" do
|
it "get index" do
|
||||||
create_list(:post_list, 3)
|
create_list(:post_list, 3)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe BlogsController do
|
RSpec.describe BlogsController, type: :controller do
|
||||||
|
|
||||||
describe 'get INDEX' do
|
describe 'get INDEX' do
|
||||||
it 'index should get by order desc' do
|
it 'index should get by order desc' do
|
||||||
|
@ -27,7 +27,7 @@ describe BlogsController do
|
||||||
comment2.post = post
|
comment2.post = post
|
||||||
comment2.save!
|
comment2.save!
|
||||||
|
|
||||||
get :show, id: post.id
|
get :show, params: { id: post.id }
|
||||||
expect(assigns(:comments)[0]).to eq(comment2)
|
expect(assigns(:comments)[0]).to eq(comment2)
|
||||||
expect(assigns(:comments)[1]).to eq(comment1)
|
expect(assigns(:comments)[1]).to eq(comment1)
|
||||||
end
|
end
|
||||||
|
@ -38,26 +38,26 @@ describe BlogsController do
|
||||||
selected = posts[1]
|
selected = posts[1]
|
||||||
s_prev = posts[0]
|
s_prev = posts[0]
|
||||||
s_next = posts[2]
|
s_next = posts[2]
|
||||||
get :show, id: selected.id
|
get :show, params: { id: selected.id }
|
||||||
expect(assigns(:prev)).to eq(s_prev)
|
expect(assigns(:prev)).to eq(s_prev)
|
||||||
expect(assigns(:next)).to eq(s_next)
|
expect(assigns(:next)).to eq(s_next)
|
||||||
|
|
||||||
# 下界
|
# 下界
|
||||||
selected = posts[0]
|
selected = posts[0]
|
||||||
get :show, id: selected.id
|
get :show, params: { id: selected.id }
|
||||||
expect(assigns(:prev)).to be_nil
|
expect(assigns(:prev)).to be_nil
|
||||||
expect(assigns(:next)).to eq(posts[1])
|
expect(assigns(:next)).to eq(posts[1])
|
||||||
|
|
||||||
# 测试上界
|
# 测试上界
|
||||||
selected = posts[2]
|
selected = posts[2]
|
||||||
get :show, id: selected.id
|
get :show, params: { id: selected.id }
|
||||||
expect(assigns(:prev)).to eq(posts[1])
|
expect(assigns(:prev)).to eq(posts[1])
|
||||||
expect(assigns(:next)).to be_nil
|
expect(assigns(:next)).to be_nil
|
||||||
|
|
||||||
# 测试未来时间
|
# 测试未来时间
|
||||||
create(:post, created_at: Time.now + 100)
|
create(:post, created_at: Time.now + 100)
|
||||||
selected = posts[1]
|
selected = posts[1]
|
||||||
get :show, id: selected.id
|
get :show, params: { id: selected.id }
|
||||||
expect(assigns(:prev)).to eq(posts[0])
|
expect(assigns(:prev)).to eq(posts[0])
|
||||||
expect(assigns(:next)).to eq(posts[2])
|
expect(assigns(:next)).to eq(posts[2])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe HomeController do
|
RSpec.describe HomeController, type: :controller do
|
||||||
|
|
||||||
describe "GET 'index'" do
|
describe "GET 'index'" do
|
||||||
it "returns http success" do
|
it "returns http success" do
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe LikesController do
|
RSpec.describe LikesController, type: :controller do
|
||||||
|
|
||||||
it "get index" do
|
it "get index" do
|
||||||
a = Post.create!(title: 'one', content: '1'*31)
|
a = Post.create!(title: 'one', content: '1'*31)
|
||||||
get 'index', blog_id: a.id
|
get 'index', params: { blog_id: a.id }
|
||||||
expect(JSON.parse(response.body)['count']).to eq(0)
|
expect(JSON.parse(response.body)['count']).to eq(0)
|
||||||
a.likes << Like.new
|
a.likes << Like.new
|
||||||
a.save!
|
a.save!
|
||||||
get 'index', blog_id: a.id
|
get 'index', params: { blog_id: a.id }
|
||||||
expect(JSON.parse(response.body)['count']).to eq(1)
|
expect(JSON.parse(response.body)['count']).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "post create" do
|
it "post create" do
|
||||||
a = Post.create!(title: 'one', content: '1'*31)
|
a = Post.create!(title: 'one', content: '1'*31)
|
||||||
post 'create', blog_id: a.id
|
post 'create', params: { blog_id: a.id }
|
||||||
expect(a.likes.size).to eq(1)
|
expect(a.likes.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ describe LikesController do
|
||||||
like = Like.new
|
like = Like.new
|
||||||
a.likes << like
|
a.likes << like
|
||||||
a.save!
|
a.save!
|
||||||
delete 'destroy', blog_id: a.id, id: like.id
|
delete 'destroy', params: { blog_id: a.id, id: like.id }
|
||||||
expect(a.reload.likes.size).to eq(0)
|
expect(a.reload.likes.size).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe SubscribesController do
|
RSpec.describe SubscribesController, type: :controller do
|
||||||
|
|
||||||
describe "POST 'create'" do
|
describe "POST 'create'" do
|
||||||
it "post ok" do
|
it "post ok" do
|
||||||
post 'create', { subscribe: { email: 'tester@test.com' } }
|
post 'create', params: { subscribe: { email: 'tester@test.com' } }
|
||||||
expect(Subscribe.all.size).to eq(1)
|
expect(Subscribe.all.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "post with disabled email" do
|
it "post with disabled email" do
|
||||||
subscribe = Subscribe.create(email: 'tester@test.com', enable: false)
|
subscribe = Subscribe.create(email: 'tester@test.com', enable: false)
|
||||||
post 'create', { subscribe: { email: 'tester@test.com' } }
|
post :create, params: { subscribe: { email: 'tester@test.com' } }
|
||||||
expect(subscribe.reload.enable).to be_truthy
|
expect(subscribe.reload.enable).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe UnsubscribesController do
|
RSpec.describe UnsubscribesController, type: :controller do
|
||||||
|
|
||||||
describe "POST 'create'" do
|
describe "POST 'create'" do
|
||||||
it "unsuscribe ok" do
|
it "unsuscribe ok" do
|
||||||
subscribe = create(:subscribe, enable: true)
|
subscribe = create(:subscribe, enable: true)
|
||||||
post 'create', { subscribe: { email: subscribe.email } }
|
post 'create', params: { subscribe: { email: subscribe.email } }
|
||||||
expect(subscribe.reload.enable).to be(false)
|
expect(subscribe.reload.enable).to be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Like do
|
RSpec.describe Like, type: :model do
|
||||||
it "add like" do
|
it "add like" do
|
||||||
a = Post.create!(title: 'one', content: '1'*31)
|
a = Post.create!(title: 'one', content: '1'*31)
|
||||||
like = Like.new
|
like = Like.new
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Post do
|
RSpec.describe Post, type: :model do
|
||||||
it "validates should be ok" do
|
it "validates should be ok" do
|
||||||
expect(create(:post)).to be_truthy
|
expect(create(:post)).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
describe Subscribe do
|
|
||||||
|
RSpec.describe Subscribe, type: :model do
|
||||||
it "validates should be ok" do
|
it "validates should be ok" do
|
||||||
expect(create(:subscribe)).to be_truthy
|
expect(create(:subscribe)).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
require File.expand_path('../../config/environment', __FILE__)
|
||||||
|
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'rspec/rails'
|
||||||
|
require 'codeclimate-test-reporter'
|
||||||
|
CodeClimate::TestReporter.start
|
||||||
|
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
||||||
|
|
||||||
|
ActiveRecord::Migration.maintain_test_schema!
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.include FactoryGirl::Syntax::Methods
|
||||||
|
|
||||||
|
config.before(:suite) do
|
||||||
|
DatabaseCleaner.strategy = :transaction
|
||||||
|
DatabaseCleaner.clean_with(:truncation)
|
||||||
|
end
|
||||||
|
|
||||||
|
config.around(:each) do |example|
|
||||||
|
DatabaseCleaner.cleaning do
|
||||||
|
example.run
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# RSpec Rails can automatically mix in different behaviours to your tests
|
||||||
|
# based on their file location, for example enabling you to call `get` and
|
||||||
|
# `post` in specs under `spec/controllers`.
|
||||||
|
#
|
||||||
|
# You can disable this behaviour by removing the line below, and instead
|
||||||
|
# explicitly tag your specs with their type, e.g.:
|
||||||
|
#
|
||||||
|
# RSpec.describe UsersController, :type => :controller do
|
||||||
|
# # ...
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# The different available types are documented in the features, such as in
|
||||||
|
# https://relishapp.com/rspec/rspec-rails/docs
|
||||||
|
config.infer_spec_type_from_file_location!
|
||||||
|
|
||||||
|
# Filter lines from Rails gems in backtraces.
|
||||||
|
config.filter_rails_from_backtrace!
|
||||||
|
# arbitrary gems may also be filtered via:
|
||||||
|
# config.filter_gems_from_backtrace("gem name")
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec::Sidekiq.configure do |config|
|
||||||
|
config.warn_when_jobs_not_processed_by_sidekiq = false
|
||||||
|
end
|
|
@ -1,36 +1,99 @@
|
||||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
||||||
ENV["RAILS_ENV"] ||= 'test'
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||||
require "codeclimate-test-reporter"
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
||||||
CodeClimate::TestReporter.start
|
# this file to always be loaded, without a need to explicitly require it in any
|
||||||
require File.expand_path("../../config/environment", __FILE__)
|
# files.
|
||||||
require 'rspec/rails'
|
#
|
||||||
|
# Given that it is always loaded, you are encouraged to keep this file as
|
||||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
# light-weight as possible. Requiring heavyweight dependencies from this file
|
||||||
# in spec/support/ and its subdirectories.
|
# will add to the boot time of your test suite on EVERY test run, even for an
|
||||||
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
# individual file that may not need all of that loaded. Instead, consider making
|
||||||
|
# a separate helper file that requires the additional dependencies and performs
|
||||||
|
# the additional setup, and require it from the spec files that actually need
|
||||||
|
# it.
|
||||||
|
#
|
||||||
|
# The `.rspec` file also contains a few flags that are not defaults but that
|
||||||
|
# users commonly want.
|
||||||
|
#
|
||||||
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.infer_spec_type_from_file_location!
|
# rspec-expectations config goes here. You can use an alternate
|
||||||
config.include FactoryGirl::Syntax::Methods
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||||
config.before :each do
|
# assertions if you prefer.
|
||||||
DatabaseCleaner.strategy = :truncation
|
config.expect_with :rspec do |expectations|
|
||||||
DatabaseCleaner.start
|
# This option will default to `true` in RSpec 4. It makes the `description`
|
||||||
|
# and `failure_message` of custom matchers include text for helper methods
|
||||||
|
# defined using `chain`, e.g.:
|
||||||
|
# be_bigger_than(2).and_smaller_than(4).description
|
||||||
|
# # => "be bigger than 2 and smaller than 4"
|
||||||
|
# ...rather than:
|
||||||
|
# # => "be bigger than 2"
|
||||||
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||||
end
|
end
|
||||||
|
|
||||||
config.after :each do
|
# rspec-mocks config goes here. You can use an alternate test double
|
||||||
DatabaseCleaner.clean
|
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
||||||
|
config.mock_with :rspec do |mocks|
|
||||||
|
# Prevents you from mocking or stubbing a method that does not exist on
|
||||||
|
# a real object. This is generally recommended, and will default to
|
||||||
|
# `true` in RSpec 4.
|
||||||
|
mocks.verify_partial_doubles = true
|
||||||
end
|
end
|
||||||
|
|
||||||
config.mock_with :rspec
|
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
||||||
config.infer_base_class_for_anonymous_controllers = false
|
# have no way to turn it off -- the option exists only for backwards
|
||||||
|
# compatibility in RSpec 3). It causes shared context metadata to be
|
||||||
|
# inherited by the metadata hash of host groups and examples, rather than
|
||||||
|
# triggering implicit auto-inclusion in groups with matching metadata.
|
||||||
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||||
|
|
||||||
[:controller, :view, :request].each do |type|
|
# The settings below are suggested to provide a good initial experience
|
||||||
config.include ::Rails::Controller::Testing::TestProcess, :type => type
|
# with RSpec, but feel free to customize to your heart's content.
|
||||||
config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
|
=begin
|
||||||
config.include ::Rails::Controller::Testing::Integration, :type => type
|
# This allows you to limit a spec run to individual examples or groups
|
||||||
|
# you care about by tagging them with `:focus` metadata. When nothing
|
||||||
|
# is tagged with `:focus`, all examples get run. RSpec also provides
|
||||||
|
# aliases for `it`, `describe`, and `context` that include `:focus`
|
||||||
|
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
||||||
|
config.filter_run_when_matching :focus
|
||||||
|
|
||||||
|
# Allows RSpec to persist some state between runs in order to support
|
||||||
|
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
||||||
|
# you configure your source control system to ignore this file.
|
||||||
|
config.example_status_persistence_file_path = "spec/examples.txt"
|
||||||
|
|
||||||
|
# Limits the available syntax to the non-monkey patched syntax that is
|
||||||
|
# recommended. For more details, see:
|
||||||
|
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
||||||
|
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
||||||
|
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
||||||
|
config.disable_monkey_patching!
|
||||||
|
|
||||||
|
# Many RSpec users commonly either run the entire suite or an individual
|
||||||
|
# file, and it's useful to allow more verbose output when running an
|
||||||
|
# individual spec file.
|
||||||
|
if config.files_to_run.one?
|
||||||
|
# Use the documentation formatter for detailed output,
|
||||||
|
# unless a formatter has already been configured
|
||||||
|
# (e.g. via a command-line flag).
|
||||||
|
config.default_formatter = 'doc'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
# Print the 10 slowest examples and example groups at the
|
||||||
RSpec::Sidekiq.configure do |config|
|
# end of the spec run, to help surface which specs are running
|
||||||
config.warn_when_jobs_not_processed_by_sidekiq = false
|
# particularly slow.
|
||||||
|
config.profile_examples = 10
|
||||||
|
|
||||||
|
# Run specs in random order to surface order dependencies. If you find an
|
||||||
|
# order dependency and want to debug it, you can fix the order by providing
|
||||||
|
# the seed, which is printed after each run.
|
||||||
|
# --seed 1234
|
||||||
|
config.order = :random
|
||||||
|
|
||||||
|
# Seed global randomization in this process using the `--seed` CLI option.
|
||||||
|
# Setting this allows you to use `--seed` to deterministically reproduce
|
||||||
|
# test failures related to randomization by passing the same `--seed` value
|
||||||
|
# as the one that triggered the failure.
|
||||||
|
Kernel.srand config.seed
|
||||||
|
=end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue