Permalink
Browse files

Rake support

  • Loading branch information...
1 parent d22f76c commit 77d99716728963ad761f9475a696724536237f95 @cavalle committed Mar 14, 2011
View
@@ -47,7 +47,7 @@ _NOTE: The latest version of Steak assumes that you're testing a Rails 3 applica
It's super-easy to get you started. Just add the gem to your `Gemfile`
- group 'test' do
+ group :test, :development do
gem 'steak'
# ...
View
@@ -1 +1,10 @@
-require 'capybara/rspec'
+require 'capybara/rspec'
+require 'rspec-rails'
+
+module Steak
+ class Railtie < ::Rails::Railtie
+ rake_tasks do
+ load "tasks/steak_tasks.rake"
+ end
+ end
+end
@@ -0,0 +1,6 @@
+namespace :spec do
+ desc "Run the acceptance specs in spec/acceptance"
+ RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t|
+ t.pattern = "spec/acceptance/**/*_spec.rb"
+ end
+end
@@ -10,7 +10,7 @@
generate_rails_project
append_to 'Gemfile', <<-GEMS
- group :test do
+ group :test, :development do
gem 'steak', :path => '#{root_path}'
end
GEMS
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+feature 'Rake support', %q{
+ In order to conveniently run my specs along with the rest of my test suite
+ As a Rails developer
+ I want rake support in Steak
+} do
+
+ background do
+ generate_rails_project_with_steak
+ create_file 'spec/unit_spec.rb', <<-RSPEC
+ require 'spec_helper'
+
+ describe Object do
+ it { should respond_to :to_s }
+ end
+ RSPEC
+ run 'rails g steak:spec my_spec'
+ run 'rake db:migrate'
+ end
+
+ scenario 'to run acceptance specs as part of the test suite' do
+ run 'rake spec'
+ output.should =~ /2 examples, 0 failures/
+
+ run 'rake'
+ output.should =~ /2 examples, 0 failures/
+ end
+
+ scenario 'to run only acceptance specs' do
+ run 'rake spec:acceptance'
+ output.should =~ /1 example, 0 failures/
+ end
+
+end
View
@@ -1,7 +1,7 @@
require 'rubygems'
require 'bundler/setup'
-require 'capybara/rspec'
-require 'active_support/all'
+require 'rails'
+require 'steak'
require 'support/helpers'
@@ -14,7 +14,7 @@ def generate_rails_project_with_steak
generate_rails_project
append_to 'Gemfile', <<-RUBY
- group(:test) do
+ group :test, :development do
gem 'steak', :path => '#{root_path}'
gem 'capybara', :path => '#{Bundler.load.specs['capybara'].first.full_gem_path}' # Totally temporal. It should be a steak dependency
end
@@ -28,6 +28,10 @@ def append_to(path, content)
rails_project_path.join(path).open('a') { |f| f.write content }
end
+ def create_file(path, content)
+ rails_project_path.join(path).open('w') { |f| f.write content }
+ end
+
def run(command)
self.output = Bundler.with_clean_env { `#{command} 2>&1` }

0 comments on commit 77d9971

Please sign in to comment.