diff --git a/Appraisals b/Appraisals index 619e3e7..4f711cc 100644 --- a/Appraisals +++ b/Appraisals @@ -18,7 +18,9 @@ end appraise "rails4" do gem "rails", :git => "git@github.com:rails/rails.git" - gem "active_record_deprecated_finders", - :git => "git@github.com:rails/active_record_deprecated_finders" + gem "activerecord-deprecated_finders", + :git => "git@github.com:rails/activerecord-deprecated_finders" + gem "journey", + :git => "git@github.com:rails/journey" gem "sqlite3" end diff --git a/Appraisals-1.8 b/Appraisals-1.8 new file mode 100644 index 0000000..b37ad3b --- /dev/null +++ b/Appraisals-1.8 @@ -0,0 +1,14 @@ +appraise "rails30" do + gem "rails", "3.0.15" + gem "sqlite3" +end + +appraise "rails31" do + gem "rails", "3.1.6" + gem "sqlite3" +end + +appraise "rails32" do + gem "rails", "3.2.6" + gem "sqlite3" +end diff --git a/Rakefile b/Rakefile index a713ed0..a95fdc3 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,16 @@ require "bundler/gem_tasks" require "rake/testtask" require "appraisal" +if RUBY_VERSION =~ /^1.8/ + module Appraisal + class File + def path + 'Appraisals-1.8' + end + end + end +end + Rake::TestTask.new do |t| t.libs.concat %w(pry-rails spec) t.pattern = "spec/*_spec.rb" @@ -12,8 +22,13 @@ end desc 'Start the Rails server' task :server => :development_env do require 'rails/commands/server' - Rails::Server.start(server: 'WEBrick', environment: 'development', - Host: '0.0.0.0', Port: 3000, config: 'config/config.ru') + Rails::Server.start( + :server => 'WEBrick', + :environment => 'development', + :Host => '0.0.0.0', + :Port => 3000, + :config => 'config/config.ru' + ) end desc 'Start the Rails console' @@ -24,7 +39,7 @@ end task :development_env do ENV['RAILS_ENV'] = 'development' - require_relative 'spec/config/environment' + require File.expand_path('../spec/config/environment', __FILE__) Dir.chdir(Rails.application.root) end diff --git a/Readme.md b/Readme.md index 83fd825..92d8ea3 100644 --- a/Readme.md +++ b/Readme.md @@ -72,18 +72,19 @@ Pokemon has_many beers through hacker ``` -# Developing +# Developing and Testing -To initialize the dev environment for pry-rails, run -`rake init_test_app`. +To generate Gemfiles for Rails 3.0, 3.1, 3.2, and 4.0, run +`rake appraisal:gemfiles appraisal:install`. -To test any changes across Rails 3.0, 3.1, 3.2, and 4.0, run -`rake appraisal console` and `rake appraisal server`. +You can then run the tests across all four versions with `rake appraisal`. +You can also manually run the Rails console and server with `rake +appraisal console` and `rake appraisal server`. -For a specific version of Rails, you can use `rake appraisal:rails30`, -`rake appraisal:rails31`, `rake appraisal:rails32`, and `rake -appraisal:rails4`. +For a specific version of Rails, use `rake appraisal:rails30`, `rake +appraisal:rails31`, `rake appraisal:rails32`, or `rake appraisal:rails4`. # Alternative -If you want to enable pry everywhere, make sure to check out [pry everywhere](http://lucapette.com/pry/pry-everywhere/). +If you want to enable pry everywhere, make sure to check out +[pry everywhere](http://lucapette.com/pry/pry-everywhere/). diff --git a/lib/pry-rails/commands/show_models.rb b/lib/pry-rails/commands/show_models.rb index 4175a56..388655c 100644 --- a/lib/pry-rails/commands/show_models.rb +++ b/lib/pry-rails/commands/show_models.rb @@ -37,7 +37,11 @@ PryRails::Commands.create_command "show-models" do display_error "Table doesn't exist" end - model.reflections.each do |other_model, reflection| + reflections = model.reflections.sort_by do |other_model, reflection| + [reflection.macro.to_s, other_model.to_s] + end + + reflections.each do |other_model, reflection| options = [] if reflection.options[:through].present? diff --git a/pry-rails.gemspec b/pry-rails.gemspec index dc724d3..3cf4491 100644 --- a/pry-rails.gemspec +++ b/pry-rails.gemspec @@ -20,5 +20,6 @@ Gem::Specification.new do |s| s.add_dependency "pry", ">= 0.9.10" s.add_development_dependency "appraisal" + s.add_development_dependency "minitest" s.add_development_dependency "rr" end diff --git a/spec/config/environment.rb b/spec/config/environment.rb index 7c94fcf..eb48b2e 100644 --- a/spec/config/environment.rb +++ b/spec/config/environment.rb @@ -55,7 +55,7 @@ end class Pokemon < ActiveRecord::Base belongs_to :hacker - has_many :beers, through: :hacker + has_many :beers, :through => :hacker end begin @@ -64,7 +64,7 @@ begin class Artist include Mongoid::Document - field :name, type: String + field :name, :type => String embeds_one :beer embeds_many :instruments end @@ -72,8 +72,8 @@ begin class Instrument include Mongoid::Document - field :name, type: String + field :name, :type => String embedded_in :artist end -rescue LoadError # Mongoid doesn't support Rails 3.0 or 4.0 +rescue LoadError # Mongoid doesn't support Rails 3.0 or 4.0 or Ruby 1.8 end diff --git a/spec/show_models_spec.rb b/spec/show_models_spec.rb index 6f6003d..bc99ae8 100644 --- a/spec/show_models_spec.rb +++ b/spec/show_models_spec.rb @@ -18,8 +18,8 @@ Beer Hacker id: integer social_ability: integer - has_many :pokemons has_many :beers + has_many :pokemons Pokemon id: integer name: string