Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building Extensions - best practises
Search
Peter Berkenbosch
February 27, 2014
0
53
Building Extensions - best practises
SpreeConf 2014 Lightning talk.
Peter Berkenbosch
February 27, 2014
Tweet
Share
More Decks by Peter Berkenbosch
See All by Peter Berkenbosch
Open source contribution with Spree
pberkenbosch
1
190
Spree Commerce hub for developers
pberkenbosch
0
170
Behavior Driven Development, an introduction
pberkenbosch
1
48
TDD Spree
pberkenbosch
5
450
Twente RB Spree from the trenches
pberkenbosch
0
52
GroningenRB Spree from the trenches
pberkenbosch
0
110
Spree from the Trenches
pberkenbosch
3
320
[dutch] Behavior Driven Development
pberkenbosch
1
68
BDD Outside in development
pberkenbosch
1
150
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
YesSQL, Process and Tooling at Scale
rocio
169
14k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Optimizing for Happiness
mojombo
376
70k
Practical Orchestrator
shlominoach
186
10k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
Designing for humans not robots
tammielis
250
25k
RailsConf 2023
tenderlove
29
900
Transcript
Building Extensions best practises ! Peter Berkenbosch
Unix philosophy building short, simple, clear, modular, and extendable code
that can be easily maintained and repurposed by developers other than its creators.
Documentation
Modular
OOP
Extension as “Model”
Models Views Controllers Assets Overrides Rails::Engine Spree other 3rd party
gems extension
Looks familier! Rails anyone?!
Outside In
Models Views Controllers Assets Overrides Rails::Engine Spree other 3rd party
gems extension
Test the “interface” can be just an API
Drives Quality
Self documenting
gem install spree_cmd
spree extension
git clone spree
rake sandbox
spree extension
module SpreeSales! class Engine < Rails::Engine! require 'spree/core'! isolate_namespace Spree!
engine_name 'spree_sales'! ! # use rspec for tests! config.generators do |g|! g.test_framework :rspec! end! ! def self.activate! Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|! Rails.configuration.cache_classes ? require(c) : load(c)! end! end! ! config.to_prepare &method(:activate).to_proc! end! end
Spree Testing Support
Usual suspect rspec capybara factory_girl
# Requires factories defined in spree_core! require 'spree/testing_support/factories'! require 'spree/testing_support/controller_requests'!
require 'spree/testing_support/authorization_helpers'! require 'spree/testing_support/url_helpers'
Red - Green - Refacor Repeat
Nothing new. TDD / BDD …
Extending Spree
class_evil Looking at adding durable_decorator
Deface for small changes
override view file for the more complex customisations
Deface-able views ! for easy overriding the overrides.
github.com/spree/spree_ Inspiration and collaboration!