Sha256: 4ddc9fbf9a111dfb4d5f0775124b5950daa89adc56cc68277af778808e6a0130

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

# encoding: UTF-8

require 'spec_helper'

describe "show-model" do
  it "should print one ActiveRecord model" do
    output = mock_pry('show-model Beer', 'exit-all')

    expected = <<MODEL
Beer
  id: integer
  name: string
  type: string
  rating: integer
  ibu: integer
  abv: integer
  belongs_to :hacker
MODEL

    output.must_equal expected
  end

  if defined? Mongoid
    it "should print one Mongoid model" do
      output = mock_pry('show-model Artist', 'exit-all')

      expected = <<MODEL
Artist
  _id: BSON::ObjectId
  name: String
  embeds_one :beer (validate)
  embeds_many :instruments (validate)
MODEL

      output.gsub!(/^ *_type: String\n/, '') # mongoid 3.0 and 3.1 differ on this
      output.gsub!(/Moped::BSON/, 'BSON')    # mongoid 3 and 4 differ on this
      output.must_equal expected
    end
  end

  it "should print an error if the model doesn't exist" do
    output = mock_pry('show-model FloojBulb', 'exit-all')
    output.must_equal "Couldn't find model FloojBulb!\n"
  end

  it "should print an error if it doesn't know what to do with the model" do
    output = mock_pry('show-model PryRails', 'exit-all')
    output.must_equal "Don't know how to show PryRails!\n"
  end

  it "should print help if no model name is given" do
    output = mock_pry('show-model', 'exit-all')
    output.must_match(/Usage: show-model/)
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
pry-rails-0.3.11 spec/show_model_spec.rb
pry-rails-0.3.10 spec/show_model_spec.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-rails-0.3.9/spec/show_model_spec.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-rails-0.3.9/spec/show_model_spec.rb
pry-rails-0.3.9 spec/show_model_spec.rb
pry-rails-0.3.8 spec/show_model_spec.rb
pry-rails-0.3.7 spec/show_model_spec.rb