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
| test = test | |
| # => nil | |
| @test = @test | |
| # => nil | |
| $test = $test | |
| # => nil | |
| @@test = @@test | |
| # NameError: uninitialized class variable @@test in Object |
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
| <li class='<%= 'complete' if todo.complete? %>' id='<%= dom_id todo %>'> | |
| <%= todo.description %> | |
| <% if todo.completed_at? -%> | |
| <%= link_to 'Incomplete', todo_completion_path(todo), method: :delete %> | |
| <% else -%> | |
| <%= link_to 'Complete', todo_completion_path(todo), method: :post %> | |
| <% end -%> | |
| </li> |
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
| # This class does something simple enough that I can describe in one sentence. | |
| # | |
| # Sometimes you may want to elaborate a little bit in one or two more sentences. | |
| # | |
| # Example: | |
| # BroomStick.new.quiddich_and_golden_snitches | |
| class BroomStick | |
| 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
| it 'finds posts containing the given word in the title' do | |
| # The titles are in a different file than the test, so you need to flip back and forth to see | |
| # what's actually going on here. When somebody adds another example post to the fixtures, this | |
| # test will start failing, which is a distraction and a waste of time. We were also never able to | |
| # come up with fixtures that weren't either hopelessly entangled or completely bloated from adding | |
| # a specific fixture for almost every test. | |
| Post.search('example').map(&:title).should =~ ['example one', 'example two'] | |
| end | |
| it 'finds posts containing the given word in the title' 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
| # create_table :posts do |table| | |
| # table.string :title, :null => false, :default => '' | |
| # table.string :body, :null => false, :default => '' | |
| # table.string :published, :default => false | |
| # end | |
| class Post < ActiveRecord::Base | |
| attr_accessible :title, :body | |
| validates_presence_of :title | |
| validates_presence_of :body, :if => :published? |
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 'benchmark' | |
| class Base | |
| def foo | |
| true | |
| end | |
| end | |
| class Implicit < Base | |
| 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
| module TaxCodeStrategies | |
| class UnitedStates | |
| def call(id) | |
| "US-#{id}" | |
| end | |
| end | |
| class Brazil | |
| def call(id) | |
| "#{id}-BR" |
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/env ruby | |
| require 'rubygems' | |
| require 'active_support/core_ext' | |
| chars = (('a'..'z').to_a + ('A'..'Z').to_a) | |
| time = Time.now.beginning_of_month | |
| twelve_hours_from_now = 12.hours.from_now | |
| end_of_next_month = 1.month.from_now.end_of_month |
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
| group :development, :test do | |
| gem "spork", "~> 0.9.0.rc" | |
| gem "guard" | |
| gem "guard-spork" | |
| gem "guard-bundler" | |
| gem "guard-passenger" | |
| gem "rb-fsevent", :require => false | |
| gem "growl", :require => false |
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
| Factory.define :gallery do |f| | |
| f.name "Gallery Name" | |
| end | |
| Factory.define :region do |f| | |
| f.name "Telugu" | |
| end |