Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--format=nested
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-p247
2.3.3
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
rvm:
- 1.9.3
script: script/ci.sh
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source "http://rubygems.org"
gemspec

gem "guard"
gem "rails-controller-testing"
2 changes: 1 addition & 1 deletion app/controllers/style_guide/style_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module StyleGuide
class StyleController < StyleGuide::ApplicationController
before_filter :load_sections
before_action :load_sections

def index
@current_section = @sections.first
Expand Down
11 changes: 2 additions & 9 deletions lib/generators/style_guide/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def install

configure_guard_livereload
configure_application
configure_development
mount_style_guide
end

Expand Down Expand Up @@ -88,19 +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}")
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")
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 => "/style-guide"))
route(%(mount StyleGuide::Engine, at: "/style_guides" if defined?(StyleGuide)))
end
end
end
Expand Down
16 changes: 9 additions & 7 deletions spec/controllers/style_guide/style_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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") }

Expand All @@ -11,29 +13,29 @@

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
end

describe "#show" do
it "assigns sections" do
get :show, id: "monkey_hammer", use_route: :styles
get :show, params: { 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, params: { id: "monkey_hammer" }
assigns(:current_section).should be_a StyleGuide::Section
assigns(:current_section).title.should == "Monkey Hammer"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
config.cache_classes = true

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = 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
Expand Down
26 changes: 1 addition & 25 deletions spec/lib/generators/style_guide/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,36 +103,12 @@
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("") }

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
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/style_guide/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/style_guide/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 1 addition & 1 deletion style-guide.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down