Skip to content

Instantly share code, notes, and snippets.

View daveworth's full-sized avatar
🔬
Science!

David E Worth daveworth

🔬
Science!
View GitHub Profile
begin
response.body.scan(/(.+?)(?:\n|$)/) do |line|
yield ActiveSupport::JSON.decode(line)
end
end
@daveworth
daveworth / gist:1245674
Created September 27, 2011 17:20
Gibbon extension tests
require 'active_support'
require 'httparty'
require 'json'
require 'cgi'
class Gibbon
include HTTParty
format :plain
default_timeout 30
describe "Setup link visibility" do
["basic", "advanced"].each do |role|
it "should not be visible to #{role}s", :driver => :rack_test do
login_as(role.to_sym) do
visit root_path
page.should_not have_content("MailChimp Setup")
end
end
end
#defines login_as
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper')
describe "MC Integration" do
describe "setup modal" do
# would want a
# before(:each) do
def login
login_as
end
def login_as(role=:basic, &block)
account = Account.find_by_name("testaccount") || Factory.create(:testaccount)
role = Role.find_by_name(role.to_s.capitalize) || Factory.create("#{role.downcase}_role")
user = Factory.create(:user, :account => account, :role => role)
login_as_user(user,&block)
Spork.each_run do
# This code will be run each time you run your specs.
`rake fuzzymatch:load_functions RAILS_ENV=test`
# reload classes for spork
ActiveSupport::Dependencies.clear
# re-instantiate observers
ActiveRecord::Base.instantiate_observers
# Reload FactoryGirl factories on each run
class Model < ActiveRecord::Base
class << self
def method
end
end
end
require 'spec_helper'
describe ContactImport do
describe "Schema" do
it { should have_db_column(:import_file_name).of_type(:string) }
it { should have_db_column(:import_content_type).of_type(:string) }
it { should have_db_column(:import_file_size).of_type(:integer) }
it { should have_db_column(:import_updated_at).of_type(:datetime) }
it { should have_db_column(:import_format).of_type(:string) }
it { should have_db_column(:tag_import).of_type(:boolean) }
it "creates a new ContactImport based on type" do
["vcard", "csv", "mailchimp"].each do |import_format|
import_class = ContactImport.import_mapping[import_format]
post :create, :contact_import => {:import_format => import_format}
assigns(:contact_import).should_not be_nil
assigns(:contact_import).should be_a_kind_of(import_class)
response.should redirect_to :edit_contact_import
end
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'