Skip to content

Commit

Permalink
add test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bolandrm committed Sep 21, 2013
1 parent e2d729f commit 04c4da3
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 52 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
45 changes: 10 additions & 35 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,20 @@
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use postgresql as the database for Active Record
gem 'pg'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
group :development, :test do
gem 'guard'
gem 'guard-livereload'
gem 'guard-rspec'
gem 'rspec-rails'
gem 'capybara'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'shoulda-matchers'
end
100 changes: 86 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,81 @@ GEM
tzinfo (~> 0.3.37)
arel (4.0.0)
atomic (1.1.14)
bourne (1.4.0)
mocha (~> 0.13.2)
builder (3.1.4)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.0.9)
coffee-rails (4.0.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0.beta, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
database_cleaner (1.0.1)
diff-lcs (1.2.4)
em-websocket (0.5.0)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.5.3)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.1)
factory_girl (4.2.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
ffi (1.9.0)
formatador (0.2.4)
guard (1.8.1)
formatador (>= 0.2.4)
listen (>= 1.0.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-livereload (1.4.0)
em-websocket (>= 0.5.0)
guard (>= 1.8.0)
multi_json (~> 1.7)
guard-rspec (3.0.2)
guard (>= 1.8)
rspec (~> 2.13)
hike (1.2.3)
http_parser.rb (0.5.3)
i18n (0.6.5)
jbuilder (1.5.1)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.0)
listen (1.2.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
lumberjack (1.0.4)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
method_source (0.8.1)
mime-types (1.25)
mini_portile (0.5.0)
minitest (4.7.5)
mocha (0.13.3)
metaclass (~> 0.0.1)
multi_json (1.8.0)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
pg (0.17.0)
polyglot (0.3.3)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
Expand All @@ -71,16 +119,35 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
rspec (2.14.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.0)
rspec-expectations (2.14.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.0)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.2.10)
sass-rails (4.0.0)
railties (>= 4.0.0.beta, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sdoc (0.3.20)
json (>= 1.1.3)
rdoc (~> 3.10)
shoulda-matchers (1.5.6)
activesupport (>= 3.0.0)
bourne (~> 1.3)
slop (3.4.5)
sprockets (2.10.0)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -97,23 +164,28 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (1.3.0)
coffee-rails
tzinfo (0.3.37)
uglifier (2.2.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
coffee-rails (~> 4.0.0)
jbuilder (~> 1.2)
database_cleaner
factory_girl_rails
guard
guard-livereload
guard-rspec
jquery-rails
pg
rails (= 4.0.0)
rspec-rails
sass-rails (~> 4.0.0)
sdoc
turbolinks
shoulda-matchers
uglifier (>= 1.3.0)
33 changes: 33 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
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 features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{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

1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Timetracker</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
Expand Down
17 changes: 17 additions & 0 deletions spec/features/account_creation_feature_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe 'account creation' do
it 'allows user to create account' do
visit root_path
click_link 'Create Account'

fill_in 'Name', with: 'Ryan'
fill_in 'Email', with: 'bolandryanm@gmail.com'
fill_in 'Password', with: 'pw'
fill_in 'Password Confirmation', with: 'pw'
fill_in 'Subdomain', with: 'test_subdomain'
click_button 'Create Account'

expect(page).to have_content('Signed up successfully')
end
end
29 changes: 29 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ENV["RAILS_ENV"] ||= 'test'

require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'database_cleaner'
require 'capybara/rspec'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
#config.include Devise::TestHelpers, type: :controller
config.order = "random"

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

config.before(:each) do
DatabaseCleaner.start
end

config.after(:each) do
DatabaseCleaner.clean
end
end

0 comments on commit 04c4da3

Please sign in to comment.