Sha256: d11ef4e6038bf2c3ea9464421a731ce50de60dd597f1ea99b7efbf8a4a215749

Contents?: true

Size: 1.8 KB

Versions: 23

Compression:

Stored size: 1.8 KB

Contents

require 'logger'
require 'rspec'
require 'factory_girl'

require 'active_record_survey'

require_relative '../spec/factories/active_record_survey/survey'

require 'database_cleaner'

# Trigger AR to initialize
ActiveRecord::Base

#ActiveRecord::Base.logger = Logger.new(STDOUT)

module Rails
  def self.root
    '.'
  end
end

# Add this directory so the ActiveSupport autoloading works
ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)

if RUBY_PLATFORM == 'java'
	ActiveRecord::Base.establish_connection :adapter => 'jdbcsqlite3', :database => ':memory:'
else
	ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
end

#ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
ActiveRecord::Migration.verbose = false

require "generators/active_record_survey/templates/migration_0.1.0"
require "generators/active_record_survey/templates/migration_0.1.26"

ActiveRecord::Schema.define do
	AddActiveRecordSurvey.up
	Update_0_1_26_ActiveRecordSurvey.up

	# Make it easier when you can put text on things
	add_column :active_record_survey_nodes, :text, :string
end

module ActiveRecordSurveyNodeMap
	def self.extended(base)
		base.instance_eval do
			include InstanceMethods
			alias_method_chain :as_map, :text
		end
	end

	module InstanceMethods
		def as_map_with_text(node_maps = nil)
			result = {
				"text" => self.node.text
 			}
			result = result.merge(as_map_without_text(node_maps))

			result
		end
	end
end
ActiveRecordSurvey::NodeMap.send(:extend, ActiveRecordSurveyNodeMap)

RSpec.configure do |config|
	config.include FactoryGirl::Syntax::Methods
	config.after(:each) do
	end

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

	config.expect_with :rspec do |c|
		c.syntax = :expect
	end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_record_survey-0.1.49 spec/spec_helper.rb
active_record_survey-0.1.48 spec/spec_helper.rb
active_record_survey-0.1.47 spec/spec_helper.rb
active_record_survey-0.1.46 spec/spec_helper.rb
active_record_survey-0.1.45 spec/spec_helper.rb
active_record_survey-0.1.44 spec/spec_helper.rb
active_record_survey-0.1.43 spec/spec_helper.rb
active_record_survey-0.1.42 spec/spec_helper.rb
active_record_survey-0.1.41 spec/spec_helper.rb
active_record_survey-0.1.40 spec/spec_helper.rb
active_record_survey-0.1.39 spec/spec_helper.rb
active_record_survey-0.1.38 spec/spec_helper.rb
active_record_survey-0.1.37 spec/spec_helper.rb
active_record_survey-0.1.36 spec/spec_helper.rb
active_record_survey-0.1.35 spec/spec_helper.rb
active_record_survey-0.1.34 spec/spec_helper.rb
active_record_survey-0.1.32 spec/spec_helper.rb
active_record_survey-0.1.31 spec/spec_helper.rb
active_record_survey-0.1.30 spec/spec_helper.rb
active_record_survey-0.1.29 spec/spec_helper.rb