require 'simplecov' require 'coveralls' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start do add_filter '/spec/' end require 'active_record' require 'timecop' require 'unread' require 'model/reader' require 'model/email' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # Require this file using `require "spec_helper"` to ensure that it is only # loaded once. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 # config.order = 'random' config.before :each do clear_db end config.after :each do Timecop.return end config.after :suite do UnreadMigration.migrate(:down) end end if I18n.respond_to?(:enforce_available_locales=) I18n.enforce_available_locales = false end def setup_db puts "Testing with ActiveRecord #{ActiveRecord::VERSION::STRING}" ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:' ActiveRecord::Migration.verbose = false require File.expand_path('../../lib/generators/unread/migration/templates/migration.rb', __FILE__) UnreadMigration.migrate(:up) ActiveRecord::Schema.define(:version => 1) do create_table :readers, :primary_key => 'number', :force => true do |t| t.string :name end create_table :emails, :primary_key => 'messageid', :force => true do |t| t.string :subject t.text :content t.datetime :created_at t.datetime :updated_at end end end def clear_db Reader.delete_all Email.delete_all ReadMark.delete_all end setup_db