Skip to content
This repository
Browse code

prepare for the specs

  • Loading branch information...
commit ff721e02d54b146c69a7c5cefd13cae5cc9f51e7 1 parent 30cbc38
Akira Matsuda authored
1  .rspec
... ... @@ -1 +1,2 @@
1 1 --color
  2 +--format=d
7 spec/kaminari_spec.rb
... ... @@ -1,7 +0,0 @@
1   -require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2   -
3   -describe "Kaminari" do
4   - it "fails" do
5   - fail "hey buddy, you should probably rename this file and start specing for real"
6   - end
7   -end
29 spec/spec_helper.rb
... ... @@ -1,12 +1,37 @@
1 1 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2 2 $LOAD_PATH.unshift(File.dirname(__FILE__))
3   -require 'rspec'
  3 +require 'active_support/all'
  4 +require 'active_record'
  5 +require 'rails'
  6 +require 'action_controller/railtie'
  7 +require 'action_view/railtie'
  8 +require 'rspec/rails'
  9 +
  10 +ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
  11 +ActiveRecord::Base.establish_connection('test')
  12 +
4 13 require 'kaminari'
5 14
  15 +app = Class.new(Rails::Application)
  16 +app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
  17 +app.config.session_store :cookie_store, :key => "_myapp_session"
  18 +app.config.active_support.deprecation = :log
  19 +app.initialize!
  20 +
  21 +app.routes.draw do
  22 + resources :users
  23 +end
  24 +
  25 +Object.const_set(:ApplicationHelper, Module.new)
  26 +
6 27 # Requires supporting files with custom matchers and macros, etc,
7 28 # in ./support/ and its subdirectories.
8 29 Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9 30
10 31 RSpec.configure do |config|
11   -
  32 + config.mock_with :rr
  33 + config.before :all do
  34 +# ActiveRecord::Base.connection.execute 'CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))' unless ActiveRecord::Base.connection.table_exists? 'users'
  35 + CreateUsers.up unless ActiveRecord::Base.connection.table_exists? 'users'
  36 + end
12 37 end
8 spec/support/20110128122508_create_users.rb
... ... @@ -0,0 +1,8 @@
  1 +class CreateUsers < ActiveRecord::Migration
  2 + def self.up
  3 + create_table :users do |t|
  4 + t.string :name
  5 + t.timestamps
  6 + end
  7 + end
  8 +end
3  spec/support/user.rb
... ... @@ -0,0 +1,3 @@
  1 +class User < ActiveRecord::Base
  2 + default_scope order('name')
  3 +end

0 comments on commit ff721e0

Please sign in to comment.
Something went wrong with that request. Please try again.