Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/code/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def get_property_value(property)

def store_property_to_config(property, property_value, config)
config.add(property, property_value)

file = File.open ".codeconfig", "w"
file = File.open '.codeconfig', 'w+'
config.write file
file.close
end
Expand Down
10 changes: 9 additions & 1 deletion lib/code/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ def command_failed?
not $?.success?
end

def print(text)
STDOUT.print text
end

def puts(text)
Kernel.puts text
STDOUT.puts text
end

def gets
STDIN.gets
end

def noecho_gets
Expand Down
8 changes: 4 additions & 4 deletions spec/code/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module Code
module System
describe "#prompt" do
it "should print the prompt, then ask for and return the input" do
expect(System).to receive(:print).with("Test: ").and_return("")
expect(System).to receive(:gets).and_return("test_user")
expect(STDOUT).to receive(:print).with("Test: ").and_return("")
expect(STDIN).to receive(:gets).and_return("test_user")
input = System.prompt "Test"
expect(input).to eq "test_user"
end

it "should strip special characters from the input" do
allow(System).to receive(:print).and_return("")
allow(System).to receive(:gets).and_return("test\n")
allow(STDOUT).to receive(:print).and_return("")
allow(STDIN).to receive(:gets).and_return("test\n")

input = System.prompt ""
expect(input).to eq "test"
Expand Down