Skip to content

Commit

Permalink
Updated testing guide.
Browse files Browse the repository at this point in the history
* Added ruby tags for ruby codes instead of shell tags.
* Unfortunately spec/spec/config/environment.rb did not exist..
* Added note about running the steps inside your extension and not from your project's root and warning about rake.
  • Loading branch information
parndt committed May 30, 2012
1 parent 50d204b commit 8c0fa1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'

if File.exist?(dummy_path = File.expand_path('../spec/dummy/config/environment.rb', __FILE__))
if File.exist?(dummy_path = File.expand_path('../dummy/config/environment.rb', __FILE__))
require dummy_path
elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
# Require the path to the refinerycms application this is vendored inside.
require File.expand_path('../../../../../config/environment', __FILE__)
else
raise "Could not find a config/environment.rb file to require. Please specify this in spec/spec_helper.rb"
raise "Could not find a config/environment.rb file to require. Please specify this in #{File.expand_path(__FILE__)}"
end

require 'rspec/rails'
Expand Down
32 changes: 16 additions & 16 deletions doc/guides/4 - Refinery Extensions/3 - Testing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,46 @@ endprologue.

h3. Bootstrap the test environment

NOTE: Make sure you perform all of the following steps from within your extension's directory.

In your extension's Gemfile uncomment or add the following line

<shell>
<ruby>
gem 'refinerycms-testing'
</shell>
</ruby>

And run

<shell>
<ruby>
$ bundle install
</shell>
</ruby>

Now we will configure our test environment by preparing a dummy refinerycms app

Add the following lines to your extension's Rakefile

<ruby>
ENGINE_PATH = File.dirname(__FILE__)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
ENGINE_PATH = File.dirname(__FILE__)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)

if File.exists?(APP_RAKEFILE)
load 'rails/tasks/extension.rake'
end
load 'rails/tasks/extension.rake' if File.exists?(APP_RAKEFILE)

require "refinerycms-testing"
Refinery::Testing::Railtie.load_tasks
require "refinerycms-testing"
Refinery::Testing::Railtie.load_tasks
</ruby>

And run the dummy application generator
And run the dummy application generator:

<shell>
$ bundle exec rake refinery:testing:dummy_app
</shell>

h3. Running the tests with Rake
NOTE: To succesfully run rake tasks within your project you may need to add the +refinerycms-testing+ gem to your application's Gemfile, too.

At your project's root run:
h3. Running the tests with Rake

<shell>
$ bundle exec rake
$ bundle exec rake spec
</shell>

This will run the rspec specs.
Expand All @@ -62,7 +62,7 @@ h3. Running the tests with Guard

We recommend using Guard if you like to develop using TDD. Guard will watch your project for changes in files. If a change is made to a spec or a file that is tested against, it will re-run only the necessary specs. This is a faster way to get feedback during your TDD cycles.

At your project's root run:
At your extension's root directory run:

<shell>
$ bundle exec guard start
Expand Down

0 comments on commit 8c0fa1c

Please sign in to comment.