├── .document ├── .gitignore ├── .rspec ├── Gemfile ├── Gemfile.lock ├── LICENSE.txt ├── README.rdoc ├── Rakefile ├── VERSION ├── bin └── rails-sh ├── lib └── rails │ ├── sh.rb │ └── sh │ ├── bundler.rb │ ├── command.rb │ ├── commands.rb │ ├── forkable.rb │ ├── helpers.rb │ ├── rails.rb │ └── rake.rb ├── rails-sh.gemspec └── spec ├── rails ├── sh │ └── command_spec.rb └── sh_spec.rb └── spec_helper.rb /.document: -------------------------------------------------------------------------------- 1 | lib/**/*.rb 2 | bin/* 3 | - 4 | features/**/*.feature 5 | LICENSE.txt 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pkg 2 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | # Add dependencies required to use your gem here. 3 | # Example: 4 | # gem "activesupport", ">= 2.3.5" 5 | 6 | # Add dependencies to develop your gem here. 7 | # Include everything needed to run rake, tests, features, etc. 8 | group :development do 9 | gem "rake", "0.8.7" 10 | gem "rspec", "~> 2.3.0" 11 | gem "bundler", "~> 1.0.0" 12 | gem "jeweler", "~> 1.5.2" 13 | gem "rcov", ">= 0" 14 | end 15 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | diff-lcs (1.1.2) 5 | git (1.2.5) 6 | jeweler (1.5.2) 7 | bundler (~> 1.0.0) 8 | git (>= 1.2.5) 9 | rake 10 | rake (0.8.7) 11 | rcov (0.9.9) 12 | rspec (2.3.0) 13 | rspec-core (~> 2.3.0) 14 | rspec-expectations (~> 2.3.0) 15 | rspec-mocks (~> 2.3.0) 16 | rspec-core (2.3.1) 17 | rspec-expectations (2.3.0) 18 | diff-lcs (~> 1.1.2) 19 | rspec-mocks (2.3.0) 20 | 21 | PLATFORMS 22 | ruby 23 | 24 | DEPENDENCIES 25 | bundler (~> 1.0.0) 26 | jeweler (~> 1.5.2) 27 | rake (= 0.8.7) 28 | rcov 29 | rspec (~> 2.3.0) 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 jugyo 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = rails-sh 2 | 3 | rails-sh is a mini shell for rails3 that provides a uniform and quick access to commands. 4 | 5 | == Install 6 | 7 | $ gem install rails-sh 8 | 9 | == Usage 10 | 11 | $ cd your-rails3-app 12 | $ rails-sh 13 | 14 | You can specify an environment as follows: 15 | 16 | $ rails-sh test 17 | 18 | == Examples 19 | 20 | Execute rake task: 21 | 22 | rails> rake db:migrate 23 | 24 | Generate a controller: 25 | 26 | rails> rails generate controller foo bar 27 | $ rails g controller foo bar 28 | create app/controllers/foo_controller.rb 29 | route get "foo/bar" 30 | invoke erb 31 | create app/views/foo 32 | create app/views/foo/bar.html.erb 33 | invoke test_unit 34 | create test/functional/foo_controller_test.rb 35 | invoke helper 36 | create app/helpers/foo_helper.rb 37 | invoke test_unit 38 | create test/unit/helpers/foo_helper_test.rb 39 | 40 | Run console: 41 | 42 | rails> console 43 | 44 | == Commands 45 | 46 | please type help 47 | 48 | == Configuration 49 | 50 | rails-sh will try to load '~/railsshrc' as configuration. 51 | 52 | Example: 53 | 54 | # ~/railsshrc 55 | Rails::Sh::Command.define 'my_command' do |arg| 56 | puts "Execute my_command with arg(`#{arg}`)!" 57 | end 58 | 59 | == TODO 60 | 61 | == Contributing to rails-sh 62 | 63 | * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet 64 | * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it 65 | * Fork the project 66 | * Start a feature/bugfix branch 67 | * Commit and push until you are happy with your contribution 68 | * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. 69 | * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. 70 | 71 | == Copyright 72 | 73 | Copyright (c) 2011 jugyo. See LICENSE.txt for further details. -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'bundler' 3 | begin 4 | Bundler.setup(:default, :development) 5 | rescue Bundler::BundlerError => e 6 | $stderr.puts e.message 7 | $stderr.puts "Run `bundle install` to install missing gems" 8 | exit e.status_code 9 | end 10 | require 'rake' 11 | 12 | require 'jeweler' 13 | Jeweler::Tasks.new do |gem| 14 | # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options 15 | gem.name = "rails-sh" 16 | gem.homepage = "http://github.com/jugyo/rails-sh" 17 | gem.license = "MIT" 18 | gem.summary = %Q{The Rails Shell} 19 | gem.description = %Q{The Rails Shell to execute sub commands of rails quickly.} 20 | gem.email = "jugyo.org@gmail.com" 21 | gem.authors = ["jugyo"] 22 | # Include your dependencies below. Runtime dependencies are required when using your gem, 23 | # and development dependencies are only needed for development (ie running rake tasks, tests, etc) 24 | # gem.add_runtime_dependency 'jabber4r', '> 0.1' 25 | # gem.add_development_dependency 'rspec', '> 1.2.3' 26 | end 27 | Jeweler::RubygemsDotOrgTasks.new 28 | 29 | require 'rspec/core' 30 | require 'rspec/core/rake_task' 31 | RSpec::Core::RakeTask.new(:spec) do |spec| 32 | spec.pattern = FileList['spec/**/*_spec.rb'] 33 | end 34 | 35 | RSpec::Core::RakeTask.new(:rcov) do |spec| 36 | spec.pattern = 'spec/**/*_spec.rb' 37 | spec.rcov = true 38 | end 39 | 40 | task :default => :spec 41 | 42 | require 'rake/rdoctask' 43 | Rake::RDocTask.new do |rdoc| 44 | version = File.exist?('VERSION') ? File.read('VERSION') : "" 45 | 46 | rdoc.rdoc_dir = 'rdoc' 47 | rdoc.title = "rails-sh #{version}" 48 | rdoc.rdoc_files.include('README*') 49 | rdoc.rdoc_files.include('lib/**/*.rb') 50 | end 51 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.5.2 -------------------------------------------------------------------------------- /bin/rails-sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | version = 'v' + File.read(File.expand_path('../../VERSION', __FILE__)) 4 | puts < e 32 | puts "\e[41m#{e.message}\n#{e.backtrace.join("\n")}\e[0m" 33 | end 34 | setup_readline 35 | end 36 | end 37 | 38 | def prompt 39 | "%s> " % "rails-sh(#{::Rails.root.basename})" 40 | end 41 | 42 | def setup_readline 43 | Readline.basic_word_break_characters = "" 44 | Readline.completion_proc = Command.completion_proc 45 | end 46 | 47 | def execute(line) 48 | if command = Command.find(line) 49 | start = Time.now 50 | arg = line.split(/\s+/, 2)[1] rescue nil 51 | command.call(arg) 52 | puts "\e[34m#{Time.now - start}sec\e[0m" 53 | else 54 | puts "\e[41mCommand not found\e[0m" 55 | end 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/rails/sh/bundler.rb: -------------------------------------------------------------------------------- 1 | module Rails 2 | module Sh 3 | module Bundler 4 | extend Forkable 5 | 6 | class << self 7 | def _invoke(line) 8 | line ||= 'install' 9 | command, *args = line.split(/\s+/) 10 | ARGV.clear 11 | ARGV.concat args 12 | require 'bundler/cli' 13 | ::Bundler::CLI.new.send(command.to_sym) 14 | end 15 | 16 | def sub_commands 17 | %w(exec install update open package config check list show console open viz init gem) 18 | end 19 | end 20 | end 21 | end 22 | end -------------------------------------------------------------------------------- /lib/rails/sh/command.rb: -------------------------------------------------------------------------------- 1 | module Rails 2 | module Sh 3 | module Command 4 | class << self 5 | def commands 6 | @commands ||= {} 7 | end 8 | 9 | def define(*names, &block) 10 | names.each do |name| 11 | commands[name.to_sym] = block 12 | completions << name.to_s 13 | end 14 | end 15 | 16 | def find(line) 17 | if name = line.split(/\s+/, 2)[0] 18 | commands[name.to_sym] 19 | else 20 | nil 21 | end 22 | end 23 | 24 | def command_names 25 | commands.keys 26 | end 27 | 28 | def [](name) 29 | commands[name.to_sym] 30 | end 31 | 32 | def completion_proc 33 | lambda { |line| 34 | regex = /#{Regexp.quote(line)}/ 35 | completions.map { |completion| 36 | case completion 37 | when String 38 | completion if completion.match(regex) 39 | when Proc 40 | completion.call(line) 41 | end 42 | }.compact 43 | } 44 | end 45 | 46 | def completions 47 | @completions ||= [] 48 | end 49 | 50 | def completions=(completions) 51 | @completions = completions 52 | end 53 | 54 | def clear 55 | commands.clear 56 | completions.clear 57 | end 58 | end 59 | end 60 | end 61 | end -------------------------------------------------------------------------------- /lib/rails/sh/commands.rb: -------------------------------------------------------------------------------- 1 | include Rails::Sh 2 | 3 | Command.define 'help' do 4 | print "\e[36m" 5 | puts < true) 32 | else 33 | Rails::Sh::Rake.invoke(arg) 34 | end 35 | end 36 | 37 | Rails::Sh::Rake.task_names.map do |name| 38 | Command.completions << "rake #{name}" 39 | end 40 | 41 | Command.define 'tasks', 't' do |arg| 42 | Rake.application.options.show_task_pattern = arg ? Regexp.new(arg) : // 43 | Rake.application.display_tasks_and_comments 44 | end 45 | 46 | Command.define 'bundle' do |arg| 47 | Rails::Sh::Bundler.invoke(arg) 48 | end 49 | 50 | (Rails::Sh::Bundler.sub_commands - ['init']).map do |c| 51 | Command.completions << "bundle #{c}" 52 | end 53 | 54 | Command.define '!' do |arg| 55 | system arg 56 | end 57 | 58 | Command.define 'eval' do |arg| 59 | puts "\e[34m=> #{eval(arg, binding, __FILE__, __LINE__).inspect}\e[0m" 60 | end 61 | 62 | Command.define 'restart' do 63 | puts 'restarting...' 64 | exec File.expand_path('../../../../bin/rails-sh', __FILE__) 65 | end 66 | 67 | Command.define 'reload' do 68 | Rails::Sh::Rails.reload! 69 | end 70 | 71 | Command.define 'log' do |arg| 72 | puts "\e[7mCtrl-C to quit\e[0m" 73 | system 'tail', '-f', Rails.root.join('log', (arg || 'development') + '.log').to_s 74 | end 75 | Command.completions += %w(development test production).map { |i| "log #{i}" } 76 | 77 | Command.define 'exit' do 78 | exit 79 | end 80 | -------------------------------------------------------------------------------- /lib/rails/sh/forkable.rb: -------------------------------------------------------------------------------- 1 | require 'stringio' 2 | 3 | module Rails 4 | module Sh 5 | module Forkable 6 | include Rails::Sh::Helpers 7 | 8 | def invoke(line, options = {}) 9 | run_before_fork 10 | pid = fork do 11 | run_after_fork 12 | 13 | if options[:pager] 14 | begin 15 | $stdout = StringIO.new 16 | _invoke(line) 17 | ensure 18 | output = $stdout.string 19 | lesspipe output 20 | $stdout = STDOUT 21 | end 22 | else 23 | _invoke(line) 24 | end 25 | 26 | end 27 | Process.waitpid(pid) 28 | end 29 | 30 | def _invoke 31 | raise NotImplementedError 32 | end 33 | 34 | def before_fork(&block) 35 | @before_fork = block 36 | end 37 | 38 | def after_fork(&block) 39 | @after_fork = block 40 | end 41 | 42 | def run_before_fork(&block) 43 | @before_fork.call if @before_fork 44 | end 45 | 46 | def run_after_fork(&block) 47 | @after_fork.call if @after_fork 48 | end 49 | end 50 | end 51 | end -------------------------------------------------------------------------------- /lib/rails/sh/helpers.rb: -------------------------------------------------------------------------------- 1 | module Rails 2 | module Sh 3 | module Helpers 4 | # copy from pry: https://github.com/pry/pry 5 | # 6 | # Create scrollable output via less! 7 | # 8 | # This command runs `less` in a subprocess, and gives you the IO to its STDIN pipe 9 | # so that you can communicate with it. 10 | # 11 | # Example: 12 | # 13 | # lesspipe do |less| 14 | # 50.times { less.puts "Hi mom!" } 15 | # end 16 | # 17 | # The default less parameters are: 18 | # * Allow colour 19 | # * Don't wrap lines longer than the screen 20 | # * Quit immediately (without paging) if there's less than one screen of text. 21 | # 22 | # You can change these options by passing a hash to `lesspipe`, like so: 23 | # 24 | # lesspipe(:wrap=>false) { |less| less.puts essay.to_s } 25 | # 26 | # It accepts the following boolean options: 27 | # :color => Allow ANSI colour codes? 28 | # :wrap => Wrap long lines? 29 | # :always => Always page, even if there's less than one page of text? 30 | # 31 | def lesspipe(*args) 32 | if args.any? and args.last.is_a?(Hash) 33 | options = args.pop 34 | else 35 | options = {} 36 | end 37 | 38 | output = args.first if args.any? 39 | 40 | params = [] 41 | params << "-R" unless options[:color] == false 42 | params << "-S" unless options[:wrap] == true 43 | params << "-F" unless options[:always] == true 44 | if options[:tail] == true 45 | params << "+\\>" 46 | $stderr.puts "Seeking to end of stream..." 47 | end 48 | params << "-X" 49 | 50 | IO.popen("less #{params * ' '}", "w") do |less| 51 | if output 52 | less.puts output 53 | else 54 | yield less 55 | end 56 | end 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/rails/sh/rails.rb: -------------------------------------------------------------------------------- 1 | module Rails 2 | module Sh 3 | module Rails 4 | extend Forkable 5 | 6 | class << self 7 | def init 8 | before_fork do 9 | ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base) 10 | end 11 | after_fork do 12 | ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base) 13 | end 14 | end 15 | 16 | def _invoke(line) 17 | reload! 18 | ARGV.clear 19 | ARGV.concat line.split(/\s+/) 20 | puts "\e[42m$ rails #{ARGV.join(" ")}\e[0m" 21 | require 'rails/commands' 22 | end 23 | 24 | def reload! 25 | ActionDispatch::Callbacks.new(Proc.new {}).call({}) 26 | end 27 | 28 | def sub_commands 29 | %w(generate destroy plugin benchmarker profiler 30 | console server dbconsole application runner) 31 | end 32 | end 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /lib/rails/sh/rake.rb: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'stringio' 3 | 4 | module Rails 5 | module Sh 6 | module Rake 7 | extend Forkable 8 | 9 | class << self 10 | def init 11 | $stdout = StringIO.new 12 | 13 | before_fork do 14 | ActiveRecord::Base.remove_connection if defined?(ActiveRecord::Base) 15 | end 16 | after_fork do 17 | ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base) 18 | end 19 | 20 | ::Rake.application = ::Rake::Application.new 21 | ::Rake.application.init 22 | ::Rake.application.load_rakefile 23 | ::Rake.application[:environment].invoke 24 | ensure 25 | $stdout = STDOUT 26 | end 27 | 28 | def _invoke(line) 29 | line ||= 'default' 30 | name, *args = line.split(/\s+/) 31 | args.each do |arg| 32 | env, value = arg.split('=') 33 | next unless env && !env.empty? && value && !value.empty? 34 | ENV[env] = value 35 | end 36 | ::Rake.application[name].invoke 37 | end 38 | 39 | def task_names 40 | ::Rake.application.tasks.map{|t| t.name} 41 | end 42 | end 43 | end 44 | end 45 | end -------------------------------------------------------------------------------- /rails-sh.gemspec: -------------------------------------------------------------------------------- 1 | # Generated by jeweler 2 | # DO NOT EDIT THIS FILE DIRECTLY 3 | # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' 4 | # -*- encoding: utf-8 -*- 5 | 6 | Gem::Specification.new do |s| 7 | s.name = "rails-sh" 8 | s.version = "1.5.2" 9 | 10 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 11 | s.authors = ["jugyo"] 12 | s.date = "2012-02-03" 13 | s.description = "The Rails Shell to execute sub commands of rails quickly." 14 | s.email = "jugyo.org@gmail.com" 15 | s.executables = ["rails-sh"] 16 | s.extra_rdoc_files = [ 17 | "LICENSE.txt", 18 | "README.rdoc" 19 | ] 20 | s.files = [ 21 | ".document", 22 | ".rspec", 23 | "Gemfile", 24 | "Gemfile.lock", 25 | "LICENSE.txt", 26 | "README.rdoc", 27 | "Rakefile", 28 | "VERSION", 29 | "bin/rails-sh", 30 | "lib/rails/sh.rb", 31 | "lib/rails/sh/bundler.rb", 32 | "lib/rails/sh/command.rb", 33 | "lib/rails/sh/commands.rb", 34 | "lib/rails/sh/forkable.rb", 35 | "lib/rails/sh/helpers.rb", 36 | "lib/rails/sh/rails.rb", 37 | "lib/rails/sh/rake.rb", 38 | "rails-sh.gemspec", 39 | "spec/rails/sh/command_spec.rb", 40 | "spec/rails/sh_spec.rb", 41 | "spec/spec_helper.rb" 42 | ] 43 | s.homepage = "http://github.com/jugyo/rails-sh" 44 | s.licenses = ["MIT"] 45 | s.require_paths = ["lib"] 46 | s.rubygems_version = "1.8.10" 47 | s.summary = "The Rails Shell" 48 | s.test_files = [ 49 | "spec/rails/sh/command_spec.rb", 50 | "spec/rails/sh_spec.rb", 51 | "spec/spec_helper.rb" 52 | ] 53 | 54 | if s.respond_to? :specification_version then 55 | s.specification_version = 3 56 | 57 | if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then 58 | s.add_development_dependency(%q, ["= 0.8.7"]) 59 | s.add_development_dependency(%q, ["~> 2.3.0"]) 60 | s.add_development_dependency(%q, ["~> 1.0.0"]) 61 | s.add_development_dependency(%q, ["~> 1.5.2"]) 62 | s.add_development_dependency(%q, [">= 0"]) 63 | else 64 | s.add_dependency(%q, ["= 0.8.7"]) 65 | s.add_dependency(%q, ["~> 2.3.0"]) 66 | s.add_dependency(%q, ["~> 1.0.0"]) 67 | s.add_dependency(%q, ["~> 1.5.2"]) 68 | s.add_dependency(%q, [">= 0"]) 69 | end 70 | else 71 | s.add_dependency(%q, ["= 0.8.7"]) 72 | s.add_dependency(%q, ["~> 2.3.0"]) 73 | s.add_dependency(%q, ["~> 1.0.0"]) 74 | s.add_dependency(%q, ["~> 1.5.2"]) 75 | s.add_dependency(%q, [">= 0"]) 76 | end 77 | end 78 | 79 | -------------------------------------------------------------------------------- /spec/rails/sh/command_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Rails::Sh::Command do 4 | before do 5 | Rails::Sh::Command.clear 6 | end 7 | 8 | context 'when define a command' do 9 | before do 10 | @block = lambda {} 11 | Rails::Sh::Command.define('foo', &@block) 12 | end 13 | 14 | it 'We can find it' do 15 | Rails::Sh::Command.find('foo').should eq(@block) 16 | end 17 | 18 | it 'We can find nil with wrong name' do 19 | Rails::Sh::Command.find('bar').should eq(nil) 20 | end 21 | 22 | it 'We can get command names' do 23 | Rails::Sh::Command.command_names.should =~ [:foo] 24 | end 25 | 26 | describe 'Command.[]' do 27 | it 'can get a command' do 28 | Rails::Sh::Command['foo'].should eq(@block) 29 | end 30 | end 31 | end 32 | 33 | describe '.completions' do 34 | context 'when command does not exist' do 35 | it 'completions is empty' do 36 | Rails::Sh::Command.completions.should be_empty 37 | end 38 | end 39 | 40 | context 'when commands exist' do 41 | before do 42 | Rails::Sh::Command.define('foo') {} 43 | Rails::Sh::Command.define('bar') {} 44 | end 45 | 46 | it 'completions is empty' do 47 | Rails::Sh::Command.completions.should =~ ['foo', 'bar'] 48 | end 49 | end 50 | end 51 | 52 | describe '.completion_proc' do 53 | before do 54 | ['foo', 'rails generate', 'rake routes', 'rake spec'].each { |c| Rails::Sh::Command.completions << c } 55 | end 56 | 57 | it 'return completions' do 58 | Rails::Sh::Command.completion_proc.call('foo').should =~ ['foo'] 59 | Rails::Sh::Command.completion_proc.call('rake').should =~ ['rake routes', 'rake spec'] 60 | end 61 | 62 | context 'with blocks for completion' do 63 | before do 64 | Rails::Sh::Command.completions.clear 65 | Rails::Sh::Command.completions << lambda { |line| 'block' } 66 | end 67 | 68 | it 'return completions' do 69 | Rails::Sh::Command.completion_proc.call('foo').should =~ ['block'] 70 | end 71 | end 72 | end 73 | end -------------------------------------------------------------------------------- /spec/rails/sh_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Rails::Sh do 4 | pending 5 | end 6 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) 2 | $LOAD_PATH.unshift(File.dirname(__FILE__)) 3 | require 'rspec' 4 | require 'rails/sh' 5 | 6 | # Requires supporting files with custom matchers and macros, etc, 7 | # in ./support/ and its subdirectories. 8 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} 9 | 10 | RSpec.configure do |config| 11 | 12 | end 13 | --------------------------------------------------------------------------------