Skip to content

Commit b5dd83e

Browse files
committed
replaced files
1 parent 0bb6eac commit b5dd83e

File tree

5 files changed

+25
-44
lines changed

5 files changed

+25
-44
lines changed

Gemfile

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
source 'https://rubygems.org'
1+
source :rubygems
22

3-
# PostgreSQL driver
4-
gem 'pg'
3+
# SQLite3 driver
4+
gem 'sqlite3'
55

66
# Sinatra driver
77
gem 'sinatra'
8+
gem 'sinatra-contrib'
89

910
# Use Thin for our web server
1011
gem 'thin'
1112

1213
gem 'activesupport'
1314
gem 'activerecord'
15+
gem 'shotgun'
1416

1517
gem 'rake'
18+
gem 'bcrypt-ruby', '~> 3.0.0'
19+
gem 'pry'
1620

17-
gem 'shotgun'
1821

19-
gem 'oauth'
20-
gem 'twitter'
22+
group :test do
23+
gem 'faker'
24+
gem 'rspec'
25+
gem 'shoulda-matchers'
26+
end

Rakefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'rake'
2-
2+
require 'rspec/core/rake_task'
33

44

55
require ::File.expand_path('../config/environment', __FILE__)
@@ -89,13 +89,13 @@ namespace :db do
8989
desc "Create the database at #{DB_NAME}"
9090
task :create do
9191
puts "Creating database #{DB_NAME} if it doesn't exist..."
92-
exec("createdb #{DB_NAME}")
92+
exec("touch #{DB_NAME}")
9393
end
9494

9595
desc "Drop the database at #{DB_NAME}"
9696
task :drop do
9797
puts "Dropping database #{DB_NAME}..."
98-
exec("dropdb #{DB_NAME}")
98+
exec("rm #{DB_NAME}")
9999
end
100100

101101
desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
@@ -122,3 +122,8 @@ desc 'Start IRB with application environment loaded'
122122
task "console" do
123123
exec "irb -r./config/environment"
124124
end
125+
126+
desc "Run the specs"
127+
RSpec::Core::RakeTask.new(:spec)
128+
129+
task :default => :spec

config/database.rb

+2-24
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,9 @@
1313
autoload ActiveSupport::Inflector.camelize(filename), model_file
1414
end
1515

16-
# We have to do this in case we have models that inherit from each other.
17-
# If model Student inherits from model Person and app/models/student.rb is
18-
# required first, it will throw an error saying "Person" is undefined.
19-
#
20-
# With this lazy-loading technique, Ruby will try to load app/models/person.rb
21-
# the first time it sees "Person" and will only throw an exception if
22-
# that file doesn't define the Person class.
23-
24-
# Heroku controls what database we connect to by setting the DATABASE_URL environment variable
25-
# We need to respect that if we want our Sinatra apps to run on Heroku without modification
26-
db = URI.parse(ENV['DATABASE_URL'] || "postgres://localhost/#{APP_NAME}_#{Sinatra::Application.environment}")
27-
28-
DB_NAME = db.path[1..-1]
29-
30-
# Note:
31-
# Sinatra::Application.environment is set to the value of ENV['RACK_ENV']
32-
# if ENV['RACK_ENV'] is set. If ENV['RACK_ENV'] is not set, it defaults
33-
# to :development
16+
DB_NAME = APP_ROOT.join('db', 'events.sqlite3').to_s
3417

3518
ActiveRecord::Base.establish_connection(
36-
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
37-
:host => db.host,
38-
:port => db.port,
39-
:username => db.user,
40-
:password => db.password,
19+
:adapter => 'sqlite3',
4120
:database => DB_NAME,
42-
:encoding => 'utf8'
4321
)

config/environment.rb

+3-11
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@
1111
require 'uri'
1212
require 'pathname'
1313

14-
require 'pg'
14+
require 'sqlite3'
1515
require 'active_record'
1616
require 'logger'
1717

1818
require 'sinatra'
19-
require 'shotgun'
20-
19+
require "sinatra/reloader" if development?
20+
require 'bcrypt'
2121
require 'erb'
2222

23-
require 'oauth'
24-
require 'twitter'
25-
2623
# Some helper constants for path-centric logic
2724
APP_ROOT = Pathname.new(File.expand_path('../../', __FILE__))
2825

@@ -34,8 +31,3 @@
3431

3532
# Set up the database and models
3633
require APP_ROOT.join('config', 'database')
37-
38-
$client = Twitter::REST::Client.new do |config|
39-
config.consumer_key = ENV['TWITTER_KEY']
40-
config.consumer_secret = ENV['TWITTER_SECRET']
41-
end

spec/spec_helper.rb

100755100644
File mode changed.

0 commit comments

Comments
 (0)