APIDeveloperUserRelease NotesDemoContact Us
  • Core

    • Addresses
    • Adjustments
    • Calculators
    • Inventory
    • Orders
    • Payments
    • Preferences
    • Products
    • Promotions
    • Shipments
    • Taxation
  • Customization

    • Storefront Customization
    • View Customization
    • Asset Customization
    • Images Customization
    • Dependency system
    • Logic Customization
    • Checkout Flow
    • API v2 Customization
    • API v1 Customization
    • Custom Authentication
    • Internationalization
    • Extensions
    • Emails Customization
  • Source

    • About the Code
    • Getting Help
    • Navigating the Source
  • Tutorials

    • Getting Started
    • Add Spree to an existing Ruby on Rails application
    • Developing Spree
    • Improve SEO
    • Creating an Extension
    • Deface Overrides
    • Extend Product Attributes
    • Security
    • Testing Spree Applications
    • Updating Extensions to Rails 6 and Spree 4
  • Upgrades

    • Upgrading Spree 4.1 to 4.2
    • Upgrading Spree 4.0 to 4.1
    • Upgrading Spree 3.7 to 4.0
    • Upgrading Spree from 3.6 to 3.7
    • Upgrading Spree from 3.5 to 3.6
    • Upgrading Spree from 3.4 to 3.5
    • Upgrading Spree from 3.3 to 3.4
    • Upgrading Spree from 3.2 to 3.3
    • Upgrading Spree from 3.1 to 3.2
    • Upgrading Spree from 3.0 to 3.1
    • All Upgrade Guides

Table Of Contents

OverviewSetup locallyFix Bundle errors on MacOSSandboxPerformance in development modeRunning TestsRunning integration tests on MacOS

Developing Spree

Overview

Spree is meant to be run within the context of Rails application and the source code is essentially a collection of gems. You can easily create a sandbox application inside of your cloned source directory for testing purposes.

Setup locally

Clone the Git repo

git clone git://github.com/spree/spree.git
cd spree

Install the gem dependencies

bundle install

Fix Bundle errors on MacOS

If bundle install fails that means you’re missing some required system libraries.

Firstly, please install homebew. With homebrew installed you will need to install some packages needed to run Spree and Rails applications in general:

brew install openssl mysql postgresql sqlite imagemagick

Sandbox

Create a sandbox Rails application for testing purposes which automatically performs all necessary database setup

bundle exec rake sandbox

Start the server

cd sandbox
bundle exec rails s

Performance in development mode

You may notice that your Spree store runs slower in development environment. This can be because in development each asset (css and javascript) is loaded separately. You can disable it by adding the following line to config/environments/development.rb.

config.assets.debug = false

Also in development caching is disabled by default. To turn on caching run:

bundle exec rails dev:cache

You will need to restart rails server after this change.

Running Tests

We use CircleCI to run the tests for Spree.

You can see the build statuses at https://circleci.com/gh/spree/spree.

Each gem contains its own series of tests, and for each directory, you need to do a quick one-time creation of a test application and then you can use it to run the tests. For example, to run the tests for the core project.

cd core
BUNDLE_GEMFILE=../Gemfile bundle exec rake test_app
bundle exec rspec spec

If you would like to run specs against a particular database you may specify the dummy app’s database, which defaults to sqlite3.

DB=postgres BUNDLE_GEMFILE=../Gemfile bundle exec rake test_app

If you want to run specs for only a single spec file

cd core
bundle exec rspec spec/models/spree/state_spec.rb

If you want to run a particular line of spec

cd core
bundle exec rspec spec/models/spree/state_spec.rb:7

Running integration tests on MacOS

We use chromedriver to run integration tests. To install it please use this command:

brew cask install chromedriver
Propose changes to this page
Designed and developed bySpree Commerce & Ruby on Rails developers© Spree Commerce. 2021 All Rights Reserved.