capistrano_rails_console 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/Rakefile +9 -0
- data/capistrano_rails_console.gemspec +2 -0
- data/lib/capistrano_rails_console/recipes.rb +18 -8
- data/lib/capistrano_rails_console.rb +1 -1
- data/spec/rails_spec.rb +42 -0
- data/spec/recipes_spec.rb +35 -0
- data/spec/spec_helper.rb +11 -0
- metadata +42 -4
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
require "capistrano
|
1
|
+
require "capistrano"
|
2
2
|
require "capistrano_rails_console/rails"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
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
|
data/spec/rails_spec.rb
ADDED
@@ -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
|
data/spec/spec_helper.rb
ADDED
@@ -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
|
+
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:
|
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:
|
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
|