Skip to content

Commit

Permalink
[AM/ARCH] Simplified loading scheme for Remarkable::ActiveModel
Browse files Browse the repository at this point in the history
  • Loading branch information
hosh committed May 25, 2010
1 parent c5d6330 commit fb416df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
12 changes: 7 additions & 5 deletions path_helpers.rb
@@ -1,8 +1,10 @@
# encoding: utf-8

def load_project_path(project)
project = project.to_s
project_path = File.join(File.dirname(__FILE__), project, 'lib')
return nil if $LOAD_PATH.include?(File.expand_path(project_path))
$LOAD_PATH.unshift(File.expand_path(project_path))
def load_project_path(*projects)
projects.each do |project|
project = project.to_s
project_path = File.join(File.dirname(__FILE__), project, 'lib')
return nil if $LOAD_PATH.include?(File.expand_path(project_path))
$LOAD_PATH.unshift(File.expand_path(project_path))
end
end
24 changes: 5 additions & 19 deletions remarkable_activemodel/lib/remarkable/active_model.rb
@@ -1,28 +1,14 @@
# Load Remarkable
unless Object.const_defined?('Remarkable')
begin
require 'remarkable'
rescue LoadError
require 'rubygems'
gem 'remarkable'
require 'remarkable'
end
end
require 'remarkable'
require 'remarkable/active_model/base'

# Load Remarkable ActiveModel files
# Add default locale
dir = File.dirname(__FILE__)
require File.join(dir, 'active_model', 'base')

# Add locale
Remarkable.add_locale File.join(dir, '..', '..', 'locale', 'en.yml')
Dir["#{dir}/../../locale/*yml"].each {|f| Remarkable.add_locale(f) }

# Add matchers
Dir[File.join(dir, 'active_model', 'matchers', '*.rb')].each do |file|
require file
end

# By default, ActiveModel matchers are not included in any example group.
# The responsibility for this is RemarkableRails. If you are using ActiveModel
# without Rails, put the line below in your spec_helper to include ActiveModel
# matchers into rspec globally.
# Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Example::ExampleGroup)
Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup)
24 changes: 10 additions & 14 deletions remarkable_activemodel/spec/spec_helper.rb
@@ -1,26 +1,22 @@
# encoding: utf-8
require 'rubygems'
$TESTING=true

require 'rubygems'
require 'rspec'

RAILS_VERSION = ENV['RAILS_VERSION'] || '3.0.0.beta3'

gem 'activesupport', RAILS_VERSION
require 'active_support/all'

gem 'activemodel', RAILS_VERSION
require 'active_model'

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
require File.expand_path('path_helpers', File.join(File.dirname(__FILE__), '/../../'))
load_project_path :remarkable, :remarkable_activemodel

# Load Remarkable core on place to avoid gem to be loaded
dir = File.dirname(__FILE__)
require File.join(dir, '..', '..', 'remarkable', 'lib', 'remarkable')
require 'remarkable/active_model'

# Load Remarkable ActiveModel
require File.join(dir, '..', 'lib', 'remarkable_activemodel')
# Requires supporting files with custom matchers and macros, etc,
# # in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

# Include matchers
Remarkable.include_matchers!(Remarkable::ActiveModel, Rspec::Core::ExampleGroup)
# Load custom matchers
#Remarkable.include_matchers!(Remarkable::Rspec, Rspec::Core::ExampleGroup)

0 comments on commit fb416df

Please sign in to comment.