Reputation: 5
Here's the code:
require_relative "simon_says"
describe "simon says" do
describe "echo" do
it "should echo hello" do
echo("hello").should == "hello"
end
it "should echo bye" do
echo("bye").should == "bye"
end
end
describe "shout" do
it "should shout hello" do
shout("hello").should == "HELLO"
end
it "should shout multiple words" do
shout("hello world").should == "HELLO WORLD"
end
end
describe "repeat" do
it "should repeat" do
repeat("hello").should == "hello hello"
end
# Wait a second! How can you make the "repeat" method
# take one *or* two arguments?
#
# Hint: *default values*
it "should repeat a number of times" do
repeat("hello", 3).should == "hello hello hello"
end
end
describe "start_of_word" do
it "returns the first letter" do
start_of_word("hello", 1).should == "h"
end
it "returns the first two letters" do
start_of_word("Bob", 2).should == "Bo"
end
it "returns the first several letters" do
s = "abcdefg"
start_of_word(s, 1).should == "a"
start_of_word(s, 2).should == "ab"
start_of_word(s, 3).should == "abc"
end
end
describe "first_word" do
it "tells us the first word of 'Hello World' is 'Hello'" do
first_word("Hello World").should == "Hello"
end
it "tells us the first word of 'oh dear' is 'oh'" do
first_word("oh dear").should == "oh"
end
end
describe "titleize" do
it "capitalizes a word" do
titleize("jaws").should == "Jaws"
end
it "capitalizes every word (aka title case)" do
titleize("david copperfield").should == "David Copperfield"
end
it "doesn't capitalize 'little words' in a title" do
titleize("war and peace").should == "War and Peace"
end
it "does capitalize 'little words' at the start of a title" do
titleize("the bridge over the river kwai").should == "The Bridge over the River Kwai"
end
end
end
But when i run this, it says No examples found. Can anyone help me?
Upvotes: 0
Views: 3470
Reputation: 41
If you dragged the file into your terminal and the rspec noticed the file, i suggest you to work on the main system directory such as /Documents folder, what i noticed was that terminal apps sometimes require the whole file path to process unless it's in system directories.
Upvotes: 0
Reputation: 422
(sorry for not seeing this earlier - I hope you kept with it)
that error is when you rspec the wrong file. if you do the lib/simon_says in rspec you'll get the "no examples found" try it with the file in spec.
If you go to terminal and just type rspec (space after c) then drag 03_simon_says_spec.rb to terminal you'll get the entire path
for example: rspec /Users/james/mainTestFolder/spec/03_simon_says_spec.rb
and it will find the lib/03_simon_says.rb correctly
Upvotes: 2