This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Console loads a new IRB session after loading the :default group, and can optionally load another group that you pass as an argument, i.e. `bundle console development`.
- Loading branch information
Showing
4 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
require File.expand_path('../../spec_helper', __FILE__) | ||
|
||
describe "bundle console" do | ||
before :each do | ||
install_gemfile <<-G | ||
source "file://#{gem_repo1}" | ||
gem "rack" | ||
gem "activesupport", :group => :test | ||
gem "rack_middleware", :group => :development | ||
G | ||
end | ||
|
||
it "starts IRB with the default group loaded" do | ||
bundle "console" do |input| | ||
input.puts("puts RACK") | ||
input.puts("exit") | ||
end | ||
out.should include("0.9.1") | ||
end | ||
|
||
it "doesn't load any other groups" do | ||
bundle "console" do |input| | ||
input.puts("puts ACTIVESUPPORT") | ||
input.puts("exit") | ||
end | ||
out.should include("NameError") | ||
end | ||
|
||
describe "when given a group" do | ||
it "loads the given group" do | ||
bundle "console test" do |input| | ||
input.puts("puts ACTIVESUPPORT") | ||
input.puts("exit") | ||
end | ||
out.should include("2.3.5") | ||
end | ||
|
||
it "loads the default group" do | ||
bundle "console test" do |input| | ||
input.puts("puts RACK") | ||
input.puts("exit") | ||
end | ||
out.should include("0.9.1") | ||
end | ||
|
||
it "doesn't load other groups" do | ||
bundle "console test" do |input| | ||
input.puts("puts RACK_MIDDLEWARE") | ||
input.puts("exit") | ||
end | ||
out.should include("NameError") | ||
end | ||
end | ||
|
||
describe "when locked" do | ||
before :each do | ||
bundle :lock | ||
end | ||
|
||
it "starts IRB with the default group loaded" do | ||
bundle :console do |input| | ||
input.puts("puts RACK") | ||
input.puts("exit") | ||
end | ||
out.should include("0.9.1") | ||
end | ||
|
||
it "doesn't load any other groups" do | ||
bundle :console do |input| | ||
input.puts("puts ACTIVESUPPORT") | ||
input.puts("exit") | ||
end | ||
out.should include("NameError") | ||
end | ||
|
||
describe "and given a group" do | ||
it "loads the given group" do | ||
bundle "console test" do |input| | ||
input.puts("puts ACTIVESUPPORT") | ||
input.puts("exit") | ||
end | ||
out.should include("2.3.5") | ||
end | ||
|
||
it "loads the default group" do | ||
bundle "console test" do |input| | ||
input.puts("puts RACK") | ||
input.puts("exit") | ||
end | ||
out.should include("0.9.1") | ||
end | ||
|
||
it "doesn't load other groups" do | ||
bundle "console test" do |input| | ||
input.puts("puts RACK_MIDDLEWARE") | ||
input.puts("exit") | ||
end | ||
out.should include("NameError") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class IO | ||
def read_available_bytes(chunk_size = 1024, select_timeout = 5) | ||
buffer = [] | ||
|
||
while self.class.select([self], nil, nil, select_timeout) | ||
begin | ||
buffer << self.readpartial(chunk_size) | ||
rescue(EOFError) | ||
break | ||
end | ||
end | ||
|
||
return buffer.join | ||
end | ||
end |