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
Testing Spree Stores and Extensions - M. Scott Ford
Search
spreeconf
August 22, 2012
Programming
1
400
Testing Spree Stores and Extensions - M. Scott Ford
spreeconf
August 22, 2012
Tweet
Share
More Decks by spreeconf
See All by spreeconf
Capitalizing on the Micro-preneur Revolution - Eric Koester
spreeconf
0
150
Design Patterns of Successful eCommerce Companies - Adil Wali
spreeconf
0
640
The Magic Tricks of Testing - Sandi Metz
spreeconf
0
240
Evolving Open Source - Yehuda Katz
spreeconf
2
250
Enterprise Spree - Daniel Honig
spreeconf
1
630
Scaling an eCommerce Business - Adil Wali
spreeconf
1
530
Other Decks in Programming
See All in Programming
雑に思考を整理する技術と効能
konifar
60
29k
新宿ダンジョンを可視化してみた
satoshi7190
2
270
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
770
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
830
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
110
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
130
Git Lint
bkuhlmann
4
750
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
280
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
350
GitHub Copilotのススメ
marcy731
1
200
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
260
Apache Hive 4 on Treasure Data
ryukobayashi
0
350
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
190k
The Pragmatic Product Professional
lauravandoore
25
5.8k
Producing Creativity
orderedlist
PRO
337
39k
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
Raft: Consensus for Rubyists
vanstee
132
6.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Navigating Team Friction
lara
178
13k
How STYLIGHT went responsive
nonsquared
92
4.8k
Code Review Best Practice
trishagee
55
15k
jQuery: Nuts, Bolts and Bling
dougneiner
59
7.1k
Visualization
eitanlees
136
14k
Transcript
Testing Spree Stores and Extensions M. Scott Ford Software Engineer
Cardagin Networks
About me
None
0:23
None
If my code failed people could die
Structure of the talk Four parts: 1. Why test? 2.
Testing best practices 3. Testing Spree stores 4. Testing Spree extensions
Why Test?
Why is Testing Important?
Safety Critical vs. Mission Critical
Safety Critical If my code fails, people could die.
Safety Critical Aircraft and Spacecraft
Safety Critical Emergency Response Systems
Safety Critical Passenger Rail
Mission Critical If my code fails, business is impacted.
Mission Critical Mars Science Lab Landing
Mission Critical Stock Trading Software
Mission Critical E-Commerce
Why Don't We Test More Often?
Why don't we test more often? "Testing is frustrating."
Why don't we test more often? "I don't see the
benefit"
Why don't we test more often? "I don't have time"
Why Test? Summary Why is Testing Important? Safety critical vs.
Mission critical Why Don't We Test More Often?
Best Practices
Test First vs. Test Last
Different Levels of Testing These are the kinds of tests
that this talk is going to cover Acceptance Integration Unit
Other Kinds of Tests These tests are important, but we
don’t have enough time to go into them here. Security Performance Exploratory
Properties of a Good Test Reads like a story (beginning,
middle, and end) Easy to read and understand what’s being tested
Tool Choice Cucumber vs. RSpec vs. Test::Unit vs. others
Tips for Consultants Don’t list testing as on giant line
item in your estimate Don’t make testing optional Let your client's risk tolerance dictate how much you test
Best Practices Summary Test first vs. test last Properties of
a good test Different levels of testing Tool choice Tips for consultants
Testing Spree Stores http://github/mscottford/sample-store
Getting Started Create a new spree store project with RSpec
and Capybara http://github.com/mscottford/sample-store branch: master
Create a Rails App $ gem install rails -v 3.2.8
$ rails _3.2.8_ new sample-store --skip-test- unit
Add Spree $ echo "gem 'spree', '~> 1.1.0'" >> Gemfile
$ bundle update $ rails g spree:install $ echo "/public/spree" >> .gitignore
Add RSpec and Capybara Gemfile: group :test do gem 'rspec-rails'
gem 'capybara' gem 'database_cleaner' gem 'factory_girl' gem 'faker' end
Add RSpec and Capybara $ bundle update $ rails g
rspec:install
Configure RSpec Add to spec_helper.rb, right before RSpec.configure: require 'database_cleaner'
require 'spree/core/testing_suppo rt/factories' require 'spree/core/testing_suppo rt/env' require 'spree/core/testing_suppo rt/controller_requests' require 'spree/core/url_helpers'
Configure RSpec In spec_helper.rb, change: config.use_transactional_ fixtures = true to:
config.use_transactional_ fixtures = false
Configure RSpec In spec_helper.rb inside RSpec.configure block, add: config.before(:each) do
if example.metadata[:js] DatabaseCleaner.strateg y = :truncation, { :except => [ 'spree_countries', 'spree_zones', 'spree_zone_members', 'spree_states', 'spree_roles' ]} else
Configure RSpec In spec_helper.rb inside RSpec.configure block, add: config.before(:each) do
DatabaseCleaner.start end config.after(:each) do DatabaseCleaner.clean end
Configure RSpec In spec_helper.rb inside RSpec.configure block, add: config.include FactoryGirl::Syntax::Meth
ods config.include Spree::Core::UrlHelpers config.include Spree::Core::TestingSup port::ControllerRequests
A simple test to make sure it's working spec/requests/home_spec.rb: require
'spec_helper' describe 'home' do it 'should load home page' do visit '/' page.should have_content('Home') end end $ bundle exec rake db:test:prepare $ be rspec
Writing an Acceptance Test Example scenario: related products
Demo http://github.com/mscottford/sample-store branch: acceptance-test
Writing an Integration Test Example scenario: Adding a method to
Spree::Product.
Demo http://github.com/mscottford/sample-store branch: integration-test
Writing a unit test Example scenario: Adding a helper method
Testing Spree Stores Summary http://github.com/mscottford/sample-store Getting started - branch: master
Acceptance test - branch: acceptance-test Integration test - branch: integration-test Unit test - branch: unit-test
Testing Spree Extensions http://github.com/mscottford/spree_sample_extension
Getting Started http://github.com/mscottford/spree_sample_extension branch: master $ gem install spree_cmd $
spree extension sample_extension
Writing an Acceptance Test Scenario: Special Pricing
Demo http://github.com/mscottford/spree_sample_extension branch: acceptance-test
Writing an Integration Test Scenario: Special pricing for select products
Demo http://github.com/mscottford/spree_sample_extension branch: integration-test
Writing a unit test Scenario: Adding a helper to remove
duplication
Demo http://github.com/mscottford/spree_sample_extension branch: unit-test
Testing Spree Extensions Summary http://github.com/mscottford/spree_sample_extension Getting started - branch: master
Acceptance test - branch: acceptance-test Integration test - branch: integration-test Unit test - branch: unit-test
Testing Spree Stores and Extensions Summary Why Test? Best Practices
Testing Spree Stores Testing Spree Extensions
Additional resources Read the Spree RSpec tests http://github.com/spree/spree Developing Spree
Extension with TDD http://nebulab.it/en/nebulog/developing-spree- extension-with-tdd
Additional resources Presentation http://github.com/mscottford/testing-spree-stores- and-extensions Sample Store code http://github.com/mscottford/sample-store Sample
Extension code http://github.com/mscottford/spree_sample_extension
Contact info email:
[email protected]
github: mscottford twitter: @mscottford blog: http://mscottford.com
Questions?