Skip to content

Commit

Permalink
Clean up test framework and simple rewrite to ensure all current test…
Browse files Browse the repository at this point in the history
…s pass
  • Loading branch information
liuhenry committed Jan 13, 2014
1 parent aa161c7 commit 37b8ab0
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-fp
--format documentation
--color
--require spec_helper
39 changes: 18 additions & 21 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
source 'https://rubygems.org'
ruby "1.9.3"
ruby '1.9.3'

# Framework and core dependencies
gem 'rails', '3.2.13'
gem 'pg'
gem 'unicorn'
gem 'foreman'

gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'crowdtilt', github: 'Crowdtilt/crowdtilt-gem'
gem 'devise'
gem 'email_spec'
gem 'nokogiri'
gem 'pg'
gem "friendly_id", "~> 4.0.9"
gem "iso_country_codes"

gem 'friendly_id', '~> 4.0.9'
gem 'iso_country_codes'
gem 'paperclip', '~> 3.0'
gem 'ckeditor'
gem 'aws-sdk'

gem 'foreman'

gem 'active_model_serializers'

# Front-end
gem 'bootstrap-sass', '2.1'
gem 'jquery-rails'
gem 'jquery-ui-rails'

group :production do
gem 'newrelic_rpm'
gem 'lograge'
Expand All @@ -31,27 +33,22 @@ group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem "asset_sync"
gem 'asset_sync'
end

group :development, :test do
gem 'pry-rails'
gem 'rspec-rails'
gem 'shoulda'
gem 'factory_girl_rails'
gem 'shoulda'
end

group :development do
gem 'quiet_assets'
end

group :test do
gem "faker"
gem "capybara"
gem 'faker'
gem 'capybara'
gem 'email_spec'
end

# jQuery & jQuery UI
gem 'jquery-rails'
gem 'jquery-ui-rails'

gem 'crowdtilt', github: 'msaint/crowdtilt'
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
GIT
remote: git://github.com/msaint/crowdtilt.git
revision: faa74632ac6c5b35f44b289e8e04252a7297f68d
remote: git://github.com/Crowdtilt/crowdtilt-gem.git
revision: 07fe38717db747e2ab5de304a382ceda973c9711
specs:
crowdtilt (0.0.1)
crowdtilt (1.0.0)
activesupport
faraday (~> 0.8, < 0.10)
faraday_middleware (~> 0.9.0)
Expand Down Expand Up @@ -92,10 +92,10 @@ GEM
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
faker (1.1.2)
faker (1.2.0)
i18n (~> 0.5)
faraday (0.8.7)
multipart-post (~> 1.1)
faraday (0.8.8)
multipart-post (~> 1.2.0)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
fog (1.11.1)
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def payment_notification(payment_id)

if (recipients.length > 0)
begin
@settings = Settings.find_by_id(1)
@settings = Settings.first
@payment = Payment.find(payment_id)
rescue ActiveRecord::RecordNotFound
logger.error "Email failed - could not find Payment #{payment_id}"
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
root to: 'pages#index'

# USERS
devise_for :users, { path: 'account', controllers: { registrations: :registrations } } do
devise_for :users, { path: 'account', controllers: { registrations: :registrations } }
devise_scope :user do
match '/user/settings', to: 'devise/registrations#edit', as: :user_settings
end

Expand Down
1 change: 0 additions & 1 deletion spec/controllers/api/v0/payments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

describe Api::V0::PaymentsController do
describe '#index' do
FactoryGirl.create(:user, :admin)
let(:settings) { create(:settings) }
let!(:api_key) { settings.api_key }

Expand Down
30 changes: 0 additions & 30 deletions spec/fixtures/orders.yml

This file was deleted.

9 changes: 0 additions & 9 deletions spec/fixtures/users.yml

This file was deleted.

12 changes: 7 additions & 5 deletions spec/mailers/admin_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
include EmailSpec::Matchers

describe AdminMailer, '#payment_notification' do
before(:all) do
campaign = FactoryGirl.create(:campaign)
@payment = FactoryGirl.create(:payment, campaign: campaign)
@email = AdminMailer.payment_notification(@payment)
before(:each) do
FactoryGirl.create(:settings)
FactoryGirl.create(:user, :admin)
@campaign = FactoryGirl.create(:campaign)
@payment = FactoryGirl.create(:payment, campaign: @campaign)
@email = AdminMailer.payment_notification(@payment.id)
end

it 'delivers the snippet to the proper address' do
expect(@email).to deliver_to(User.where(admin:true).all.map { |user| user.email })
end

it "has the correct subject" do
expect(@email).to have_subject(/Your Crowdhoster project has a new backer!/)
expect(@email).to have_subject(/New backer for \"#{@campaign.name}\"/)
end

it "contains the proper copy" do
Expand Down
9 changes: 1 addition & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'email_spec'

# Requires supporting ruby files with custom matchers and macros, etc,
Expand All @@ -18,9 +18,6 @@
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
Expand All @@ -37,10 +34,6 @@
# --seed 1234
config.order = "random"

def create(*args)
FactoryGirl.create(*args)
end

# Include Factory Girl syntax to simplify calls to factories
config.include FactoryGirl::Syntax::Methods
end

0 comments on commit 37b8ab0

Please sign in to comment.