Skip to content

Commit

Permalink
Separate Rails-specific specs into rails_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
arvicco committed Jul 16, 2012
1 parent a256ab5 commit 557745d
Show file tree
Hide file tree
Showing 44 changed files with 61 additions and 46 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.

describe 'Rails Controllers', :rails => true do
describe Ib::UnderlyingsController, :type => :controller do

# This should return the minimal set of attributes required to create a valid
Expand Down Expand Up @@ -168,3 +169,4 @@ def valid_session
end

end
end
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions spec/internal/db/schema.rb → rails_spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

ActiveRecord::Schema.define(:version => 171) do

create_table "bars", :force => true do |t|
create_table "ib_bars", :force => true do |t|
t.float "open"
t.float "high"
t.float "low"
Expand All @@ -26,7 +26,7 @@
t.datetime "updated_at", :null => false
end

create_table "combo_legs", :force => true do |t|
create_table "ib_combo_legs", :force => true do |t|
t.integer "combo_id"
t.integer "leg_contract_id"
t.integer "con_id"
Expand All @@ -41,7 +41,7 @@
t.datetime "updated_at", :null => false
end

create_table "contract_details", :force => true do |t|
create_table "ib_contract_details", :force => true do |t|
t.integer "contract_id"
t.string "market_name"
t.string "trading_class"
Expand Down Expand Up @@ -77,7 +77,7 @@
t.datetime "updated_at", :null => false
end

create_table "contracts", :force => true do |t|
create_table "ib_contracts", :force => true do |t|
t.integer "con_id"
t.string "sec_type", :limit => 5
t.float "strike"
Expand All @@ -98,7 +98,7 @@
t.datetime "updated_at", :null => false
end

create_table "executions", :force => true do |t|
create_table "ib_executions", :force => true do |t|
t.integer "order_id"
t.integer "local_id"
t.integer "client_id"
Expand All @@ -118,7 +118,7 @@
t.datetime "updated_at", :null => false
end

create_table "order_states", :force => true do |t|
create_table "ib_order_states", :force => true do |t|
t.integer "order_id"
t.integer "local_id"
t.integer "client_id"
Expand All @@ -142,7 +142,7 @@
t.datetime "updated_at", :null => false
end

create_table "orders", :force => true do |t|
create_table "ib_orders", :force => true do |t|
t.integer "contract_id"
t.integer "local_id"
t.integer "client_id"
Expand Down Expand Up @@ -233,7 +233,7 @@
t.datetime "updated_at", :null => false
end

create_table "underlyings", :force => true do |t|
create_table "ib_underlyings", :force => true do |t|
t.integer "contract_id"
t.integer "con_id"
t.float "delta"
Expand Down
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.
File renamed without changes.
9 changes: 3 additions & 6 deletions spec/r.rb → spec/comb.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
puts 'To run specs with Combustion-based Rails app, use:'
puts '$ rspec -rr spec/models'
puts '$ rspec -rcomb rails_spec'

require 'bundler/setup'
require 'combustion'
require 'backports/1.9.2' if RUBY_VERSION =~ /1.8/
require 'ib'

# Configure Rails Environment ?
# ENV["RAILS_ENV"] = "test"
Combustion.path = 'rails_spec/combustion'
Combustion.initialize!

require 'rspec/rails'
require 'yaml'
require 'pathname'
require 'database_cleaner'

13 changes: 13 additions & 0 deletions spec/dummy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
puts 'To run specs with dummy Rails app, use:'
puts '$ rspec -rdummy rails_spec'

# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require File.expand_path("../../rails_spec/dummy/config/environment.rb", __FILE__)

require 'rspec/rails'
require 'capybara/rails'
require 'capybara/dsl'

Rails.backtrace_cleaner.remove_silencers!
24 changes: 0 additions & 24 deletions spec/rr.rb

This file was deleted.

43 changes: 35 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
OPTS ||= {
:verbose => false, #true, # Run test suite in a verbose mode ?
:brokertron => false, # Use mock (Brokertron) instead of paper account ?
:db => IB.db_backed?,
:rails => IB.rails?
}

if OPTS[:brokertron]
Expand Down Expand Up @@ -35,6 +37,12 @@
pp OPTS

RSpec.configure do |config|
# config.filter = { :focus => true }
# config.include(UserExampleHelpers)
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

config.exclusion_filter = {
:if => proc do |condition|
t = Time.now.utc
Expand All @@ -50,19 +58,38 @@

:db => proc { |condition| IB.db_backed? != condition }, # true/false

:reuters => proc { |condition| !OPTS[:connection][:reuters] == condition } # true/false
:rails => proc { |condition| IB.rails? != condition }, # true/false

:reuters => proc { |condition| !OPTS[:connection][:reuters] == condition }, # true/false
}
# config.filter = { :focus => true }
# config.include(UserExampleHelpers)
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

if IB.db_backed?
puts "Database backed"
if OPTS[:db]
require 'database_cleaner'

config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
end

config.after(:suite) do
DatabaseCleaner.clean
end
end

if OPTS[:rails]
config.include IB::Engine.routes.url_helpers,
:example_group => {:file_path => /\brails_spec\//}

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 557745d

Please sign in to comment.