Skip to content

Instantly share code, notes, and snippets.

@senny
senny / grouped_select.erb
Created July 29, 2014 12:24
grouped select
<%= form_tag "#" do %>
<%= select_tag "name", grouped_options_for_select("Group 1" => ["value 1", "value 2"], "Group 2" => ["value 3", "value 4"]) %>
<% end %>
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'test123')
ActiveRecord::Base.logger = Logger.new(STDOUT)
class PhotosController < ApplicationController
def show
if params.has_key? :time
@main_photo = "http://www.google.com/images/srpr/logo11w.png"
end
end
end
class Developer
def salery
5000
end
end
class Manager
def salery
8000
end
@senny
senny / 1test.rb
Last active August 29, 2015 14:10
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 32140be..f2e0f82 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -223,7 +223,16 @@ Every test must contain at least one assertion, with no restriction as to how ma
### Maintaining the test database schema
-In order to run your tests, your test database will need to have the current structure. The test helper checks whether your test database has any pending migrations. If so, it will try to load your `db/schema.rb` or `db/structure.sql` into the test database. If migrations are still pending, an error will be raised.
+In order to run your tests, your test database will need to have the current
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
E, [2015-02-12T03:25:25.223244 #32185] ERROR -- : Actor crashed!
Errno::EHOSTDOWN: Host is down @ dir_initialize - <THE/DIRECTORY/LISTEN/WATCHES>
/usr/local/rbenv/versions/2.1.5/lib/ruby/2.1.0/pathname.rb:425:in `open'
/usr/local/rbenv/versions/2.1.5/lib/ruby/2.1.0/pathname.rb:425:in `foreach'
/usr/local/rbenv/versions/2.1.5/lib/ruby/2.1.0/pathname.rb:425:in `children'
/path/to/app/vendor/bundle/ruby/2.1.0/gems/listen-2.8.3/lib/listen/directory.rb:14:in `scan'
/path/to/app/vendor/bundle/ruby/2.1.0/gems/listen-2.8.3/lib/listen/change.rb:38:in `change'
/path/to/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
/path/to/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
/path/to/app/vendor/bundle/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/calls.rb:63:in `dispatch'
diff --git a/test/fixtures/high_scores.yml b/test/fixtures/high_scores.yml
index 0c3721e..9d3b342 100644
--- a/test/fixtures/high_scores.yml
+++ b/test/fixtures/high_scores.yml
@@ -1,5 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+<% require Rails.root + "test/support/fixture_helper" %>
+
one:
@senny
senny / env
Last active August 29, 2015 14:16
Ruby 2.2.1 bug
$ ruby --version
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]