This file contains hidden or 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
| require 'spec_helper' | |
| RSpec.describe YourRecord do | |
| subject(:record) { create :your_record, *traits } | |
| let(:traits) { [] } | |
| its(:name) { is_expected.to be_nil } | |
| its(:size) { is_expected.to eq(0) } | |
| context "when name is bob" do |
This file contains hidden or 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.describe YourModule do | |
| let(:includer) { Class.new.include(described_class).new } | |
| describe "#hello_world" do | |
| it "returns Hello World" do | |
| expect(includer.hello_world). | |
| to eq("Hello World") | |
| end | |
| end | |
| end |
This file contains hidden or 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
| gemfile=File.read("Gemfile") | |
| unversioned = gemfile.scan(/(?<!#)\s+(gem|custom_require) ['"]([\w-]+)['"](?!,.*(\d+\.\d+\.\d+))/) | |
| lockfile = File.read("Gemfile.lock") | |
| puts unversioned.inspect | |
| unversioned.each do |lead, name| | |
| version = lockfile.scan(/#{name} \(((\d+\.?)+)\)/).first.first | |
| gemfile.gsub! /#{lead} ['"]#{name}['"]/, "\\0, '~> #{version}'" |
This file contains hidden or 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
| file=Pathname.new(Dir.pwd+'/lib') | |
| if(file.exist?) | |
| $:.unshift(file.to_s) | |
| end |
This file contains hidden or 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 RubyVersion | |
| def self.current | |
| factory.current | |
| end | |
| def self.factory | |
| if version_file_exists? | |
| Files.new | |
| elsif rvm_present? | |
| RVM.new |
This file contains hidden or 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 'ordering' do | |
| let(:herp) { raise 'hi' } | |
| subject { raise 'bye' } | |
| it { should eq(herp) } #=> error 'hi' | |
| it { is_expected.to eq(herp) } #=> error 'bye' | |
| end |
This file contains hidden or 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 OnCodeCaller | |
| def self.call(code, needer) | |
| if needer.respond_to?("on_#{code}") | |
| needer.send("on_#{code}") | |
| elsif needer.respond_to?("on_#{code / 100}XX") | |
| needer.send("on_#{code / 100}XX") | |
| else | |
| needer.on_failure | |
| end | |
| end |
This file contains hidden or 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
| package funsets | |
| import common._ | |
| /** | |
| * 2. Purely Functional Sets. | |
| */ | |
| object FunSets { | |
| /** | |
| * We represent a set by its characteristic function, i.e. |
This file contains hidden or 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
| #! /usr/bin/ruby | |
| branch_match = `git branch`.match(/FY-#{ARGV[0]}\w+/) | |
| branch = branch_match ? branch_match[0].to_s : ARGV[0] | |
| `git checkout #{branch}` |
This file contains hidden or 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 [ -f "$rvm_path/scripts/rvm" ]; then | |
| source "$rvm_path/scripts/rvm" | |
| if [ -f ".rvmrc" ]; then | |
| source ".rvmrc" | |
| else | |
| if [ -f ".ruby-version" ]; then | |
| if [ -f ".ruby-gemset" ]; then | |
| rvm use `cat .ruby-version`@`cat .ruby-gemset` | |
| else | |
| rvm use `cat .ruby-version` |