From fd88036b8dc04a5efe27a39765d00f510793a3eb Mon Sep 17 00:00:00 2001 From: yafeilee Date: Tue, 25 Nov 2014 01:05:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20rails=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8E=20rspec=20=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- Gemfile.lock | 92 +++++++++---------- .../admin/dashboard_controller_spec.rb | 2 +- .../admin/posts_controller_spec.rb | 4 +- .../admin/sessions_controller_spec.rb | 2 +- spec/controllers/archives_controller_spec.rb | 10 +- spec/controllers/likes_controller_spec.rb | 8 +- spec/spec_helper.rb | 1 - 8 files changed, 59 insertions(+), 62 deletions(-) diff --git a/Gemfile b/Gemfile index 5c087f7..b77a2cd 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ else source 'https://rubygems.org' end -gem 'rails', '4.1.7' +gem 'rails', '4.1.8' #gem 'sprockets', '2.12.1' gem 'sass-rails', '~> 4.0.4' gem 'coffee-rails', '~> 4.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 56accdd..b045e39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,33 +1,33 @@ GEM remote: http://ruby.taobao.org/ specs: - actionmailer (4.1.7) - actionpack (= 4.1.7) - actionview (= 4.1.7) + actionmailer (4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.7) - actionview (= 4.1.7) - activesupport (= 4.1.7) + actionpack (4.1.8) + actionview (= 4.1.8) + activesupport (= 4.1.8) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.7) - activesupport (= 4.1.7) + actionview (4.1.8) + activesupport (= 4.1.8) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.7) - activesupport (= 4.1.7) + activemodel (4.1.8) + activesupport (= 4.1.8) builder (~> 3.1) - activerecord (4.1.7) - activemodel (= 4.1.7) - activesupport (= 4.1.7) + activerecord (4.1.8) + activemodel (= 4.1.8) + activesupport (= 4.1.8) arel (~> 5.0.0) - activesupport (4.1.7) + activesupport (4.1.8) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) - angularjs-rails (1.3.0) + angularjs-rails (1.3.3) arel (5.0.1.20140414130214) bson (2.3.0) builder (3.2.2) @@ -59,7 +59,7 @@ GEM coffee-script-source execjs coffee-script-source (1.8.0) - connection_pool (2.0.0) + connection_pool (2.1.0) database_cleaner (1.3.0) diff-lcs (1.2.5) docile (1.1.5) @@ -82,7 +82,7 @@ GEM foundation-rails (5.4.5.0) railties (>= 3.1.0) sass (>= 3.2.0) - guard (2.7.0) + guard (2.8.2) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) @@ -91,7 +91,7 @@ GEM guard-bundler (2.0.0) bundler (~> 1.0) guard (~> 2.2) - guard-rails (0.6.0) + guard-rails (0.7.0) guard (~> 2.0) guard-rspec (4.3.1) guard (~> 2.1) @@ -106,19 +106,18 @@ GEM thor (>= 0.14, < 2.0) json (1.8.1) kgio (2.9.2) - listen (2.7.11) + listen (2.8.1) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.0.9) - mail (2.6.1) + mail (2.6.3) mime-types (>= 1.16, < 3) method_source (0.8.2) mime-types (2.4.3) - mini_magick (3.8.1) - subexec (~> 0.2.1) - mini_portile (0.6.0) - minitest (5.4.2) + mini_magick (4.0.1) + mini_portile (0.6.1) + minitest (5.4.3) mongoid (4.0.0) activemodel (~> 4.0) moped (~> 2.0.0) @@ -134,15 +133,15 @@ GEM mongoid (>= 3.0.1) rake rspec (>= 2.14) - moped (2.0.1) + moped (2.0.2) bson (~> 2.2) connection_pool (~> 2.0) optionable (~> 0.2.0) multi_json (1.10.1) netrc (0.8.0) - newrelic_rpm (3.9.6.257) - nokogiri (1.6.3.1) - mini_portile (= 0.6.0) + newrelic_rpm (3.9.7.266) + nokogiri (1.6.4.1) + mini_portile (~> 0.6.0) optionable (0.2.0) origin (2.1.1) pry (0.10.1) @@ -158,19 +157,19 @@ GEM rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (4.1.7) - actionmailer (= 4.1.7) - actionpack (= 4.1.7) - actionview (= 4.1.7) - activemodel (= 4.1.7) - activerecord (= 4.1.7) - activesupport (= 4.1.7) + rails (4.1.8) + actionmailer (= 4.1.8) + actionpack (= 4.1.8) + actionview (= 4.1.8) + activemodel (= 4.1.8) + activerecord (= 4.1.8) + activesupport (= 4.1.8) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.7) + railties (= 4.1.8) sprockets-rails (~> 2.0) - railties (4.1.7) - actionpack (= 4.1.7) - activesupport (= 4.1.7) + railties (4.1.8) + actionpack (= 4.1.8) + activesupport (= 4.1.8) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) @@ -185,7 +184,7 @@ GEM rest-client (1.7.2) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) - rouge (1.7.2) + rouge (1.7.4) rqrcode-with-patches (0.5.4) chunky_png rspec (3.1.0) @@ -217,8 +216,8 @@ GEM sass (~> 3.2.2) sprockets (~> 2.8, < 2.12) sprockets-rails (~> 2.0) - sidekiq (3.2.4) - celluloid (>= 0.15.2) + sidekiq (3.3.0) + celluloid (>= 0.16.0) connection_pool (>= 2.0.0) json redis (>= 3.0.6) @@ -240,24 +239,23 @@ GEM railties (>= 3.0, < 4.2) slim (~> 2.0) slop (3.6.0) - spring (1.1.3) + spring (1.2.0) sprockets (2.11.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.2.0) + sprockets-rails (2.2.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - subexec (0.2.3) temple (0.6.10) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) timers (4.0.1) hitimes - tzinfo (1.1.0) + tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.5.3) execjs (>= 0.3.0) @@ -300,7 +298,7 @@ DEPENDENCIES pry-nav pry-rails quiet_assets - rails (= 4.1.7) + rails (= 4.1.8) redcarpet rest-client rouge diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 201937f..10a9a10 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -8,7 +8,7 @@ describe Admin::DashboardController do describe "GET 'index'" do it "returns http success" do get 'index' - response.should be_success + expect(response).to be_success end end diff --git a/spec/controllers/admin/posts_controller_spec.rb b/spec/controllers/admin/posts_controller_spec.rb index 7de6acd..a633371 100644 --- a/spec/controllers/admin/posts_controller_spec.rb +++ b/spec/controllers/admin/posts_controller_spec.rb @@ -7,9 +7,9 @@ describe Admin::PostsController do end it "preview should return ok" do post :preview - response.body.should == "" + expect(response.body).to eq("") post :preview, content: '123' - response.body.should == "

123

\n" + expect(response.body).to eq("

123

\n") end it "update" do diff --git a/spec/controllers/admin/sessions_controller_spec.rb b/spec/controllers/admin/sessions_controller_spec.rb index 0ce5e16..e5f0c14 100644 --- a/spec/controllers/admin/sessions_controller_spec.rb +++ b/spec/controllers/admin/sessions_controller_spec.rb @@ -8,7 +8,7 @@ describe Admin::SessionsController do describe "GET 'new'" do it "returns http success" do get 'new' - response.should be_success + expect(response).to be_success end end diff --git a/spec/controllers/archives_controller_spec.rb b/spec/controllers/archives_controller_spec.rb index 04842bc..b044558 100644 --- a/spec/controllers/archives_controller_spec.rb +++ b/spec/controllers/archives_controller_spec.rb @@ -9,33 +9,33 @@ describe ArchivesController do describe "GET 'index'" do it "json" do get 'index', format: :json - posts_data(response).size.should == 0 + expect(posts_data(response).size).to eq(0) end it "add ten" do posts = create_list(:post_list, 10) get 'index', format: :json - posts_data(response).size.should == 10 + expect(posts_data(response).size).to eq(10) end it "add 20" do posts = create_list(:post_list, 20) get 'index', format: :json - posts_data(response).size.should == 10 + expect(posts_data(response).size).to eq(10) end it "type filter" do posts = create_list(:post_list, 20) life_posts = create_list(:post_list, 5, type: Post::LIFE) get 'index', type: 'life', format: :json - posts_data(response).size.should == 5 + expect(posts_data(response).size).to eq(5) end it "start_with filter" do posts = create_list(:post_list, 10) start_with = posts[4].created_at.to_i.to_s get 'index', start_with: start_with, format: :json - posts_data(response).size.should == 5 + expect(posts_data(response).size).to eq(5) end it "load_more" do diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index b1e01aa..a5392fb 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -5,17 +5,17 @@ describe LikesController do it "get index" do a = Post.create!(title: 'one', content: '1'*31, type: Post::TECH ) get 'index', blog_id: a.id - JSON.parse(response.body)['count'].should == 0 + expect(JSON.parse(response.body)['count']).to eq(0) a.likes << Like.new a.save! get 'index', blog_id: a.id - JSON.parse(response.body)['count'].should == 1 + expect(JSON.parse(response.body)['count']).to eq(1) end it "post create" do a = Post.create!(title: 'one', content: '1'*31, type: Post::TECH ) post 'create', blog_id: a.id - a.likes.size.should == 1 + expect(a.likes.size).to eq(1) end it "DELETE destroy" do @@ -24,6 +24,6 @@ describe LikesController do a.likes << like a.save! delete 'destroy', blog_id: a.id, id: like.id - a.reload.likes.size.should == 0 + expect(a.reload.likes.size).to eq(0) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c9ef59b..d5640f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,6 @@ require "codeclimate-test-reporter" CodeClimate::TestReporter.start require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' -require 'rspec/autorun' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories.