Skip to content

Instantly share code, notes, and snippets.

@Kosmas
Kosmas / gist:e2772e2cf89e918ae66a4d61586d572d
Created August 30, 2016 11:13
Alias for running Code Climate CLI (cca) - add in .bashrc
alias cca="docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze"
eature: REST API
Scenario: Compare JSON # features/rest_api.feature:3
Given I have created a new Rails app "rails-3-app" and installed cucumber-rails # features/step_definitions/cucumber_rails_steps.rb:48
And I write to "app/controllers/posts_controller.rb" with: # aruba-0.5.3/lib/aruba/cucumber.rb:31
"""
class PostsController < ApplicationController
def index
render :json => {'hello' => 'world'}.to_json
end
kosmas:cucumber-rails (master)$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "builder":
In Gemfile:
ammeter (>= 0.2.9) ruby depends on
builder (~> 2.1.2) ruby
cucumber-rails (>= 0) ruby depends on
home/kosmas/.rvm/rubies/ruby-1.9.3-p327/bin/ruby -S bundle exec cucumber
Using the default profile...
.................................................F------..............................................................
(::) failed steps (::)
Exit status was 1 but expected it to be 0. Output:
exit | mongo
create
test_helper.rb
require './test/additional_assertions'
additional_assertions.rb
module AdditionalAssertions
module CaptureOutput
# NOTE: MiniTest has capture_io and capture_subprocess_io
@Kosmas
Kosmas / percentages_display
Created October 20, 2015 12:56
display percentages in a rake task
def calculate_perc(i, total)
(i * 100 / total).to_i
end
def rate_limit_1_perc?(perc, last_perc, last_updated)
# Changes of at least 1%
# once every 20 seconds
perc > last_perc && last_updated < Time.now.ago(20.seconds)
end
@Kosmas
Kosmas / ruboto_build_fail_1.7.0
Created November 14, 2012 11:19
ruboto build with 1.7.0
vagrant@precise64:~/Prog/android_data/projects/test$ ruby -v
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on OpenJDK 64-Bit Server VM 1.7.0_09-b30 [linux-amd64]
vagrant@precise64:~/Prog/android_data/projects/test$ gem list
*** LOCAL GEMS ***
arrayfields (4.7.4)
bouncy-castle-java (1.5.0146.1)
bundler (1.2.1)
chronic (0.6.7)
@Kosmas
Kosmas / ruboto_build_fail
Created November 7, 2012 12:36
Ruboto jruby build fail
vagrant@precise64:~/Prog/android_data/projects/test$ ruboto update jruby --force
Copying /home/vagrant/.rvm/gems/jruby-1.6.7.2/gems/jruby-jars-1.7.0/lib/jruby-core-1.7.0.jar to libs...Done.
Copying /home/vagrant/.rvm/gems/jruby-1.6.7.2/gems/jruby-jars-1.7.0/lib/jruby-stdlib-1.7.0.jar to libs...Done.
Copying dexmaker.jar to libs...Done.
Removing unneeded classes from jruby-core-1.7.0.jar...Done.
Reformatting jruby-stdlib-1.7.0.jar..../lib/ruby : no such file or directory
Done.
JRuby version is now: 1.7.0
vagrant@precise64:~/Prog/android_data/projects/test$ rake
/home/vagrant/Prog/android_data/projects/test/libs/jruby-stdlib-1.7.0.jar changed.
@Kosmas
Kosmas / ruboto_build_fail_1.6.7.2
Created November 7, 2012 12:53
ruboto build with 1.6.7.2
vagrant@precise64:~/Prog/android_data/projects/test1$ gem install jruby-jars --version 1.6.7.2
Fetching: jruby-jars-1.6.7.2.gem (100%)
Successfully installed jruby-jars-1.6.7.2
1 gem installed
vagrant@precise64:~/Prog/android_data/projects/test$ rm libs/jruby-*.jar
vagrant@precise64:~/Prog/android_data/projects/test$ ls libs
dexmaker20120305.jar tmp
vagrant@precise64:~/Prog/android_data/projects/test$ ruboto update jruby --force
@Kosmas
Kosmas / Gemfile
Created October 5, 2011 16:08 — forked from kossnocorp/Gemfile
...
gem 'devise',
:git => 'https://github.com/plataformatec/devise.git',
:branch => 'omniauth'
gem 'oa-oauth', :require => 'omniauth/oauth'
...