capistrano_rails_console 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.5.3
4
+
5
+ * don't require username or port [@spikegrobstein, #2]
6
+
3
7
  ## v0.5.2
4
8
 
5
9
  * test integration in `cap`
data/Rakefile CHANGED
@@ -3,20 +3,24 @@ require "bundler/gem_tasks"
3
3
  require "rspec"
4
4
  require "rspec/core/rake_task"
5
5
 
6
- RSpec::Core::RakeTask.new("spec") do |spec|
6
+ RSpec::Core::RakeTask.new("test:spec") do |spec|
7
7
  spec.pattern = "spec/**/*_spec.rb"
8
8
  end
9
9
 
10
- desc "Run integration test"
11
- task :integration do
12
- puts
13
- puts "Start integration test"
14
- unless `cap -T` =~ /rails:console/
15
- puts "Integration test fails!"
16
- exit!
17
- else
18
- puts "Integration test successfully!"
10
+ namespace :test do
11
+ desc "Run integration test"
12
+ task :integration do
13
+ puts
14
+ puts "Start integration test"
15
+ unless `cap -T` =~ /cap\ rails:console/
16
+ puts "Integration test fails!"
17
+ exit!
18
+ else
19
+ puts "Integration test successfully!"
20
+ end
19
21
  end
20
22
  end
21
23
 
22
- task :default => [:spec, :integration]
24
+ desc "Run integration tests and specs"
25
+ task :test => ["test:spec", "test:integration"]
26
+ task :default => :test
@@ -11,7 +11,13 @@ module CapistranoRailsConsole
11
11
  hostname = find_servers_for_task(current_task).first
12
12
 
13
13
  console_command = CapistranoRailsConsole::Rails.console_command % rails_env
14
- run_locally "ssh -l #{user} #{hostname} -p #{port} -t 'cd #{current_path} && #{console_command}'"
14
+ local_ssh_command = ["ssh"]
15
+ local_ssh_command << "-l #{user}" if fetch(:user, nil)
16
+ local_ssh_command << hostname
17
+ local_ssh_command << "-p #{port}" if fetch(:port, nil)
18
+ local_ssh_command << "-t 'cd #{current_path} && #{console_command}'"
19
+
20
+ run_locally(local_ssh_command.join(" "))
15
21
  end
16
22
  end
17
23
  end
@@ -1,3 +1,3 @@
1
1
  module CapistranoRailsConsole
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -4,11 +4,10 @@ require "capistrano/shell"
4
4
  describe CapistranoRailsConsole::Recipes, "loaded into a configuration" do
5
5
  describe "rails:console" do
6
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
7
  configuration.role :app, "example.com"
8
+ configuration.set :rails_env, "rails_env"
9
+ configuration.set :current_path, "current_path"
10
+ CapistranoRailsConsole::Rails.stub(:console_command => "command %s")
12
11
  end
13
12
 
14
13
  let :configuration do
@@ -17,19 +16,55 @@ describe CapistranoRailsConsole::Recipes, "loaded into a configuration" do
17
16
  configuration.extend Capistrano::Spec::ConfigurationExtension
18
17
  end
19
18
 
20
- it "defines rails:console" do
21
- configuration.find_task('rails:console').should_not be_nil
19
+ context "normal operations" do
20
+ before do
21
+ configuration.set :user, "user"
22
+ configuration.set :port, 22
23
+ end
24
+
25
+ it "defines rails:console" do
26
+ configuration.find_task('rails:console').should_not be_nil
27
+ end
28
+
29
+ it "should call 'CapistranoRailsConsole::Rails.console_command'" do
30
+ CapistranoRailsConsole::Rails.should_receive(:console_command).once.and_return("")
31
+ configuration.find_and_execute_task "rails:console"
32
+ end
33
+
34
+ it "should run the remote command" do
35
+ configuration.find_and_execute_task "rails:console"
36
+ configuration.should have_run_locally "ssh -l user example.com -p 22 -t 'cd current_path && command rails_env'"
37
+ end
22
38
  end
23
39
 
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"
40
+ context "when port is not defined" do
41
+ before do
42
+ configuration.set :user, "user"
43
+ end
44
+
45
+ it "should not blow up" do
46
+ lambda { configuration.find_and_execute_task('rails:console') }.should_not raise_error
47
+ end
48
+
49
+ it "should not include the port in the command" do
50
+ configuration.find_and_execute_task "rails:console"
51
+ configuration.should have_run_locally "ssh -l user example.com -t 'cd current_path && command rails_env'"
52
+ end
27
53
  end
28
54
 
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'"
55
+ context "when the user is not defined" do
56
+ before do
57
+ configuration.set :port, 22
58
+ end
59
+
60
+ it "should not blow up" do
61
+ lambda { configuration.find_and_execute_task('rails:console') }.should_not raise_error
62
+ end
63
+
64
+ it "shoudl not include the login in the path" do
65
+ configuration.find_and_execute_task "rails:console"
66
+ configuration.should have_run_locally "ssh example.com -p 22 -t 'cd current_path && command rails_env'"
67
+ end
33
68
  end
34
69
  end
35
70
  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.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-17 00:00:00.000000000 Z
12
+ date: 2013-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: -1881473115402274885
114
+ hash: -2525387992721803318
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -1881473115402274885
123
+ hash: -2525387992721803318
124
124
  requirements: []
125
125
  rubyforge_project:
126
126
  rubygems_version: 1.8.24