Skip to content

Commit

Permalink
Specs should pass with all supported options
Browse files Browse the repository at this point in the history
  • Loading branch information
arvicco committed Jul 16, 2012
1 parent 557745d commit 801081b
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -12,3 +12,5 @@ gem "jquery-rails"
gem 'sqlite3', '> 1.3.3', :platforms => [:ruby_18, :ruby_19] #:ruby
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2.2', :platforms => :jruby
gem 'jdbc-sqlite3', '>= 3.7.2', :platforms => :jruby

gem "backports"
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -43,6 +43,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.8)
arel (3.0.2)
backports (2.6.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
Expand Down Expand Up @@ -162,6 +163,7 @@ PLATFORMS

DEPENDENCIES
activerecord-jdbcsqlite3-adapter (>= 1.2.2)
backports
capybara
combustion
database_cleaner (>= 0.7.2)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/ib/application_controller.rb
@@ -1,4 +1,5 @@
module Ib
class ApplicationController < ::ApplicationController
class ApplicationController <
defined?(::ApplicationController) ? ::ApplicationController : ActionController::Base
end
end
7 changes: 6 additions & 1 deletion lib/ib.rb
Expand Up @@ -2,6 +2,11 @@ module IB
def self.db_backed?
!!defined?(IB::DB)
end

def self.rails?
!!defined?(Rails) && Rails.respond_to?('env')
end

end # module IB

IbRuby = IB
Expand All @@ -11,7 +16,7 @@ def self.db_backed?
# By default there is no DB backend, unless specifically requested
# require 'ib/db' # to make all IB models database-backed

if defined?(Rails) && Rails.respond_to?('env')
if IB.rails?
require 'ib/engine'
else
require 'ib/requires'
Expand Down
8 changes: 8 additions & 0 deletions lib/ib/base.rb
Expand Up @@ -53,6 +53,14 @@ def save

alias save! save

### Noop methods mocking ActiveRecord::Base macros

def self.attr_protected *args
end

def self.attr_accessible *args
end

### ActiveRecord::Base association API mocks

def self.belongs_to model, *args
Expand Down
2 changes: 0 additions & 2 deletions lib/ib/db.rb
Expand Up @@ -26,6 +26,4 @@ def self.connect config
end # module DB
end

# You may just require 'ib/db', it will then auto-require core 'ib' for you
require 'ib'

2 changes: 1 addition & 1 deletion lib/ib/engine.rb
@@ -1,6 +1,6 @@
module IB
class Engine < ::Rails::Engine
isolate_namespace IB
isolate_namespace Ib

#paths["app"] # => ["app"]
#paths["app/controllers"] # => ["app/controllers"]
Expand Down
2 changes: 1 addition & 1 deletion spec/my.rb
@@ -1,4 +1,4 @@
# My very specific connection configuration to run specs
# My very specific IB connection configuration to run the specs

ACCOUNT = 'DU118180'
HOST = '10.211.55.2'
Expand Down
16 changes: 4 additions & 12 deletions spec/spec_helper.rb
Expand Up @@ -33,10 +33,11 @@
}
end

puts 'Running specs with OPTS:'
pp OPTS

RSpec.configure do |config|

puts "Running specs '#{config.pattern}' with OPTS:"
pp OPTS

# config.filter = { :focus => true }
# config.include(UserExampleHelpers)
# config.mock_with :mocha
Expand Down Expand Up @@ -82,14 +83,5 @@

config.include Capybara::DSL,
:example_group => { :file_path => /\brails_spec\//}
else
# We need to prevent loading Rails-related spec files unless Rails support was required
# However, when spec_helper.rb is first required, we're already inside a
# config.load_spec_files cycle
p config.pattern
p config.files_to_run
config.files_to_run = config.files_to_run.reject {|path| path =~ /rails/}
p config.files_to_run

end
end

0 comments on commit 801081b

Please sign in to comment.