Skip to content
Browse files

Sinatra specs passing, added spec/run for convenience

  • Loading branch information...
1 parent 2fc35bb commit d95c6b68faeb3f47db0dc583d0c1e0095f4898bc @winton committed Jan 2, 2011
View
3 config/externals.yml
@@ -4,6 +4,9 @@ active_wrapper-solo:
also_migrate:
repo: git@github.com:winton/also_migrate.git
path: vendor
+framework_fixture:
+ repo: git@github.com:winton/framework_fixture.git
+ path: vendor
mover:
repo: git@github.com:winton/mover.git
path: vendor
View
4 spec/acts_as_archive_spec.rb
@@ -25,8 +25,8 @@
end
end
-if FrameworkFixture.rails
- describe "Rails #{FrameworkFixture.rails}" do
+if FrameworkFixture.framework
+ describe "#{FrameworkFixture.framework} #{FrameworkFixture.exact_version}" do
include Rack::Test::Methods
View
36 spec/fixtures/frameworks.yml
@@ -1,15 +1,13 @@
rails:
<3:
- config:
- - config/database.yml
frameworks/rails2:
- app/controllers/application_controller.rb
- config/database.yml
- config/routes.rb
- vendor/plugins/plugin/rails/init.rb
- helpers:
+ helpers: &h
- app/helpers/spec_helper.rb
- models:
+ models: &m
- app/models/belongs_to.rb
- app/models/has_many.rb
- app/models/has_many_through.rb
@@ -24,21 +22,15 @@ rails:
- config/database.yml
- config/routes.rb
- Gemfile
- helpers:
- - app/helpers/spec_helper.rb
- models:
- - app/models/belongs_to.rb
- - app/models/has_many.rb
- - app/models/has_many_through.rb
- - app/models/has_many_through_through.rb
- - app/models/has_one.rb
- - app/models/has_one_through.rb
- - app/models/has_one_through_through.rb
- - app/models/record.rb
-# sinatra:
-# <1:
-# frameworks/sinatra:
-# - application.rb
-# <2:
-# frameworks/sinatra:
-# - application.rb
+ helpers: *h
+ models: *m
+sinatra:
+ <1:
+ frameworks/sinatra: &s
+ - application.rb
+ helpers: *h
+ models: *m
+ <2:
+ frameworks/sinatra: *s
+ helpers: *h
+ models: *m
View
3 spec/fixtures/frameworks/rails3/Gemfile
@@ -1,12 +1,11 @@
source 'http://rubygems.org'
+gem 'mysql2'
gem 'rails', '3.0.3'
gem 'rspec'
gem 'acts_as_archive', :path => "../../../../"
-gem 'mysql2', :require => 'mysql2'
-
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
View
26 spec/fixtures/frameworks/sinatra/application.rb
@@ -1,14 +1,34 @@
require 'sinatra/base'
-require 'smart_asset'
+require "#{$root}/lib/acts_as_archive"
class Application < Sinatra::Base
set :app_file, __FILE__
- set :views, File.dirname(__FILE__)
+ set :dump_errors, true
+ set :raise_errors, true
+ set :show_exceptions, false
- include SmartAsset::Adapters::Sinatra
+ include SpecHelper
get '/pulse' do
'1'
end
+
+ get "/should_create_records_action" do
+ before_each false, true
+ should_create_records
+ '1'
+ end
+
+ get "/should_move_records_back_to_original_tables_action" do
+ before_each false, true
+ should_move_records_back_to_original_tables
+ '1'
+ end
+
+ get "/should_move_records_to_archive_tables_action" do
+ before_each false, true
+ should_move_records_to_archive_tables(params[:type])
+ '1'
+ end
end
View
27 spec/run
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+
+system "spec -f n -c spec"
+
+puts "\n"
+
+ENV['ACTIVERECORD'] = '2'
+system "spec -f n -c spec/acts_as_archive_spec.rb"
+
+ENV.delete 'ACTIVERECORD'
+
+puts "\n"
+
+ENV['RAILS'] = '2'
+system "spec -f n -c spec/acts_as_archive_spec.rb"
+
+puts "\n"
+
+ENV['RAILS'] = '3'
+system "spec -f n -c spec/acts_as_archive_spec.rb"
+
+ENV.delete 'RAILS'
+
+puts "\n"
+
+ENV['SINATRA'] = '1'
+system "spec -f n -c spec/acts_as_archive_spec.rb"
View
18 spec/spec_helper.rb
@@ -4,21 +4,31 @@
require "#{$root}/lib/acts_as_archive/gems"
ActsAsArchive::Gems.activate :framework_fixture
-
require 'framework_fixture'
-FrameworkFixture.generate File.dirname(__FILE__) + '/fixtures'
+
+if FrameworkFixture.framework == 'rails'
+ FrameworkFixture.generate File.dirname(__FILE__) + '/fixtures'
+end
ActsAsArchive::Gems.activate %w(active_wrapper-solo rack-test rspec)
require 'active_wrapper/gems'
+# Framework specs
if FrameworkFixture.framework
require 'rack/test'
if FrameworkFixture.rails == '<3'
ActiveWrapper::Gems.gemset = :ar2
+ elsif FrameworkFixture.sinatra
+ ActiveWrapper::Gems.activate %w(activesupport)
+ require 'active_support/dependencies'
+ ActiveSupport::Dependencies.autoload_paths << "#{$root}/spec/fixtures/builds/sinatra#{ENV['SINATRA']}/app/models"
+ ActiveSupport::Dependencies.autoload_paths << "#{$root}/spec/fixtures/builds/sinatra#{ENV['SINATRA']}/app/helpers"
end
require 'active_wrapper'
+
+# Normal specs
else
if ENV['ACTIVERECORD'] == '2'
ActiveWrapper::Gems.gemset = :ar2
@@ -44,6 +54,10 @@
)
$db.establish_connection
+if FrameworkFixture.framework == 'sinatra'
+ FrameworkFixture.generate File.dirname(__FILE__) + '/fixtures'
+end
+
Spec::Runner.configure do |config|
end

0 comments on commit d95c6b6

Please sign in to comment.
Something went wrong with that request. Please try again.