Skip to content

Commit

Permalink
Setup RSpec, SimpleCov
Browse files Browse the repository at this point in the history
  • Loading branch information
justincampbell committed Oct 30, 2012
1 parent 9ddde62 commit 8a80a88
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ public/**/uploads
public/test
public/cucumber

coverage/
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ group :production do
end

group :development, :test do
gem 'rspec-rails'
gem 'sqlite3'
end

Expand All @@ -38,13 +39,14 @@ group :test do
gem 'guard', '1.4.0'
gem 'guard-cucumber'
gem 'guard-livereload'
gem 'guard-rspec'
gem 'launchy'
gem 'listen'
gem 'pry'
gem 'pry-doc'
gem 'pry-rails'
gem 'rb-fsevent', '~> 0.9.1'
gem 'rspec-rails'
gem 'simplecov'
gem 'timecop'
gem 'vcr'
gem 'webmock'
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ GEM
em-websocket (>= 0.2.0)
guard (>= 1.1.0)
multi_json (~> 1.0)
guard-rspec (2.1.0)
guard (>= 1.1)
rspec (~> 2.11)
haml (3.1.7)
haml-rails (0.3.5)
actionpack (>= 3.1, < 4.1)
Expand Down Expand Up @@ -209,6 +212,10 @@ GEM
multi_json (~> 1.0)
rubyzip
simple_oauth (0.1.9)
simplecov (0.6.4)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
slop (3.3.3)
sprockets (2.1.3)
hike (~> 1.2)
Expand Down Expand Up @@ -263,6 +270,7 @@ DEPENDENCIES
guard (= 1.4.0)
guard-cucumber
guard-livereload
guard-rspec
haml-rails
jquery-rails
kaminari
Expand All @@ -279,6 +287,7 @@ DEPENDENCIES
rmagick
rspec-rails
sass-rails (~> 3.2.3)
simplecov
sqlite3
susy
thin
Expand Down
22 changes: 22 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ group 'frontend' do
watch(%r{(app|vendor)/assets/\w+/(.+\.(css|js|html)).*}) { |m| "/assets/#{m[2]}" }
end
end

guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }

# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

5 changes: 5 additions & 0 deletions spec/controllers/tweets_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe TweetsController do

end
5 changes: 5 additions & 0 deletions spec/models/rubyfriends_app_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe RubyfriendsApp do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/models/tweet_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe Tweet do
pending "add some examples to (or delete) #{__FILE__}"
end
19 changes: 19 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
unless ENV['GUARD_NOTIFY'] # Only run simplecov with Rake
require 'simplecov'
SimpleCov.start :rails
end

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)

require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
config.infer_base_class_for_anonymous_controllers = true
config.order = :random
config.treat_symbols_as_metadata_keys_with_true_values = true
end

0 comments on commit 8a80a88

Please sign in to comment.