forked from learn-co-students/greeting-cli-ruby-intro-000
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aea726e
commit 3c5317c
Showing
9 changed files
with
151 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ tags: | |
- cli | ||
languages: | ||
- ruby | ||
resources: 0 | ||
resources: 0 |
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,34 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
coderay (1.1.0) | ||
diff-lcs (1.2.5) | ||
method_source (0.8.2) | ||
pry (0.10.1) | ||
coderay (~> 1.1.0) | ||
method_source (~> 0.8.1) | ||
slop (~> 3.4) | ||
rspec (3.3.0) | ||
rspec-core (~> 3.3.0) | ||
rspec-expectations (~> 3.3.0) | ||
rspec-mocks (~> 3.3.0) | ||
rspec-core (3.3.2) | ||
rspec-support (~> 3.3.0) | ||
rspec-expectations (3.3.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.3.0) | ||
rspec-mocks (3.3.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.3.0) | ||
rspec-support (3.3.0) | ||
slop (3.6.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
pry | ||
rspec | ||
|
||
BUNDLED WITH | ||
1.10.6 |
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
require_relative "../lib/greeting" | ||
require_relative "../lib/greeting.rb" | ||
|
||
puts "Hi! I'm HAL, what's your name?" | ||
|
||
user_name = gets.chomp | ||
greeting(user_name) | ||
# code your CLI here! |
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
def greeting(name) | ||
puts "Hello #{name}. It's nice to meet you." | ||
end | ||
# code the #greeting method here! |
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,19 @@ | ||
require_relative "../lib/greeting.rb" | ||
|
||
describe './lib/greeting.rb' do | ||
it 'defines a greeting method' do | ||
expect(defined?(greeting)).to be_truthy | ||
end | ||
|
||
context '#greeting' do | ||
it 'takes in an argument of a persons name' do | ||
expect {greeting("Bobby")}.to_not raise_error | ||
end | ||
|
||
it 'greets the person whose name was passed in as an argument' do | ||
allow($stdout).to receive(:puts) | ||
output = capture_puts{ greeting("Sally") } | ||
expect(output).to include("Hello Sally. It's nice to meet you.") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require_relative "../lib/greeting.rb" | ||
|
||
describe './bin/greet executing a CLI Application' do | ||
it 'outputs a welcome message and asks the user for input' do | ||
allow($stdout).to receive(:puts) | ||
allow(self).to receive(:gets).and_return("Don") | ||
expect($stdout).to receive(:puts).with("Hi! I'm HAL, what's your name?"), "Make sure bin/greet has code that can output 'Hi! I'm HAL, what's your name?' exactly." | ||
run_file("./bin/greet") | ||
end | ||
|
||
it 'uses #gets.strip to capture the user input and set it equal to a variable called name' do | ||
allow($stdout).to receive(:puts) | ||
allow(self).to receive(:gets).and_return("Don") | ||
name = get_variable_from_file("./bin/greet", "name") | ||
expect(name).to eq("Don") | ||
run_file("./bin/greet") | ||
end | ||
|
||
it "calls on the #greeting method with an argument of the user's name" do | ||
allow($stdout).to receive(:puts) | ||
allow(self).to receive(:gets).and_return("Don") | ||
expect(self).to receive(:greeting).with("Don"), "Make sure the bin/greet file has code that calls the #greeting method with an argument of the user's name." | ||
run_file("./bin/greet") | ||
end | ||
|
||
it "calls on the #greeting method with an argument of the user's name and returns the new greeting, interpolating the user's name" do | ||
allow($stdout).to receive(:puts) | ||
allow(self).to receive(:gets).and_return("Don") | ||
output = capture_puts{ run_file("./bin/greet") } | ||
expect(output).to include("Hello Don. It's nice to meet you.") | ||
run_file("./bin/greet") | ||
end | ||
end |
Empty file.
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