capistrano_rails_console 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in capistrano_rails_console.gemspec
4
4
  gemspec
5
+
6
+ gem "capistrano-spec", :github => "timoschilling/capistrano-spec"
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Capistrano Rails Console
1
+ # Capistrano Rails Console [![Build Status](https://travis-ci.org/timoschilling/capistrano_rails_console.png?branch=master)](https://travis-ci.org/timoschilling/capistrano_rails_console)
2
2
 
3
3
  Open a rails console the first app server.
4
4
 
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require "rspec"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new("spec") do |spec|
7
+ spec.pattern = "spec/**/*_spec.rb"
8
+ end
9
+
10
+ task :default => :spec
@@ -20,4 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency "capistrano", "~> 2"
21
21
 
22
22
  gem.add_development_dependency "rake"
23
+ gem.add_development_dependency "rspec"
24
+ gem.add_development_dependency "capistrano-spec"
23
25
  end
@@ -1,14 +1,24 @@
1
- require "capistrano/configuration"
1
+ require "capistrano"
2
2
  require "capistrano_rails_console/rails"
3
3
 
4
- Capistrano::Configuration.instance(:must_exist).load do
5
- namespace :rails do
6
- desc "Open a rails console the first app server"
7
- task :console, :roles => :app do
8
- hostname = find_servers_for_task(current_task).first
4
+ module CapistranoRailsConsole
5
+ module Recipes
6
+ def self.load_into(configuration)
7
+ configuration.load do
8
+ namespace :rails do
9
+ desc "Open a rails console the first app server"
10
+ task :console, :roles => :app do
11
+ hostname = find_servers_for_task(current_task).first
9
12
 
10
- console_command = CapistranoRailsConsole::Rails.console_command % rails_env
11
- exec "ssh -l #{user} #{hostname} -p #{port} -t 'cd #{current_path} && #{console_command}'"
13
+ console_command = CapistranoRailsConsole::Rails.console_command % rails_env
14
+ run_locally "ssh -l #{user} #{hostname} -p #{port} -t 'cd #{current_path} && #{console_command}'"
15
+ end
16
+ end
17
+ end
12
18
  end
13
19
  end
14
20
  end
21
+
22
+ if Capistrano::Configuration.instance
23
+ CapistranoRailsConsole.load_into(Capistrano::Configuration.instance)
24
+ end
@@ -1,3 +1,3 @@
1
1
  module CapistranoRailsConsole
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ describe CapistranoRailsConsole::Rails do
4
+ describe ".version" do
5
+ it "should require 'rails/version'" do
6
+ described_class.should_receive(:require).once.with("rails/version")
7
+ described_class.version rescue nil
8
+ end
9
+
10
+ it "should raise an exception if can not require 'rails/version'" do
11
+ expect { described_class.version }.to raise_error
12
+ end
13
+
14
+ it "should return the value of Rails::VERSION::MAJOR" do
15
+ stub_const "Rails::VERSION::MAJOR", 3
16
+ described_class.stub :require
17
+ described_class.version.should be 3
18
+ end
19
+
20
+ it "should raise an exception if Rails::VERSION::MAJOR is not defined" do
21
+ described_class.stub :require
22
+ expect { described_class.version }.to raise_error
23
+ end
24
+ end
25
+
26
+ describe ".console_command" do
27
+ it "should call .version" do
28
+ described_class.should_receive(:version).once
29
+ described_class.console_command
30
+ end
31
+
32
+ it "should return the Rails 2 command" do
33
+ described_class.stub :version => 2
34
+ described_class.console_command.should eq "./script/console %s"
35
+ end
36
+
37
+ it "should return the Rails 3 command" do
38
+ described_class.stub :version => 3
39
+ described_class.console_command.should eq "rails console %s"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+ require "capistrano/shell"
3
+
4
+ describe CapistranoRailsConsole::Recipes, "loaded into a configuration" do
5
+ describe "rails:console" do
6
+ before do
7
+ [:rails_env, :user, :current_path].each do |key|
8
+ configuration.set key, "#{key}"
9
+ end
10
+ configuration.set :port, 22
11
+ configuration.role :app, "example.com"
12
+ end
13
+
14
+ let :configuration do
15
+ configuration = Capistrano::Configuration.new
16
+ described_class.load_into configuration
17
+ configuration.extend Capistrano::Spec::ConfigurationExtension
18
+ end
19
+
20
+ it "defines rails:console" do
21
+ configuration.find_task('rails:console').should_not be_nil
22
+ end
23
+
24
+ it "should call 'CapistranoRailsConsole::Rails.console_command'" do
25
+ CapistranoRailsConsole::Rails.should_receive(:console_command).once.and_return("")
26
+ configuration.find_and_execute_task "rails:console"
27
+ end
28
+
29
+ it "should run the remote command" do
30
+ CapistranoRailsConsole::Rails.stub(:console_command => "command %s")
31
+ configuration.find_and_execute_task "rails:console"
32
+ configuration.should have_run_locally "ssh -l user example.com -p 22 -t 'cd current_path && command rails_env'"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ require "rspec"
2
+ require "capistrano"
3
+ require "capistrano-spec"
4
+ require "capistrano_rails_console/recipes"
5
+
6
+ RSpec.configure do |config|
7
+ config.include Capistrano::Spec::Matchers
8
+ config.include Capistrano::Spec::Helpers
9
+ config.filter_run :focus => true
10
+ config.run_all_when_everything_filtered = true
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_rails_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,38 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: capistrano-spec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  description: Open a rails console the first app server.
47
79
  email:
48
80
  - timo@schilling.io
@@ -59,6 +91,9 @@ files:
59
91
  - lib/capistrano_rails_console.rb
60
92
  - lib/capistrano_rails_console/rails.rb
61
93
  - lib/capistrano_rails_console/recipes.rb
94
+ - spec/rails_spec.rb
95
+ - spec/recipes_spec.rb
96
+ - spec/spec_helper.rb
62
97
  homepage: http://github.com/timoschilling/capistrano_rails_console
63
98
  licenses: []
64
99
  post_install_message:
@@ -73,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
108
  version: '0'
74
109
  segments:
75
110
  - 0
76
- hash: -505841522537028888
111
+ hash: 4308426827508875195
77
112
  required_rubygems_version: !ruby/object:Gem::Requirement
78
113
  none: false
79
114
  requirements:
@@ -82,11 +117,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
117
  version: '0'
83
118
  segments:
84
119
  - 0
85
- hash: -505841522537028888
120
+ hash: 4308426827508875195
86
121
  requirements: []
87
122
  rubyforge_project:
88
123
  rubygems_version: 1.8.24
89
124
  signing_key:
90
125
  specification_version: 3
91
126
  summary: Open a rails console the first app server.
92
- test_files: []
127
+ test_files:
128
+ - spec/rails_spec.rb
129
+ - spec/recipes_spec.rb
130
+ - spec/spec_helper.rb