Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add basic testing suite
  • Loading branch information
michael-misshore committed Jan 6, 2018
commit d294837bd3ff75a227a810f52530d9b8dfb0adb2
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ group :development, :test do
gem 'byebug', platform: [:ruby], require: false
gem 'rubocop', require: false
gem 'rspec-rails', '~> 3.6'
gem 'capybara', '~> 2.16'
gem 'pry-rails'
end

# HACK: npm install on bundle
Expand Down
1 change: 1 addition & 0 deletions app_container_name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
criticalpathcss_ruby
5 changes: 2 additions & 3 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'rubygems'
require 'bundler'
require 'combustion'

Bundler.require :default, :development

Combustion.initialize! :all
Combustion.initialize! :action_controller, :action_view
run Combustion::Application
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ services:
build:
context: .
dockerfile: docker/ruby/Dockerfile
ports:
- 9292:9292
volumes:
- .:/app:rw
volumes_from:
- data
env_file: docker/ruby/.env
container_name: criticalpathcss_ruby

data:
build:
context: .
Expand Down
2 changes: 1 addition & 1 deletion docker/ruby/startup.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

bundle check || bundle install

tail -f /dev/null
bundle exec rackup --host 0.0.0.0
3 changes: 3 additions & 0 deletions spec/internal/app/controllers/root_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class RootController < ActionController::Base
def index; end
end
4 changes: 4 additions & 0 deletions spec/internal/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<html>
<head></head>
<body><%= yield %></body>
</html>
1 change: 1 addition & 0 deletions spec/internal/app/views/root/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p><%= CriticalPathCss.fetch(request.path) %></p>
11 changes: 11 additions & 0 deletions spec/internal/config/critical_path_css.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defaults: &defaults
base_url: http://0.0.0.0:9292
css_path: /test.css
routes:
- /

development:
<<: *defaults

test:
<<: *defaults
2 changes: 1 addition & 1 deletion spec/internal/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Rails.application.routes.draw do
#
root 'root#index'
end
3 changes: 3 additions & 0 deletions spec/internal/public/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
p {
color: red;
}
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Combustion.initialize! :action_controller, :action_view

require 'rspec/rails'
require 'capybara/rails'

RSpec.configure do |config|
config.use_transactional_fixtures = true
Expand Down
16 changes: 16 additions & 0 deletions spec/system/fetch_critical_css_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper.rb'

RSpec.describe 'fetching the critical css' do
before do
CriticalPathCss.generate_all
end

context 'on the root page' do
let(:route) { '/' }

it 'displays the correct critical CSS' do
visit route
expect(page).to have_content 'color: red;'
end
end
end