Skip to content

Commit

Permalink
Merge pull request #5 from nebulab/rails-6
Browse files Browse the repository at this point in the history
Add support for Rails 6
  • Loading branch information
aldesantis authored Jan 16, 2020
2 parents 746ea33 + 0e46de3 commit 2564210
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 51 deletions.
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ jobs:
- checkout
- restore_cache:
keys:
- renderful-v1-{{ .Branch }}-{{ .Revision }}
- renderful-v1-{{ .Branch }}
- renderful-v1-
- run:
name: Bundle Install
command: bundle check || bundle install
- save_cache:
key: renderful-v1-{{ .Branch }}
key: renderful-v1-{{ .Branch }}-{{ .Revision }}
paths:
- vendor/bundle

Expand All @@ -29,12 +30,11 @@ jobs:
- checkout
- restore_cache:
keys:
- renderful-v1-{{ .Branch }}
- renderful-v1-
- renderful-v1-{{ .Branch }}-{{ .Revision }}
- run:
name: Run RSpec
command: |
bundle exec rspec --profile 10 \
bundle exec appraisal rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
Expand All @@ -51,8 +51,7 @@ jobs:
- checkout
- restore_cache:
keys:
- renderful-v1-{{ .Branch }}
- renderful-v1-
- renderful-v1-{{ .Branch }}-{{ .Revision }}
- run:
name: Run RuboCop
command: bundle exec rubocop
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.rspec_status
Gemfile.lock
gemfiles/*.lock
9 changes: 9 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

appraise 'rails-5-2' do
gem 'rails', '~> 5.2.0'
end

appraise 'rails-6-0' do
gem 'rails', '~> 6.0.0'
end
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added support for Rails 6

### Fixed

- Fixed linked entries not being invalidated ([5325981](https://github.com/nebulab/renderful/commit/5325981b6ed093407712e16e9937d86f92cdbab0))
Expand Down
9 changes: 9 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "rubygems"
require "bundler"

Bundler.require :default, :development

Combustion.initialize! :all
run Combustion::Application
9 changes: 9 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 5.2.0"

gemspec path: "../"
9 changes: 9 additions & 0 deletions gemfiles/rails_6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0.0"

gemspec path: "../"
6 changes: 4 additions & 2 deletions renderful.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'contentful', '~> 2.11'
spec.add_dependency 'rails', '~> 5.0'
spec.add_dependency 'rails', ['>= 5.0.0', '< 7']

spec.add_development_dependency 'appraisal', '~> 2.2'
spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'combustion', '~> 1.1'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'redis', '~> 4.1'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec-rails', '~> 4.0.0.beta4'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
spec.add_development_dependency 'rubocop', '~> 0.79.0'
spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
Expand Down
Empty file.
1 change: 1 addition & 0 deletions spec/internal/app/views/renderful/_test_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_local is <%= test_local %>
3 changes: 3 additions & 0 deletions spec/internal/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
adapter: sqlite3
database: db/combustion_test.sqlite
5 changes: 5 additions & 0 deletions spec/internal/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

Rails.application.routes.draw do
# Add your own routes here, or remove this file if you don't have need for it.
end
1 change: 1 addition & 0 deletions spec/internal/log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
Empty file.
42 changes: 2 additions & 40 deletions spec/renderful/renderer/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

require 'spec_helper'

require 'action_controller'

RSpec.describe Renderful::Renderer::Rails do
subject(:renderer) do
TestComponentRenderer.new(entry, client: client)
Expand All @@ -12,8 +10,6 @@
let(:entry) { OpenStruct.new(content_type: OpenStruct.new(id: 'testComponent')) }
let(:client) { instance_double('Renderful::Client') }

let(:rails_renderer) { instance_spy('ActionController::Renderer') }

before(:all) do
TestComponentRenderer = Class.new(described_class) do
def locals
Expand All @@ -22,45 +18,11 @@ def locals
end
end

before { allow(ActionController::Base).to receive(:renderer).and_return(rails_renderer) }

describe '#render' do
it 'returns the output from the ActionController renderer' do
allow(rails_renderer).to receive(:render).and_return('render_output')

it 'renders the correct partial' do
result = renderer.render

expect(result).to eq('render_output')
end

it 'infers the correct component view' do
renderer.render

expect(rails_renderer).to have_received(:render).with(a_hash_including(
partial: 'renderful/test_component',
))
end

it 'passes locals to the view' do
renderer.render

expect(rails_renderer).to have_received(:render).with(a_hash_including(
locals: a_hash_including(
test_local: 'local_value',
),
))
end

it 'passes the entry, renderer and client to the view' do
renderer.render

expect(rails_renderer).to have_received(:render).with(a_hash_including(
locals: a_hash_including(
entry: entry,
renderer: renderer,
client: client,
),
))
expect(result.strip).to eq('test_local is local_value')
end
end
end
9 changes: 6 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# frozen_string_literal: true

require "bundler/setup"
require "renderful"
require 'combustion'
Combustion.initialize! :action_controller, :action_view, :sprockets

require 'rspec/rails'
require 'renderful'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
config.example_status_persistence_file_path = '.rspec_status'

# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
Expand Down

0 comments on commit 2564210

Please sign in to comment.