This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* author: @jameslafa | |
* More details on http://blog.james-lafa.fr/angularjs-how-to-mock-mixpanel-inside-for-your-tests/ | |
*/ | |
class MixpanelMock | |
debug = false | |
log: (event, data) -> | |
if @debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "UT: MyDirective", -> | |
$scope = undefined | |
$element = undefined | |
$q = undefined | |
html = '<div my-directive></div>' | |
# Compile the directive to generate the html code and get the scope | |
compileDirective = () -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More details on https://blog.james-lafa.fr/angularjs-how-to-test-a-retry-after-http-error-with-httpbackend/ | |
sessionCalls = 0 | |
$httpBackend.when('POST', '/sessions').respond( (method, url, data, headers) -> | |
if sessionCalls == 0 | |
sessionCalls++ | |
return [200, {"response": 1}, {}] | |
else | |
sessionCalls++ | |
return [200, {"response":0,"auth_token":"HK7i6DRncWdBmq"}, {}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Install xquartz : https://xquartz.macosforge.org (no need to restart) | |
2. brew install cairo pango | |
3. brew install graphviz --with-pangocairo (it's important to install graphviz after cairo and pango) | |
4. bundle exec erd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Debugging in the browser | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'meta_request' | |
gem 'quiet_assets' # Remove useless logs | |
# Deploying | |
gem 'capistrano' | |
gem 'capistrano-rails' | |
gem 'capistrano-bundler' # Run bundle install while deploying |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ControllerMacros | |
def attributes_with_foreign_keys(*args) | |
FactoryGirl.build(*args).attributes.delete_if do |k, v| | |
["id", "type", "created_at", "updated_at"].member?(k) | |
end | |
end | |
end | |
RSpec.configure do |config| | |
config.include ControllerMacros, :type => :controller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
belongs_to :organization | |
Organization.categories.keys.each do |category| | |
define_method("#{category}?") do | |
organization.send("#{category}?") | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if flash.any? %> | |
<div class="row flashes"> | |
<div class="col-md-8 col-md-offset-2"> | |
<% flash.each do |msg_type, message| %> | |
<%= flash_message(msg_type, message) %> | |
<% end %> | |
</div> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |