Skip to content

Commit

Permalink
Merge pull request #39 from mudbugmedia/fix-css-paths
Browse files Browse the repository at this point in the history
Fix css paths
  • Loading branch information
michael-misshore authored Mar 2, 2019
2 parents ce4c3a2 + d9205e8 commit c5ebdc1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ group :development, :test do
gem 'actionpack'
gem 'byebug', platform: [:ruby], require: false
gem 'rubocop', require: false
gem 'rspec-rails', '~> 3.6'
gem 'capybara', '~> 2.16'
gem 'rspec-rails', '~> 3.8'
gem 'capybara', '~> 3.14'
gem 'pry-rails'
end

Expand Down
2 changes: 1 addition & 1 deletion critical-path-css-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.require_path = 'lib'

gem.add_development_dependency 'combustion', '~> 0.7.0'
gem.add_development_dependency 'combustion', '~> 1.1.0'

gem.extensions = ['ext/npm/extconf.rb']
end
5 changes: 4 additions & 1 deletion lib/critical_path_css/rails/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def format_css_paths
if config['css_path']
config['css_path'] = format_path(config['css_path'])
config['css_paths'] = []
else
elsif config['css_paths']
config['css_path'] = ''
config['css_paths'] = config['css_paths'].collect { |path| format_path(path) }
else
config['css_path'] = ActionController::Base.helpers.stylesheet_path(config['manifest_name'], host: '')
config['css_paths'] = []
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/critical_path_css/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CriticalPathCSS
module Rails
VERSION = '3.0.0'.freeze
VERSION = '3.0.1'.freeze
end
end
26 changes: 26 additions & 0 deletions spec/lib/critical_path_css/rails/config_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@
end
end

context 'when no paths are specified' do
let(:config_file) {
<<~CONFIG
defaults: &defaults
base_url: http://0.0.0.0:9292
manifest_name: application
routes:
- /
development:
<<: *defaults
test:
<<: *defaults
CONFIG
}

it 'sets css_path with the path' do
expect(subject.config['css_path']).to eq '/stylesheets/application.css'
end

it 'leaves css_paths empty' do
expect(subject.config['css_paths']).to eq []
end
end

context 'when single css_path and multiple css_paths are both specified' do
let(:config_file) {
<<~CONFIG
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require 'capybara/rails'

RSpec.configure do |config|
config.include Capybara::DSL

config.use_transactional_fixtures = true

# Enable flags like --only-failures and --next-failure
Expand Down

0 comments on commit c5ebdc1

Please sign in to comment.