Skip to content

Instantly share code, notes, and snippets.

@nandosola
Created March 26, 2013 16:12
Show Gist options
  • Save nandosola/5246704 to your computer and use it in GitHub Desktop.
Save nandosola/5246704 to your computer and use it in GitHub Desktop.
Ejemplo para RSpec
source 'http://rubygems.org'
gem 'sinatra', '1.3.6'
gem 'json', '1.7.7'
gem 'haml', '3.1.7'
gem 'mongoid', '3.1.2'
gem 'bcrypt-ruby', '3.0.1'
gem 'rest-client', '1.6.7'
gem 'stringex', '1.5.1'
gem 'vlad', :require => false
gem 'vlad-hg', :require => false
# Include when vlad's jruby support is fixed
#gem 'torquebox-rake-support', '2.3.0', :require => false
group :test do
gem 'ci_reporter'
gem 'rspec'
gem 'rack-test'
end
@nandosola
Copy link
Author

Este sería el Rakefile

# encoding: utf-8
require 'rubygems'
require 'bundler'
Bundler.setup(:default)
begin
  require 'vlad'
  Vlad.load(:app=>nil,:scm=>:mercurial)
rescue LoadError
  puts 'Could not load Vlad'
end
# Require when vlad's jruby support is fixed
# require 'torquebox-rake-support'

desc 'Run specs'
task :spec do
  Bundler.setup(:test)
  require 'rspec/core/rake_task'
  require 'ci/reporter/rake/rspec'
  RSpec::Core::RakeTask.new('spec') do |t|
    t.rspec_opts = %w{--colour --format CI::Reporter::RSpec}
    t.pattern = FileList['spec/spec_base.rb']
  end
end

@nandosola
Copy link
Author

Y éste spec/spec_base.rb

# encoding: utf-8
require 'rspec'
require 'rack/test'
require 'yaml'

ENV['RACK_ENV'] ||= 'test'
CONFIG = YAML.load_file(File.join('config', 'settings.yml'))[ENV['RACK_ENV']]
APP_ROOT = File.join(File.dirname(__FILE__), '..')
CONFIG.freeze; APP_ROOT.freeze

RSpec.configure do |conf|
  conf.include Rack::Test::Methods
end

Dir[ "#{File.dirname(__FILE__)}/*_spec.rb" ].each do |path|
   require path
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment