Skip to content

Commit

Permalink
Move all spec support files into spec/support
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Mar 12, 2010
1 parent e346123 commit 8db90ba
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,6 +1,6 @@
coverage/* coverage/*
config/database.yml config/database.yml
spec/fixtures/*database* spec/support/fixtures/*database*
*.DS_Store *.DS_Store
debug.log debug.log
pkg pkg
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -28,8 +28,8 @@ else
t.libs << "#{File.dirname(__FILE__)}/spec" t.libs << "#{File.dirname(__FILE__)}/spec"
# t.warning = true # t.warning = true
t.spec_files = t.spec_files =
["spec/connections/#{adapter}_connection.rb"] + ["spec/support/connections/#{adapter}_connection.rb"] +
["spec/schemas/#{adapter}_schema.rb"] + ["spec/support/schemas/#{adapter}_schema.rb"] +
FileList['spec/**/*_spec.rb'] FileList['spec/**/*_spec.rb']
end end
end end
Expand Down
Binary file added spec/spec/fixtures/fixture_database.sqlite3
Binary file not shown.
44 changes: 4 additions & 40 deletions spec/spec_helper.rb
Expand Up @@ -7,44 +7,8 @@
require 'fileutils' require 'fileutils'
require 'arel' require 'arel'


[:matchers, :doubles].each do |helper| Dir["#{dir}/support/*.rb"].each do |file|
Dir["#{dir}/#{helper}/*"].each { |m| require "#{dir}/#{helper}/#{File.basename(m)}" } require file
end

module AdapterGuards
def adapter_is(*names)
names = names.map(&:to_s)
names.each{|name| verify_adapter_name(name)}
yield if names.include? adapter_name
end

def adapter_is_not(*names)
names = names.map(&:to_s)
names.each{|name| verify_adapter_name(name)}
yield unless names.include? adapter_name
end

def adapter_name
name = ActiveRecord::Base.configurations["unit"][:adapter]
name = 'oracle' if name == 'oracle_enhanced'
verify_adapter_name(name)
name
end

def verify_adapter_name(name)
raise "Invalid adapter name: #{name}" unless valid_adapters.include?(name.to_s)
end

def valid_adapters
%w[mysql postgresql sqlite3 oracle]
end
end

module Check
# This is used to eliminate Ruby warnings on some RSpec assertion lines
# See: https://rspec.lighthouseapp.com/projects/5645/tickets/504
def check(*args)
end
end end


Spec::Runner.configure do |config| Spec::Runner.configure do |config|
Expand All @@ -59,6 +23,6 @@ def check(*args)


# load corresponding adapter using ADAPTER environment variable when running single *_spec.rb file # load corresponding adapter using ADAPTER environment variable when running single *_spec.rb file
if adapter = ENV['ADAPTER'] if adapter = ENV['ADAPTER']
require "#{dir}/connections/#{adapter}_connection.rb" require "#{dir}/support/connections/#{adapter}_connection.rb"
require "#{dir}/schemas/#{adapter}_schema.rb" require "#{dir}/support/schemas/#{adapter}_schema.rb"
end end
6 changes: 6 additions & 0 deletions spec/support/check.rb
@@ -0,0 +1,6 @@
module Check
# This is used to eliminate Ruby warnings on some RSpec assertion lines
# See: https://rspec.lighthouseapp.com/projects/5645/tickets/504
def check(*args)
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -4,7 +4,7 @@


ActiveRecord::Base.logger = Logger.new("debug.log") ActiveRecord::Base.logger = Logger.new("debug.log")


db_file = "spec/fixtures/fixture_database.sqlite3" db_file = "spec/support/fixtures/fixture_database.sqlite3"


ActiveRecord::Base.configurations = { ActiveRecord::Base.configurations = {
"unit" => { "unit" => {
Expand Down
1 change: 1 addition & 0 deletions spec/support/doubles.rb
@@ -0,0 +1 @@
require "support/doubles/hash"
File renamed without changes.
28 changes: 28 additions & 0 deletions spec/support/guards.rb
@@ -0,0 +1,28 @@
module AdapterGuards
def adapter_is(*names)
names = names.map(&:to_s)
names.each{|name| verify_adapter_name(name)}
yield if names.include? adapter_name
end

def adapter_is_not(*names)
names = names.map(&:to_s)
names.each{|name| verify_adapter_name(name)}
yield unless names.include? adapter_name
end

def adapter_name
name = ActiveRecord::Base.configurations["unit"][:adapter]
name = 'oracle' if name == 'oracle_enhanced'
verify_adapter_name(name)
name
end

def verify_adapter_name(name)
raise "Invalid adapter name: #{name}" unless valid_adapters.include?(name.to_s)
end

def valid_adapters
%w[mysql postgresql sqlite3 oracle]
end
end
3 changes: 3 additions & 0 deletions spec/support/matchers.rb
@@ -0,0 +1,3 @@
require "support/matchers/be_like"
require "support/matchers/disambiguate_attributes"
require "support/matchers/hash_the_same_as"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8db90ba

Please sign in to comment.