From 541a82f21cafa05dafb2740d027fbf9eeaa7df1f Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 13:38:29 -0800 Subject: [PATCH 1/7] Update for use with current rspec --- .rspec | 1 - .rvmrc | 1 - .../style_guide/style_controller_spec.rb | 16 +++++++++------- spec/dummy/config/environments/test.rb | 2 +- spec/lib/style_guide/config_spec.rb | 8 ++++---- spec/lib/style_guide/section_spec.rb | 6 +++--- spec/spec_helper.rb | 10 ++++++++++ 7 files changed, 27 insertions(+), 17 deletions(-) delete mode 100644 .rvmrc diff --git a/.rspec b/.rspec index e41b078..4e1e0d2 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1 @@ --color ---format=nested diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 865fb10..0000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm --create ruby-1.9.3-p194@style-guide diff --git a/spec/controllers/style_guide/style_controller_spec.rb b/spec/controllers/style_guide/style_controller_spec.rb index 1bf8888..f411f48 100644 --- a/spec/controllers/style_guide/style_controller_spec.rb +++ b/spec/controllers/style_guide/style_controller_spec.rb @@ -1,6 +1,8 @@ require "spec_helper" -describe StyleGuide::StyleController do +describe StyleGuide::StyleController, type: :controller do + routes { StyleGuide::Engine.routes } + let(:temp_path) { Dir.mktmpdir } let(:partial_path) { File.join(temp_path, "monkey_hammer") } @@ -11,14 +13,14 @@ describe "#index" do it "assigns sections" do - get :index, use_route: :styles + get :index assigns(:sections).should be - assigns(:sections).should have(1).section + assigns(:sections).size.should eq 1 assigns(:sections).first.should be_a StyleGuide::Section end it "sets the current section to the first one" do - get :index, use_route: :styles + get :index assigns(:current_section).should == assigns(:sections).first assigns(:current_section).title.should == "Monkey Hammer" end @@ -26,14 +28,14 @@ describe "#show" do it "assigns sections" do - get :show, id: "monkey_hammer", use_route: :styles + get :show, id: "monkey_hammer" assigns(:sections).should be - assigns(:sections).should have(1).section + assigns(:sections).size.should eq 1 assigns(:sections).first.should be_a StyleGuide::Section end it "assigns the section" do - get :show, id: "monkey_hammer", use_route: :styles + get :show, id: "monkey_hammer" assigns(:current_section).should be_a StyleGuide::Section assigns(:current_section).title.should == "Monkey Hammer" end diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index f8e9fb1..0d38ba0 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -8,7 +8,7 @@ config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = "public, max-age=3600" # Show full error reports and disable caching diff --git a/spec/lib/style_guide/config_spec.rb b/spec/lib/style_guide/config_spec.rb index 54522e8..cc633a5 100644 --- a/spec/lib/style_guide/config_spec.rb +++ b/spec/lib/style_guide/config_spec.rb @@ -3,7 +3,7 @@ describe StyleGuide::Config do describe "#paths" do context "when no paths have been added" do - it { should have_at_least(1).path } + specify { subject.paths.size.should eq(1) } end context "when adding a path" do @@ -25,14 +25,14 @@ context "after a path has been added" do before { subject.paths << "partials-and-magic-beans" } - its(:paths) { should include "partials-and-magic-beans" } + specify { subject.paths.should include "partials-and-magic-beans" } end end describe "#sections" do context "when no paths have been added" do - it { should have_at_least(1).section } - its(:'sections.first') { should be_a StyleGuide::Section } + it { subject.sections.size.should be >= 1 } + specify { subject.sections.first.should be_a StyleGuide::Section } end context "when adding a nonexistent path" do diff --git a/spec/lib/style_guide/section_spec.rb b/spec/lib/style_guide/section_spec.rb index cc7349a..74833d8 100644 --- a/spec/lib/style_guide/section_spec.rb +++ b/spec/lib/style_guide/section_spec.rb @@ -40,7 +40,7 @@ context "with multiple paths having the same basename" do let(:paths) { ["/neck/wattle", "/underarm/wattle"] } - + it { should =~ ["wattle", "wattle1"] } end end @@ -71,7 +71,7 @@ before { Dir.stub(:glob => partial_paths) } - it { should have(2).partials } - its(:first) { should be_a StyleGuide::Partial } + specify { subject.size.should eq 2 } + specify { subject.first.should be_a StyleGuide::Partial } end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eda59ad..92f5bf4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,4 +5,14 @@ require "rspec/rails" require "generators/style_guide/install_generator" +RSpec.configure do |config| + config.expect_with(:rspec) do |c| + c.syntax = :should, :expect + end + + config.mock_with :rspec do |mocks| + mocks.syntax = :should + end +end + Dir.glob(File.expand_path("../support/**/*.rb")).each {|f| require f } From 7aed61324dc10de600e6a0d203d9ad515b30e90b Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 13:51:21 -0800 Subject: [PATCH 2/7] Upgrade for rails 5 support --- Gemfile | 1 + app/controllers/style_guide/style_controller.rb | 2 +- spec/controllers/style_guide/style_controller_spec.rb | 4 ++-- spec/dummy/config/environments/test.rb | 4 ++-- style-guide.gemspec | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 7cdba60..0517150 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,4 @@ source "http://rubygems.org" gemspec gem "guard" +gem "rails-controller-testing" diff --git a/app/controllers/style_guide/style_controller.rb b/app/controllers/style_guide/style_controller.rb index 8d839d9..79b1d42 100644 --- a/app/controllers/style_guide/style_controller.rb +++ b/app/controllers/style_guide/style_controller.rb @@ -1,6 +1,6 @@ module StyleGuide class StyleController < StyleGuide::ApplicationController - before_filter :load_sections + before_action :load_sections def index @current_section = @sections.first diff --git a/spec/controllers/style_guide/style_controller_spec.rb b/spec/controllers/style_guide/style_controller_spec.rb index f411f48..756518e 100644 --- a/spec/controllers/style_guide/style_controller_spec.rb +++ b/spec/controllers/style_guide/style_controller_spec.rb @@ -28,14 +28,14 @@ describe "#show" do it "assigns sections" do - get :show, id: "monkey_hammer" + get :show, params: { id: "monkey_hammer" } assigns(:sections).should be assigns(:sections).size.should eq 1 assigns(:sections).first.should be_a StyleGuide::Section end it "assigns the section" do - get :show, id: "monkey_hammer" + get :show, params: { id: "monkey_hammer" } assigns(:current_section).should be_a StyleGuide::Section assigns(:current_section).title.should == "Monkey Hammer" end diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 0d38ba0..1d4af76 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -8,8 +8,8 @@ config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_files = true - config.static_cache_control = "public, max-age=3600" + config.public_file_server.enabled = true + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching config.consider_all_requests_local = true diff --git a/style-guide.gemspec b/style-guide.gemspec index bf5d3ea..1cf95cb 100644 --- a/style-guide.gemspec +++ b/style-guide.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- spec/*`.split( "\n" ) s.require_paths = ["lib"] - s.add_dependency "rails", "~> 4.0" + s.add_dependency "rails", ">= 4.0" s.add_dependency "nokogiri", "~> 1.5" s.add_dependency "github-markdown", "~> 0.5" From 6088a3ec6038317d25a659fa3c033d8855a60608 Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 14:56:07 -0800 Subject: [PATCH 3/7] Fix generated route syntax --- lib/generators/style_guide/install_generator.rb | 2 +- spec/lib/generators/style_guide/install_generator_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/style_guide/install_generator.rb b/lib/generators/style_guide/install_generator.rb index b7c5166..b3b1602 100644 --- a/lib/generators/style_guide/install_generator.rb +++ b/lib/generators/style_guide/install_generator.rb @@ -100,7 +100,7 @@ def configure_development def mount_style_guide unless routes_rb && routes_rb.include?("mount StyleGuide::Engine") - route(%(mount StyleGuide::Engine => "/style-guide")) + route(%(mount StyleGuide::Engine at: "/style_guides" if defined?(StyleGuide))) end end end diff --git a/spec/lib/generators/style_guide/install_generator_spec.rb b/spec/lib/generators/style_guide/install_generator_spec.rb index 05b2fcd..7656f35 100644 --- a/spec/lib/generators/style_guide/install_generator_spec.rb +++ b/spec/lib/generators/style_guide/install_generator_spec.rb @@ -132,7 +132,7 @@ before { subject.stub(:routes_rb).and_return("") } it "mounts the style guide" do - subject.should_receive(:route).with('mount StyleGuide::Engine => "/style-guide"') + subject.should_receive(:route).with('mount StyleGuide::Engine at: "/style_guides" if defined?(StyleGuide)') subject.install end end From 6f2e9553807c0a1de22e5ad85dd0941409c8863c Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 15:00:16 -0800 Subject: [PATCH 4/7] Remove broken configuration for live reload --- .../style_guide/install_generator.rb | 7 ------ .../style_guide/install_generator_spec.rb | 24 ------------------- 2 files changed, 31 deletions(-) diff --git a/lib/generators/style_guide/install_generator.rb b/lib/generators/style_guide/install_generator.rb index b3b1602..65959fe 100644 --- a/lib/generators/style_guide/install_generator.rb +++ b/lib/generators/style_guide/install_generator.rb @@ -10,7 +10,6 @@ def install configure_guard_livereload configure_application - configure_development mount_style_guide end @@ -92,12 +91,6 @@ def configure_application end end - def configure_development - unless development_rb && development_rb.include?("Rack::LiveReload") - application("config.middleware.insert_before(::Rack::Lock, ::Rack::LiveReload, :min_delay => 500) if defined?(Rack::LiveReload)", :env => "development") - end - end - def mount_style_guide unless routes_rb && routes_rb.include?("mount StyleGuide::Engine") route(%(mount StyleGuide::Engine at: "/style_guides" if defined?(StyleGuide))) diff --git a/spec/lib/generators/style_guide/install_generator_spec.rb b/spec/lib/generators/style_guide/install_generator_spec.rb index 7656f35..e33db1b 100644 --- a/spec/lib/generators/style_guide/install_generator_spec.rb +++ b/spec/lib/generators/style_guide/install_generator_spec.rb @@ -103,30 +103,6 @@ end end - describe "development configuration" do - context "when livereload is not configured in development.rb" do - before { subject.stub(:development_rb).and_return("") } - - it "adds an entry for livereload" do - subject.should_receive(:application).once do |config, options| - options.should == {:env => "development"} - config.should include "config.middleware.insert_before" - config.should include "Rack::LiveReload" - end - subject.install - end - end - - context "when livereload is already configured in development.rb" do - before { subject.stub(:development_rb).and_return("Rack::LiveReload") } - - it "does not modify development.rb" do - subject.should_not_receive(:application) - subject.install - end - end - end - describe "mounting" do context "when style guide is not mounted" do before { subject.stub(:routes_rb).and_return("") } From 59f1e47a71c9cc48a4906702d277ac6d1274c06d Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 15:01:17 -0800 Subject: [PATCH 5/7] Update route configuration syntax --- lib/generators/style_guide/install_generator.rb | 4 ++-- spec/lib/generators/style_guide/install_generator_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/generators/style_guide/install_generator.rb b/lib/generators/style_guide/install_generator.rb index 65959fe..50729f8 100644 --- a/lib/generators/style_guide/install_generator.rb +++ b/lib/generators/style_guide/install_generator.rb @@ -87,13 +87,13 @@ def configure_guard_livereload def configure_application unless application_rb && application_rb.include?("config.style_guide.paths") - application("config.style_guide.paths << #{default_partial_path}") + application("StyleGuide::Engine.config.style_guide.paths << #{default_partial_path}") end end def mount_style_guide unless routes_rb && routes_rb.include?("mount StyleGuide::Engine") - route(%(mount StyleGuide::Engine at: "/style_guides" if defined?(StyleGuide))) + route(%(mount StyleGuide::Engine, at: "/style_guides" if defined?(StyleGuide))) end end end diff --git a/spec/lib/generators/style_guide/install_generator_spec.rb b/spec/lib/generators/style_guide/install_generator_spec.rb index e33db1b..d0cb368 100644 --- a/spec/lib/generators/style_guide/install_generator_spec.rb +++ b/spec/lib/generators/style_guide/install_generator_spec.rb @@ -108,7 +108,7 @@ before { subject.stub(:routes_rb).and_return("") } it "mounts the style guide" do - subject.should_receive(:route).with('mount StyleGuide::Engine at: "/style_guides" if defined?(StyleGuide)') + subject.should_receive(:route).with('mount StyleGuide::Engine, at: "/style_guides" if defined?(StyleGuide)') subject.install end end From 12edb5213f2e30c8e67f740fd33ce8bb1c8a3bb5 Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 15:41:38 -0800 Subject: [PATCH 6/7] =?UTF-8?q?Get=20Travis=E2=80=99=20ruby=20version=20fr?= =?UTF-8?q?om=20.ruby-version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 330bcfc..458675f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1 @@ -rvm: - - 1.9.3 script: script/ci.sh From 39325db3f132e379b232247e05da8e7678eae314 Mon Sep 17 00:00:00 2001 From: Damien Burke Date: Sat, 26 Nov 2016 15:52:36 -0800 Subject: [PATCH 7/7] Upgrade ruby version --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index cb50681..0bee604 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.0.0-p247 +2.3.3