diff --git a/.gitignore b/.gitignore index c6ef2182b..cbd3b4731 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .idea - ++.DS_Store* diff --git a/00_hello/hello_spec.rb b/00_hello/hello_spec.rb index 3ffd5cce4..26075944a 100644 --- a/00_hello/hello_spec.rb +++ b/00_hello/hello_spec.rb @@ -16,7 +16,7 @@ # # You should see an error. **Don't get scared!** Try to read it and figure out what the computer wants to tell you. Somewhere on the first line it should say something like # -# no such file to load -- test-first-teaching/hello/hello (LoadError) +# cannot load such file -- test-first-teaching/hello/hello (LoadError) # # That means that it is looking for a file called `hello.rb` and can't find it. # @@ -36,7 +36,7 @@ # Failures: # # 1) the hello function says hello -# Failure/Error: hello.should == "Hello!" +# Failure/Error: expect(hello).to eq("Hello!") # NameError: # undefined local variable or method `hello' for # # # ./hello/hello_spec.rb:5:in `block (2 levels) in ' @@ -60,9 +60,9 @@ # Failures: # # 1) the hello function says hello -# Failure/Error: hello().should == "Hello!" +# Failure/Error: expect(hello).to eq("Hello!") # expected: "Hello!" -# got: nil (using ==) +# got: nil (compared using ==) # # ./hello/hello_spec.rb:5:in `block (2 levels) in ' # # This means that while it found the file, and it found the function, it's not returning anything! ("nil" is the Ruby way of saying "not anything".) @@ -82,9 +82,9 @@ # Now you should see an error like this: # # 1) the hello function says hello -# Failure/Error: hello().should == "Hello!" +# Failure/Error: expect(hello.to eq("Hello!") # expected: "Hello!" -# got: "whuh?" (using ==) +# got: "whuh?" (compared using ==) # # ./hello/hello_spec.rb:5:in `block (2 levels) in ' # # Correct this by changing "whuh?" to "Hello!". Save it. Run the test again. @@ -117,16 +117,16 @@ describe "the hello function" do it "says hello" do - hello.should == "Hello!" + expect(hello).to eq("Hello!") end end describe "the greet function" do it "says hello to someone" do - greet("Alice").should == "Hello, Alice!" + expect(greet("Alice")).to eq("Hello, Alice!") end it "says hello to someone else" do - greet("Bob").should == "Hello, Bob!" + expect(greet("Bob")).to eq("Hello, Bob!") end end diff --git a/00_hello/index.html b/00_hello/index.html index bd5cc9084..e4eb3d6b8 100644 --- a/00_hello/index.html +++ b/00_hello/index.html @@ -51,7 +51,7 @@

Watch it fail

You should see an error. Don't get scared! Try to read it and figure out what the computer wants to tell you. Somewhere on the first line it should say something like

-
no such file to load -- test-first-teaching/hello/hello (LoadError)
+
cannot load such file -- test-first-teaching/hello/hello (LoadError)
 

That means that it is looking for a file called hello.rb and can't find it.

@@ -73,7 +73,7 @@

Watch it fail

Failures: 1) the hello function says hello - Failure/Error: hello.should == "Hello!" + Failure/Error: expect(hello).to eq("Hello!") NameError: undefined local variable or method `hello' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001009b8808> # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>' @@ -99,9 +99,9 @@

Watch it fail

Failures: 1) the hello function says hello - Failure/Error: hello().should == "Hello!" + Failure/Error: expect(hello).to eq("Hello!") expected: "Hello!" - got: nil (using ==) + got: nil (compared using ==) # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
@@ -123,9 +123,9 @@

Watch it fail

Now you should see an error like this:

1) the hello function says hello
-   Failure/Error: hello().should == "Hello!"
+   Failure/Error: expect(hello).to eq("Hello!")
      expected: "Hello!"
-          got: "whuh?" (using ==)
+          got: "whuh?" (compared using ==)
    # ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
 
@@ -164,17 +164,17 @@

Tests

describe "the hello function" do it "says hello" do - hello.should == "Hello!" + expect(hello).to eq("Hello!") end end describe "the greet function" do it "says hello to someone" do - greet("Alice").should == "Hello, Alice!" + expect(greet("Alice")).to eq("Hello, Alice!") end it "says hello to someone else" do - greet("Bob").should == "Hello, Bob!" + expect(greet("Bob")).to eq("Hello, Bob!") end end diff --git a/01_temperature/index.html b/01_temperature/index.html index 3b6014315..fc87b405d 100644 --- a/01_temperature/index.html +++ b/01_temperature/index.html @@ -62,19 +62,19 @@

Tests

describe "#ftoc" do it "converts freezing temperature" do - ftoc(32).should == 0 + expect(ftoc(32)).to eq(0) end it "converts boiling temperature" do - ftoc(212).should == 100 + expect(ftoc(212)).to eq(100) end it "converts body temperature" do - ftoc(98.6).should == 37 + expect(ftoc(98.6)).to eq(37) end it "converts arbitrary temperature" do - ftoc(68).should == 20 + expect(ftoc(68)).to eq(20) end end @@ -82,19 +82,19 @@

Tests

describe "#ctof" do it "converts freezing temperature" do - ctof(0).should == 32 + expect(ctof(0)).to eq(32) end it "converts boiling temperature" do - ctof(100).should == 212 + expect(ctof(100)).to eq(212) end it "converts arbitrary temperature" do - ctof(20).should == 68 + expect(ctof(20)).to eq(68) end it "converts body temperature" do - ctof(37).should be_within(0.1).of(98.6) + expect(ctof(37)).to be_within(0.1).of(98.6) # Why do we need to use be_within? # See http://www.ruby-forum.com/topic/169330 # and http://en.wikipedia.org/wiki/IEEE_754-2008 diff --git a/01_temperature/temperature_spec.rb b/01_temperature/temperature_spec.rb index 6cad3701c..7e92a54dc 100644 --- a/01_temperature/temperature_spec.rb +++ b/01_temperature/temperature_spec.rb @@ -22,19 +22,19 @@ describe "#ftoc" do it "converts freezing temperature" do - ftoc(32).should == 0 + expect(ftoc(32)).to eq(0) end it "converts boiling temperature" do - ftoc(212).should == 100 + expect(ftoc(212)).to eq(100) end it "converts body temperature" do - ftoc(98.6).should == 37 + expect(ftoc(98.6)).to eq(37) end it "converts arbitrary temperature" do - ftoc(68).should == 20 + expect(ftoc(68)).to eq(20) end end @@ -42,19 +42,19 @@ describe "#ctof" do it "converts freezing temperature" do - ctof(0).should == 32 + expect(ctof(0)).to eq(32) end it "converts boiling temperature" do - ctof(100).should == 212 + expect(ctof(100)).to eq(212) end it "converts arbitrary temperature" do - ctof(20).should == 68 + expect(ctof(20)).to eq(68) end it "converts body temperature" do - ctof(37).should be_within(0.1).of(98.6) + expect(ctof(37)).to be_within(0.1).of(98.6) # Why do we need to use be_within? # See http://www.ruby-forum.com/topic/169330 # and http://en.wikipedia.org/wiki/IEEE_754-2008 diff --git a/02_calculator/calculator_spec.rb b/02_calculator/calculator_spec.rb index 29c91f64e..fef7e9d00 100644 --- a/02_calculator/calculator_spec.rb +++ b/02_calculator/calculator_spec.rb @@ -37,39 +37,39 @@ describe "add" do it "adds 0 and 0" do - add(0,0).should == 0 + expect(add(0,0)).to eq(0) end it "adds 2 and 2" do - add(2,2).should == 4 + expect(add(2,2)).to eq(4) end it "adds positive numbers" do - add(2,6).should == 8 + expect(add(2,6)).to eq(8) end end describe "subtract" do it "subtracts numbers" do - subtract(10,4).should == 6 + expect(subtract(10,4)).to eq(6) end end describe "sum" do it "computes the sum of an empty array" do - sum([]).should == 0 + expect(sum([])).to eq(0) end it "computes the sum of an array of one number" do - sum([7]).should == 7 + expect(sum([7])).to eq(7) end it "computes the sum of an array of two numbers" do - sum([7,11]).should == 18 + expect(sum([7,11])).to eq(18) end it "computes the sum of an array of many numbers" do - sum([1,3,5,7,9]).should == 25 + expect(sum([1,3,5,7,9])).to eq(25) end end @@ -82,7 +82,7 @@ it "multiplies two numbers" it "multiplies several numbers" - + end describe "#power" do diff --git a/02_calculator/index.html b/02_calculator/index.html index 037732e40..b8c612f4e 100644 --- a/02_calculator/index.html +++ b/02_calculator/index.html @@ -78,39 +78,39 @@

Tests

describe "add" do it "adds 0 and 0" do - add(0,0).should == 0 + expect(add(0,0)).to eq(0) end it "adds 2 and 2" do - add(2,2).should == 4 + expect(add(2,2)).to eq(4) end it "adds positive numbers" do - add(2,6).should == 8 + expect(add(2,6)).to eq(8) end end describe "subtract" do it "subtracts numbers" do - subtract(10,4).should == 6 + expect(subtract(10,4)).to eq(6) end end describe "sum" do it "computes the sum of an empty array" do - sum([]).should == 0 + expect(sum([])).to eq(0) end it "computes the sum of an array of one number" do - sum([7]).should == 7 + expect(sum([7])).to eq(7) end it "computes the sum of an array of two numbers" do - sum([7,11]).should == 18 + expect(sum([7,11])).to eq(18) end it "computes the sum of an array of many numbers" do - sum([1,3,5,7,9]).should == 25 + expect(sum([1,3,5,7,9])).to eq(25) end end diff --git a/03_simon_says/index.html b/03_simon_says/index.html index bfb8d6f29..74de726a0 100644 --- a/03_simon_says/index.html +++ b/03_simon_says/index.html @@ -55,27 +55,27 @@

Tests

describe "Simon says" do describe "echo" do it "should echo hello" do - echo("hello").should == "hello" + expect(echo("hello")).to eq("hello") end it "should echo bye" do - echo("bye").should == "bye" + expect(echo("bye")).to eq("bye") end end describe "shout" do it "should shout hello" do - shout("hello").should == "HELLO" + expect(shout("hello")).to eq("HELLO") end it "should shout multiple words" do - shout("hello world").should == "HELLO WORLD" + expect(shout("hello world")).to eq("HELLO WORLD") end end describe "repeat" do it "should repeat" do - repeat("hello").should == "hello hello" + expect(repeat("hello")).to eq("hello hello") end # Wait a second! How can you make the "repeat" method @@ -83,52 +83,52 @@

Tests

# # Hint: *default values* it "should repeat a number of times" do - repeat("hello", 3).should == "hello hello hello" + expect(repeat("hello", 3)).to eq("hello hello hello") end end describe "start_of_word" do it "returns the first letter" do - start_of_word("hello", 1).should == "h" + expect(start_of_word("hello", 1)).to eq("h") end it "returns the first two letters" do - start_of_word("Bob", 2).should == "Bo" + expect(start_of_word("Bob", 2)).to eq("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" + expect(start_of_word(s, 1)).to eq("a") + expect(start_of_word(s, 2)).to eq("ab") + expect(start_of_word(s, 3)).to eq("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" + expect(first_word("Hello World")).to eq("Hello") end it "tells us the first word of 'oh dear' is 'oh'" do - first_word("oh dear").should == "oh" + expect(first_word("oh dear")).to eq("oh") end end describe "titleize" do it "capitalizes a word" do - titleize("jaws").should == "Jaws" + expect(titleize("jaws")).to eq("Jaws") end it "capitalizes every word (aka title case)" do - titleize("david copperfield").should == "David Copperfield" + expect(titleize("david copperfield")).to eq("David Copperfield") end it "doesn't capitalize 'little words' in a title" do - titleize("war and peace").should == "War and Peace" + expect(titleize("war and peace")).to eq("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" + expect(titleize("the bridge over the river kwai")).to eq("The Bridge over the River Kwai") end end diff --git a/03_simon_says/simon_says_spec.rb b/03_simon_says/simon_says_spec.rb index 8dac0b9f0..2c62be76d 100644 --- a/03_simon_says/simon_says_spec.rb +++ b/03_simon_says/simon_says_spec.rb @@ -16,27 +16,27 @@ describe "Simon says" do describe "echo" do it "should echo hello" do - echo("hello").should == "hello" + expect(echo("hello")).to eq("hello") end it "should echo bye" do - echo("bye").should == "bye" + expect(echo("bye")).to eq("bye") end end describe "shout" do it "should shout hello" do - shout("hello").should == "HELLO" + expect(shout("hello")).to eq("HELLO") end it "should shout multiple words" do - shout("hello world").should == "HELLO WORLD" + expect(shout("hello world")).to eq("HELLO WORLD") end end describe "repeat" do it "should repeat" do - repeat("hello").should == "hello hello" + expect(repeat("hello")).to eq("hello hello") end # Wait a second! How can you make the "repeat" method @@ -44,52 +44,52 @@ # # Hint: *default values* it "should repeat a number of times" do - repeat("hello", 3).should == "hello hello hello" + expect(repeat("hello", 3)).to eq("hello hello hello") end end describe "start_of_word" do it "returns the first letter" do - start_of_word("hello", 1).should == "h" + expect(start_of_word("hello", 1)).to eq("h") end it "returns the first two letters" do - start_of_word("Bob", 2).should == "Bo" + expect(start_of_word("Bob", 2)).to eq("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" + expect(start_of_word(s, 1)).to eq("a") + expect(start_of_word(s, 2)).to eq("ab") + expect(start_of_word(s, 3)).to eq("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" + expect(first_word("Hello World")).to eq("Hello") end it "tells us the first word of 'oh dear' is 'oh'" do - first_word("oh dear").should == "oh" + expect(first_word("oh dear")).to eq("oh") end end describe "titleize" do it "capitalizes a word" do - titleize("jaws").should == "Jaws" + expect(titleize("jaws")).to eq("Jaws") end it "capitalizes every word (aka title case)" do - titleize("david copperfield").should == "David Copperfield" + expect(titleize("david copperfield")).to eq("David Copperfield") end it "doesn't capitalize 'little words' in a title" do - titleize("war and peace").should == "War and Peace" + expect(titleize("war and peace")).to eq("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" + expect(titleize("the bridge over the river kwai")).to eq("The Bridge over the River Kwai") end end diff --git a/04_pig_latin/index.html b/04_pig_latin/index.html index da46cb79d..b40830700 100644 --- a/04_pig_latin/index.html +++ b/04_pig_latin/index.html @@ -61,46 +61,46 @@

Tests

it "translates a word beginning with a vowel" do s = translate("apple") - s.should == "appleay" + expect(s).to eq("appleay") end it "translates a word beginning with a consonant" do s = translate("banana") - s.should == "ananabay" + expect(s).to eq("ananabay") end it "translates a word beginning with two consonants" do s = translate("cherry") - s.should == "errychay" + expect(s).to eq("errychay") end it "translates two words" do s = translate("eat pie") - s.should == "eatay iepay" + expect(s).to eq("eatay iepay") end it "translates a word beginning with three consonants" do - translate("three").should == "eethray" + expect(translate("three")).to eq("eethray") end it "counts 'sch' as a single phoneme" do s = translate("school") - s.should == "oolschay" + expect(s).to eq("oolschay") end it "counts 'qu' as a single phoneme" do s = translate("quiet") - s.should == "ietquay" + expect(s).to eq("ietquay") end it "counts 'qu' as a consonant even when it's preceded by a consonant" do s = translate("square") - s.should == "aresquay" + expect(s).to eq("aresquay") end it "translates many words" do s = translate("the quick brown fox") - s.should == "ethay ickquay ownbray oxfay" + expect(s).to eq("ethay ickquay ownbray oxfay") end # Test-driving bonus: diff --git a/04_pig_latin/pig_latin_spec.rb b/04_pig_latin/pig_latin_spec.rb index 86328f2a4..cc659edfd 100644 --- a/04_pig_latin/pig_latin_spec.rb +++ b/04_pig_latin/pig_latin_spec.rb @@ -23,46 +23,46 @@ it "translates a word beginning with a vowel" do s = translate("apple") - s.should == "appleay" + expect(s).to eq("appleay") end it "translates a word beginning with a consonant" do s = translate("banana") - s.should == "ananabay" + expect(s).to eq("ananabay") end it "translates a word beginning with two consonants" do s = translate("cherry") - s.should == "errychay" + expect(s).to eq("errychay") end it "translates two words" do s = translate("eat pie") - s.should == "eatay iepay" + expect(s).to eq("eatay iepay") end it "translates a word beginning with three consonants" do - translate("three").should == "eethray" + expect(translate("three")).to eq("eethray") end it "counts 'sch' as a single phoneme" do s = translate("school") - s.should == "oolschay" + expect(s).to eq("oolschay") end it "counts 'qu' as a single phoneme" do s = translate("quiet") - s.should == "ietquay" + expect(s).to eq("ietquay") end it "counts 'qu' as a consonant even when it's preceded by a consonant" do s = translate("square") - s.should == "aresquay" + expect(s).to eq("aresquay") end it "translates many words" do s = translate("the quick brown fox") - s.should == "ethay ickquay ownbray oxfay" + expect(s).to eq("ethay ickquay ownbray oxfay") end # Test-driving bonus: diff --git a/05_silly_blocks/index.html b/05_silly_blocks/index.html index e13df82de..ada51229b 100644 --- a/05_silly_blocks/index.html +++ b/05_silly_blocks/index.html @@ -54,28 +54,28 @@

Tests

result = reverser do "hello" end - result.should == "olleh" + expect(result).to eq("olleh") end it "reverses each word in the string returned by the default block" do result = reverser do "hello dolly" end - result.should == "olleh yllod" + expect(result).to eq("olleh yllod") end end describe "adder" do it "adds one to the value returned by the default block" do - adder do + expect(adder do 5 - end.should == 6 + end).to eq(6) end it "adds 3 to the value returned by the default block" do - adder(3) do + expect(adder(3) do 5 - end.should == 8 + end).to eq(8) end end @@ -85,7 +85,7 @@

Tests

repeater do block_was_executed = true end - block_was_executed.should == true + expect(block_was_executed).to eq(true) end it "executes the default block 3 times" do @@ -93,7 +93,7 @@

Tests

repeater(3) do n += 1 end - n.should == 3 + expect(n).to eq(3) end it "executes the default block 10 times" do @@ -101,7 +101,7 @@

Tests

repeater(10) do n += 1 end - n.should == 10 + expect(n).to eq(10) end end diff --git a/05_silly_blocks/silly_blocks_spec.rb b/05_silly_blocks/silly_blocks_spec.rb index 6a34b2cff..c64e3ef70 100644 --- a/05_silly_blocks/silly_blocks_spec.rb +++ b/05_silly_blocks/silly_blocks_spec.rb @@ -15,28 +15,28 @@ result = reverser do "hello" end - result.should == "olleh" + expect(result).to eq("olleh") end it "reverses each word in the string returned by the default block" do result = reverser do "hello dolly" end - result.should == "olleh yllod" + expect(result).to eq("olleh yllod") end end describe "adder" do it "adds one to the value returned by the default block" do - adder do + expect(adder do 5 - end.should == 6 + end).to eq(6) end it "adds 3 to the value returned by the default block" do - adder(3) do + expect(adder(3) do 5 - end.should == 8 + end).to eq(8) end end @@ -46,7 +46,7 @@ repeater do block_was_executed = true end - block_was_executed.should == true + expect(block_was_executed).to eq(true) end it "executes the default block 3 times" do @@ -54,7 +54,7 @@ repeater(3) do n += 1 end - n.should == 3 + expect(n).to eq(3) end it "executes the default block 10 times" do @@ -62,7 +62,7 @@ repeater(10) do n += 1 end - n.should == 10 + expect(n).to eq(10) end end diff --git a/06_performance_monitor/index.html b/06_performance_monitor/index.html index d50de4207..7e2dc0560 100644 --- a/06_performance_monitor/index.html +++ b/06_performance_monitor/index.html @@ -60,30 +60,30 @@

Tests

it "takes about 0 seconds to run an empty block" do elapsed_time = measure do end - elapsed_time.should be_within(0.1).of(0) + expect(elapsed_time).to be_within(0.1).of(0) end it "takes exactly 0 seconds to run an empty block (with stubs)" do - Time.stub(:now) { @eleven_am } + allow(Time).to receive(:now) { @eleven_am } elapsed_time = measure do end - elapsed_time.should == 0 + expect(elapsed_time).to eq(0) end it "takes about 1 second to run a block that sleeps for 1 second" do elapsed_time = measure do sleep 1 end - elapsed_time.should be_within(0.1).of(1) + expect(elapsed_time).to be_within(0.1).of(1) end it "takes exactly 1 second to run a block that sleeps for 1 second (with stubs)" do fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } elapsed_time = measure do fake_time += 60 # adds one minute to fake_time end - elapsed_time.should == 60 + expect(elapsed_time).to eq(60) end it "runs a block N times" do @@ -91,28 +91,28 @@

Tests

measure(4) do n += 1 end - n.should == 4 + expect(n).to eq(4) end it "returns the average time, not the total time, when running multiple times" do run_times = [8,6,5,7] fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } average_time = measure(4) do fake_time += run_times.pop end - average_time.should == 6.5 + expect(average_time).to eq(6.5) end it "returns the average time when running a random number of times for random lengths of time" do fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } number_of_times = rand(10) + 2 average_time = measure(number_of_times) do delay = rand(10) fake_time += delay end - average_time.should == (fake_time - @eleven_am).to_f/number_of_times + expect(average_time).to eq((fake_time - @eleven_am).to_f/number_of_times) end end diff --git a/06_performance_monitor/performance_monitor_spec.rb b/06_performance_monitor/performance_monitor_spec.rb index 04820d4f7..fa19f3e4b 100644 --- a/06_performance_monitor/performance_monitor_spec.rb +++ b/06_performance_monitor/performance_monitor_spec.rb @@ -20,30 +20,30 @@ it "takes about 0 seconds to run an empty block" do elapsed_time = measure do end - elapsed_time.should be_within(0.1).of(0) + expect(elapsed_time).to be_within(0.1).of(0) end it "takes exactly 0 seconds to run an empty block (with stubs)" do - Time.stub(:now) { @eleven_am } + allow(Time).to receive(:now) { @eleven_am } elapsed_time = measure do end - elapsed_time.should == 0 + expect(elapsed_time).to eq(0) end it "takes about 1 second to run a block that sleeps for 1 second" do elapsed_time = measure do sleep 1 end - elapsed_time.should be_within(0.1).of(1) + expect(elapsed_time).to be_within(0.1).of(1) end it "takes exactly 1 second to run a block that sleeps for 1 second (with stubs)" do fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } elapsed_time = measure do fake_time += 60 # adds one minute to fake_time end - elapsed_time.should == 60 + expect(elapsed_time).to eq(60) end it "runs a block N times" do @@ -51,28 +51,28 @@ measure(4) do n += 1 end - n.should == 4 + expect(n).to eq(4) end it "returns the average time, not the total time, when running multiple times" do run_times = [8,6,5,7] fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } average_time = measure(4) do fake_time += run_times.pop end - average_time.should == 6.5 + expect(average_time).to eq(6.5) end it "returns the average time when running a random number of times for random lengths of time" do fake_time = @eleven_am - Time.stub(:now) { fake_time } + allow(Time).to receive(:now) { fake_time } number_of_times = rand(10) + 2 average_time = measure(number_of_times) do delay = rand(10) fake_time += delay end - average_time.should == (fake_time - @eleven_am).to_f/number_of_times + expect(average_time).to eq((fake_time - @eleven_am).to_f/number_of_times) end end diff --git a/07_hello_friend/hello_friend_spec.rb b/07_hello_friend/hello_friend_spec.rb index 29b25730f..f6c07d376 100644 --- a/07_hello_friend/hello_friend_spec.rb +++ b/07_hello_friend/hello_friend_spec.rb @@ -40,7 +40,7 @@ # # 'Friend says hello' FAILED # expected: "Hello!", -# got: nil (using ==) +# got: nil (compared using ==) # ./friend_spec.rb:5: # # This means that there is a method, but it's not returning anything! ("nil" is the Ruby way of saying "not anything".) @@ -61,7 +61,7 @@ # # 'Friend says hello' FAILED # expected: "Hello!", -# got: "whuh?" (using ==) +# got: "whuh?" (compared using ==) # ./friend_spec.rb:5: # # Correct this by changing "whuh?" to "Hello!". Save it. Run the test again. @@ -92,10 +92,10 @@ describe Friend do it "says hello" do - Friend.new.greeting.should == "Hello!" + expect(Friend.new.greeting).to eq("Hello!") end it "says hello to someone" do - Friend.new.greeting("Bob").should == "Hello, Bob!" + expect(Friend.new.greeting("Bob")).to eq("Hello, Bob!") end end diff --git a/07_hello_friend/index.html b/07_hello_friend/index.html index 865ca858f..55f4e035c 100644 --- a/07_hello_friend/index.html +++ b/07_hello_friend/index.html @@ -77,7 +77,7 @@

Watch it fail some more

'Friend says hello' FAILED
 expected: "Hello!",
-     got: nil (using ==)
+     got: nil (compared using ==)
 ./friend_spec.rb:5:
 
@@ -100,7 +100,7 @@

Watch it fail yet again

'Friend says hello' FAILED
 expected: "Hello!",
-     got: "whuh?" (using ==)
+     got: "whuh?" (compared using ==)
 ./friend_spec.rb:5:
 
@@ -136,11 +136,11 @@

Tests

describe Friend do it "says hello" do - Friend.new.greeting.should == "Hello!" + expect(Friend.new.greeting).to eq("Hello!") end it "says hello to someone" do - Friend.new.greeting("Bob").should == "Hello, Bob!" + expect(Friend.new.greeting("Bob")).to eq("Hello, Bob!") end end diff --git a/08_book_titles/book_titles_spec.rb b/08_book_titles/book_titles_spec.rb index d7bc9a359..72822c6b8 100644 --- a/08_book_titles/book_titles_spec.rb +++ b/08_book_titles/book_titles_spec.rb @@ -23,52 +23,52 @@ describe 'title' do it 'should capitalize the first letter' do @book.title = "inferno" - @book.title.should == "Inferno" + expect(@book.title).to eq("Inferno") end it 'should capitalize every word' do @book.title = "stuart little" - @book.title.should == "Stuart Little" + expect(@book.title).to eq("Stuart Little") end describe 'should capitalize every word except...' do describe 'articles' do specify 'the' do @book.title = "alexander the great" - @book.title.should == "Alexander the Great" + expect(@book.title).to eq("Alexander the Great") end specify 'a' do @book.title = "to kill a mockingbird" - @book.title.should == "To Kill a Mockingbird" + expect(@book.title).to eq("To Kill a Mockingbird") end specify 'an' do @book.title = "to eat an apple a day" - @book.title.should == "To Eat an Apple a Day" + expect(@book.title).to eq("To Eat an Apple a Day") end end specify 'conjunctions' do @book.title = "war and peace" - @book.title.should == "War and Peace" + expect(@book.title).to eq("War and Peace") end specify 'prepositions' do @book.title = "love in the time of cholera" - @book.title.should == "Love in the Time of Cholera" + expect(@book.title).to eq("Love in the Time of Cholera") end end describe 'should always capitalize...' do specify 'I' do @book.title = "what i wish i knew when i was 20" - @book.title.should == "What I Wish I Knew When I Was 20" + expect(@book.title).to eq("What I Wish I Knew When I Was 20") end specify 'the first word' do @book.title = "the man in the iron mask" - @book.title.should == "The Man in the Iron Mask" + expect(@book.title).to eq("The Man in the Iron Mask") end end end diff --git a/08_book_titles/index.html b/08_book_titles/index.html index 50dfe0ddd..b5da4af8e 100644 --- a/08_book_titles/index.html +++ b/08_book_titles/index.html @@ -62,52 +62,52 @@

Tests

describe 'title' do it 'should capitalize the first letter' do @book.title = "inferno" - @book.title.should == "Inferno" + expect(@book.title).to eq("Inferno") end it 'should capitalize every word' do @book.title = "stuart little" - @book.title.should == "Stuart Little" + expect(@book.title).to eq("Stuart Little") end describe 'should capitalize every word except...' do describe 'articles' do specify 'the' do @book.title = "alexander the great" - @book.title.should == "Alexander the Great" + expect(@book.title).to eq("Alexander the Great") end specify 'a' do @book.title = "to kill a mockingbird" - @book.title.should == "To Kill a Mockingbird" + expect(@book.title).to eq("To Kill a Mockingbird") end specify 'an' do @book.title = "to eat an apple a day" - @book.title.should == "To Eat an Apple a Day" + expect(@book.title).to eq("To Eat an Apple a Day") end end specify 'conjunctions' do @book.title = "war and peace" - @book.title.should == "War and Peace" + expect(@book.title).to eq("War and Peace") end specify 'prepositions' do @book.title = "love in the time of cholera" - @book.title.should == "Love in the Time of Cholera" + expect(@book.title).to eq("Love in the Time of Cholera") end end describe 'should always capitalize...' do specify 'I' do @book.title = "what i wish i knew when i was 20" - @book.title.should == "What I Wish I Knew When I Was 20" + expect(@book.title).to eq("What I Wish I Knew When I Was 20") end specify 'the first word' do @book.title = "the man in the iron mask" - @book.title.should == "The Man in the Iron Mask" + expect(@book.title).to eq("The Man in the Iron Mask") end end end diff --git a/09_timer/index.html b/09_timer/index.html index f1ea5a720..fcf7a2c66 100644 --- a/09_timer/index.html +++ b/09_timer/index.html @@ -55,28 +55,28 @@

Tests

end it "should initialize to 0 seconds" do - @timer.seconds.should == 0 + expect(@timer.seconds).to eq(0) end describe 'time_string' do it "should display 0 seconds as 00:00:00" do @timer.seconds = 0 - @timer.time_string.should == "00:00:00" + expect(@timer.time_string).to eq("00:00:00") end it "should display 12 seconds as 00:00:12" do @timer.seconds = 12 - @timer.time_string.should == "00:00:12" + expect(@timer.time_string).to eq("00:00:12") end it "should display 66 seconds as 00:01:06" do @timer.seconds = 66 - @timer.time_string.should == "00:01:06" + expect(@timer.time_string).to eq("00:01:06") end it "should display 4000 seconds as 01:06:40" do @timer.seconds = 4000 - @timer.time_string.should == "01:06:40" + expect(@timer.time_string).to eq("01:06:40") end end @@ -87,13 +87,13 @@

Tests

# # describe 'padded' do # it 'pads zero' do - # @timer.padded(0).should == '00' + # expect(@timer.padded(0)).to eq('00') # end # it 'pads one' do - # @timer.padded(1).should == '01' + # expect(@timer.padded(1)).to eq('01') # end # it "doesn't pad a two-digit number" do - # @timer.padded(12).should == '12' + # expect(@timer.padded(12)).to eq('12') # end # end diff --git a/09_timer/timer_spec.rb b/09_timer/timer_spec.rb index d1baf90b3..40b33f23f 100644 --- a/09_timer/timer_spec.rb +++ b/09_timer/timer_spec.rb @@ -15,28 +15,28 @@ end it "should initialize to 0 seconds" do - @timer.seconds.should == 0 + expect(@timer.seconds).to eq(0) end describe 'time_string' do it "should display 0 seconds as 00:00:00" do @timer.seconds = 0 - @timer.time_string.should == "00:00:00" + expect(@timer.time_string).to eq("00:00:00") end it "should display 12 seconds as 00:00:12" do @timer.seconds = 12 - @timer.time_string.should == "00:00:12" + expect(@timer.time_string).to eq("00:00:12") end it "should display 66 seconds as 00:01:06" do @timer.seconds = 66 - @timer.time_string.should == "00:01:06" + expect(@timer.time_string).to eq("00:01:06") end it "should display 4000 seconds as 01:06:40" do @timer.seconds = 4000 - @timer.time_string.should == "01:06:40" + expect(@timer.time_string).to eq("01:06:40") end end @@ -47,13 +47,13 @@ # # describe 'padded' do # it 'pads zero' do - # @timer.padded(0).should == '00' + # expect(@timer.padded(0)).to eq('00') # end # it 'pads one' do - # @timer.padded(1).should == '01' + # expect(@timer.padded(1)).to eq('01') # end # it "doesn't pad a two-digit number" do - # @timer.padded(12).should == '12' + # expect(@timer.padded(12)).to eq('12') # end # end diff --git a/10_temperature_object/index.html b/10_temperature_object/index.html index a86e7b851..6c88c6e7f 100644 --- a/10_temperature_object/index.html +++ b/10_temperature_object/index.html @@ -62,44 +62,44 @@

Tests

describe "can be constructed with an options hash" do describe "in degrees fahrenheit" do it "at 50 degrees" do - Temperature.new(:f => 50).in_fahrenheit.should == 50 + expect(Temperature.new(:f => 50).in_fahrenheit).to eq(50) end describe "and correctly convert to celsius" do it "at freezing" do - Temperature.new(:f => 32).in_celsius.should == 0 + expect(Temperature.new(:f => 32).in_celsius).to eq(0) end it "at boiling" do - Temperature.new(:f => 212).in_celsius.should == 100 + expect(Temperature.new(:f => 212).in_celsius).to eq(100) end it "at body temperature" do - Temperature.new(:f => 98.6).in_celsius.should == 37 + expect(Temperature.new(:f => 98.6).in_celsius).to eq(37) end it "at an arbitrary temperature" do - Temperature.new(:f => 68).in_celsius.should == 20 + expect(Temperature.new(:f => 68).in_celsius).to eq(20) end end end describe "in degrees celsius" do it "at 50 degrees" do - Temperature.new(:c => 50).in_celsius.should == 50 + expect(Temperature.new(:c => 50).in_celsius).to eq(50) end describe "and correctly convert to fahrenheit" do it "at freezing" do - Temperature.new(:c => 0).in_fahrenheit.should == 32 + expect(Temperature.new(:c => 0).in_fahrenheit).to eq(32) end it "at boiling" do - Temperature.new(:c => 100).in_fahrenheit.should == 212 + expect(Temperature.new(:c => 100).in_fahrenheit).to eq(212) end it "at body temperature" do - Temperature.new(:c => 37).in_fahrenheit.should be_within(0.1).of(98.6) + expect(Temperature.new(:c => 37).in_fahrenheit).to be_within(0.1).of(98.6) # Why do we need to use be_within here? # See http://www.ruby-forum.com/topic/169330 # and http://groups.google.com/group/rspec/browse_thread/thread/f3ebbe3c313202bb @@ -116,13 +116,13 @@

Tests

describe "can be constructed via factory methods" do it "in degrees celsius" do - Temperature.from_celsius(50).in_celsius.should == 50 - Temperature.from_celsius(50).in_fahrenheit.should == 122 + expect(Temperature.from_celsius(50).in_celsius).to eq(50) + expect(Temperature.from_celsius(50).in_fahrenheit).to eq(122) end it "in degrees fahrenheit" do - Temperature.from_fahrenheit(50).in_fahrenheit.should == 50 - Temperature.from_fahrenheit(50).in_celsius.should == 10 + expect(Temperature.from_fahrenheit(50).in_fahrenheit).to eq(50) + expect(Temperature.from_fahrenheit(50).in_celsius).to eq(10) end end @@ -142,23 +142,23 @@

Tests

describe "Temperature subclasses" do describe "Celsius subclass" do it "is constructed in degrees celsius" do - Celsius.new(50).in_celsius.should == 50 - Celsius.new(50).in_fahrenheit.should == 122 + expect(Celsius.new(50).in_celsius).to eq(50) + expect(Celsius.new(50).in_fahrenheit).to eq(122) end it "is a Temperature subclass" do - Celsius.new(0).should be_a(Temperature) + expect(Celsius.new(0)).to be_a(Temperature) end end describe "Fahrenheit subclass" do it "is constructed in degrees fahrenheit" do - Fahrenheit.new(50).in_fahrenheit.should == 50 - Fahrenheit.new(50).in_celsius.should == 10 + expect(Fahrenheit.new(50).in_fahrenheit).to eq(50) + expect(Fahrenheit.new(50).in_celsius).to eq(10) end it "is a Temperature subclass" do - Fahrenheit.new(0).should be_a(Temperature) + expect(Fahrenheit.new(0)).to be_a(Temperature) end end end diff --git a/10_temperature_object/temperature_object_spec.rb b/10_temperature_object/temperature_object_spec.rb index fe21c1135..5c0af8685 100644 --- a/10_temperature_object/temperature_object_spec.rb +++ b/10_temperature_object/temperature_object_spec.rb @@ -24,44 +24,44 @@ describe "can be constructed with an options hash" do describe "in degrees fahrenheit" do it "at 50 degrees" do - Temperature.new(:f => 50).in_fahrenheit.should == 50 + expect(Temperature.new(:f => 50).in_fahrenheit).to eq(50) end describe "and correctly convert to celsius" do it "at freezing" do - Temperature.new(:f => 32).in_celsius.should == 0 + expect(Temperature.new(:f => 32).in_celsius).to eq(0) end it "at boiling" do - Temperature.new(:f => 212).in_celsius.should == 100 + expect(Temperature.new(:f => 212).in_celsius).to eq(100) end it "at body temperature" do - Temperature.new(:f => 98.6).in_celsius.should == 37 + expect(Temperature.new(:f => 98.6).in_celsius).to eq(37) end it "at an arbitrary temperature" do - Temperature.new(:f => 68).in_celsius.should == 20 + expect(Temperature.new(:f => 68).in_celsius).to eq(20) end end end describe "in degrees celsius" do it "at 50 degrees" do - Temperature.new(:c => 50).in_celsius.should == 50 + expect(Temperature.new(:c => 50).in_celsius).to eq(50) end describe "and correctly convert to fahrenheit" do it "at freezing" do - Temperature.new(:c => 0).in_fahrenheit.should == 32 + expect(Temperature.new(:c => 0).in_fahrenheit).to eq(32) end it "at boiling" do - Temperature.new(:c => 100).in_fahrenheit.should == 212 + expect(Temperature.new(:c => 100).in_fahrenheit).to eq(212) end it "at body temperature" do - Temperature.new(:c => 37).in_fahrenheit.should be_within(0.1).of(98.6) + expect(Temperature.new(:c => 37).in_fahrenheit).to be_within(0.1).of(98.6) # Why do we need to use be_within here? # See http://www.ruby-forum.com/topic/169330 # and http://groups.google.com/group/rspec/browse_thread/thread/f3ebbe3c313202bb @@ -78,13 +78,13 @@ describe "can be constructed via factory methods" do it "in degrees celsius" do - Temperature.from_celsius(50).in_celsius.should == 50 - Temperature.from_celsius(50).in_fahrenheit.should == 122 + expect(Temperature.from_celsius(50).in_celsius).to eq(50) + expect(Temperature.from_celsius(50).in_fahrenheit).to eq(122) end it "in degrees fahrenheit" do - Temperature.from_fahrenheit(50).in_fahrenheit.should == 50 - Temperature.from_fahrenheit(50).in_celsius.should == 10 + expect(Temperature.from_fahrenheit(50).in_fahrenheit).to eq(50) + expect(Temperature.from_fahrenheit(50).in_celsius).to eq(10) end end @@ -104,23 +104,23 @@ describe "Temperature subclasses" do describe "Celsius subclass" do it "is constructed in degrees celsius" do - Celsius.new(50).in_celsius.should == 50 - Celsius.new(50).in_fahrenheit.should == 122 + expect(Celsius.new(50).in_celsius).to eq(50) + expect(Celsius.new(50).in_fahrenheit).to eq(122) end it "is a Temperature subclass" do - Celsius.new(0).should be_a(Temperature) + expect(Celsius.new(0)).to be_a(Temperature) end end describe "Fahrenheit subclass" do it "is constructed in degrees fahrenheit" do - Fahrenheit.new(50).in_fahrenheit.should == 50 - Fahrenheit.new(50).in_celsius.should == 10 + expect(Fahrenheit.new(50).in_fahrenheit).to eq(50) + expect(Fahrenheit.new(50).in_celsius).to eq(10) end it "is a Temperature subclass" do - Fahrenheit.new(0).should be_a(Temperature) + expect(Fahrenheit.new(0)).to be_a(Temperature) end end end diff --git a/11_dictionary/dictionary_spec.rb b/11_dictionary/dictionary_spec.rb index 85f147ccf..f57bb3e9d 100644 --- a/11_dictionary/dictionary_spec.rb +++ b/11_dictionary/dictionary_spec.rb @@ -14,70 +14,70 @@ end it 'is empty when created' do - @d.entries.should == {} + expect(@d.entries).to eq({}) end it 'can add whole entries with keyword and definition' do @d.add('fish' => 'aquatic animal') - @d.entries.should == {'fish' => 'aquatic animal'} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => 'aquatic animal'}) + expect(@d.keywords).to eq(['fish']) end it 'add keywords (without definition)' do @d.add('fish') - @d.entries.should == {'fish' => nil} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => nil}) + expect(@d.keywords).to eq(['fish']) end it 'can check whether a given keyword exists' do - @d.include?('fish').should be_false + expect(@d.include?('fish')).to be false end it "doesn't cheat when checking whether a given keyword exists" do - @d.include?('fish').should be_false # if the method is empty, this test passes with nil returned + expect(@d.include?('fish')).to be false # if the method is empty, this test passes with nil returned @d.add('fish') - @d.include?('fish').should be_true # confirms that it actually checks - @d.include?('bird').should be_false # confirms not always returning true after add + expect(@d.include?('fish')).to be true # confirms that it actually checks + expect(@d.include?('bird')).to be false # confirms not always returning true after add end it "doesn't include a prefix that wasn't added as a word in and of itself" do @d.add('fish') - @d.include?('fi').should be_false + expect(@d.include?('fi')).to be false end it "doesn't find a word in empty dictionary" do - @d.find('fi').should be_empty # {} + expect(@d.find('fi')).to be_empty # {} end it 'finds nothing if the prefix matches nothing' do @d.add('fiend') @d.add('great') - @d.find('nothing').should be_empty + expect(@d.find('nothing')).to be_empty end it "finds an entry" do @d.add('fish' => 'aquatic animal') - @d.find('fish').should == {'fish' => 'aquatic animal'} + expect(@d.find('fish')).to eq({'fish' => 'aquatic animal'}) end it 'finds multiple matches from a prefix and returns the entire entry (keyword + definition)' do @d.add('fish' => 'aquatic animal') @d.add('fiend' => 'wicked person') @d.add('great' => 'remarkable') - @d.find('fi').should == {'fish' => 'aquatic animal', 'fiend' => 'wicked person'} + expect(@d.find('fi')).to eq({'fish' => 'aquatic animal', 'fiend' => 'wicked person'}) end it 'lists keywords alphabetically' do @d.add('zebra' => 'African land animal with stripes') @d.add('fish' => 'aquatic animal') @d.add('apple' => 'fruit') - @d.keywords.should == %w(apple fish zebra) + expect(@d.keywords).to eq(%w(apple fish zebra)) end it 'can produce printable output like so: [keyword] "definition"' do @d.add('zebra' => 'African land animal with stripes') @d.add('fish' => 'aquatic animal') @d.add('apple' => 'fruit') - @d.printable.should == %Q{[apple] "fruit"\n[fish] "aquatic animal"\n[zebra] "African land animal with stripes"} + expect(@d.printable).to eq(%Q{[apple] "fruit"\n[fish] "aquatic animal"\n[zebra] "African land animal with stripes"}) end end diff --git a/11_dictionary/index.html b/11_dictionary/index.html index 778d45ee2..4b4d4463f 100644 --- a/11_dictionary/index.html +++ b/11_dictionary/index.html @@ -53,71 +53,71 @@

Tests

end it 'is empty when created' do - @d.entries.should == {} + expect(@d.entries).to eq({}) end it 'can add whole entries with keyword and definition' do @d.add('fish' => 'aquatic animal') - @d.entries.should == {'fish' => 'aquatic animal'} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => 'aquatic animal'}) + expect(@d.keywords).to eq(['fish']) end it 'add keywords (without definition)' do @d.add('fish') - @d.entries.should == {'fish' => nil} - @d.keywords.should == ['fish'] + expect(@d.entries).to eq({'fish' => nil}) + expect(@d.keywords).to eq(['fish']) end it 'can check whether a given keyword exists' do - @d.include?('fish').should be_false + expect(@d.include?('fish').to be_false end it "doesn't cheat when checking whether a given keyword exists" do - @d.include?('fish').should be_false # if the method is empty, this test passes with nil returned + expect(@d.include?('fish')).to be_false # if the method is empty, this test passes with nil returned @d.add('fish') - @d.include?('fish').should be_true # confirms that it actually checks - @d.include?('bird').should be_false # confirms not always returning true after add + expect(@d.include?('fish')).to be_true # confirms that it actually checks + expect(@d.include?('bird')).to be_false # confirms not always returning true after add end it "doesn't include a prefix that wasn't added as a word in and of itself" do @d.add('fish') - @d.include?('fi').should be_false + expect(@d.include?('fi')).to be_false end it "doesn't find a word in empty dictionary" do - @d.find('fi').should be_empty # {} + expect(@d.find('fi')).to be_empty # {} end it 'finds nothing if the prefix matches nothing' do @d.add('fiend') @d.add('great') - @d.find('nothing').should be_empty + expect(@d.find('nothing')).to be_empty end it "finds an entry" do @d.add('fish' => 'aquatic animal') - @d.find('fish').should == {'fish' => 'aquatic animal'} + expect(@d.find('fish')).to eq({'fish' => 'aquatic animal'}) end it 'finds multiple matches from a prefix and returns the entire entry (keyword + definition)' do @d.add('fish' => 'aquatic animal') @d.add('fiend' => 'wicked person') @d.add('great' => 'remarkable') - @d.find('fi').should == {'fish' => 'aquatic animal', 'fiend' => 'wicked person'} + expect(@d.find('fi')).to eq({'fish' => 'aquatic animal', 'fiend' => 'wicked person'}) end it 'lists keywords alphabetically' do @d.add('zebra' => 'African land animal with stripes') @d.add('fish' => 'aquatic animal') @d.add('apple' => 'fruit') - @d.keywords.should == %w(apple fish zebra) + expect(@d.keywords).to eq(%w(apple fish zebra)) end it 'can produce printable output like so: [keyword] "definition"' do @d.add('zebra' => 'African land animal with stripes') @d.add('fish' => 'aquatic animal') @d.add('apple' => 'fruit') - @d.printable.should == %Q{[apple] "fruit"\n[fish] "aquatic animal"\n[zebra] "African land animal with stripes"} + expect(@d.printable).to eq(%Q{[apple] "fruit"\n[fish] "aquatic animal"\n[zebra] "African land animal with stripes"}) end end diff --git a/12_rpn_calculator/index.html b/12_rpn_calculator/index.html index b19f645d7..5237a7d4e 100644 --- a/12_rpn_calculator/index.html +++ b/12_rpn_calculator/index.html @@ -90,7 +90,7 @@

Tests

calculator.push(2) calculator.push(3) calculator.plus - calculator.value.should == 5 + expect(calculator.value).to eq(5) end it "adds three numbers" do @@ -98,16 +98,16 @@

Tests

calculator.push(3) calculator.push(4) calculator.plus - calculator.value.should == 7 + expect(calculator.value).to eq(7) calculator.plus - calculator.value.should == 9 + expect(calculator.value).to eq(9) end it "subtracts the second number from the first number" do calculator.push(2) calculator.push(3) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) end it "adds and subtracts" do @@ -115,9 +115,9 @@

Tests

calculator.push(3) calculator.push(4) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) calculator.plus - calculator.value.should == 1 + expect(calculator.value).to eq(1) end it "multiplies and divides" do @@ -125,9 +125,9 @@

Tests

calculator.push(3) calculator.push(4) calculator.divide - calculator.value.should == (3.0 / 4.0) + expect(calculator.value).to eq(3.0 / 4.0) calculator.times - calculator.value.should == 2.0 * (3.0 / 4.0) + expect(calculator.value).to eq(2.0 * (3.0 / 4.0)) end it "resolves operator precedence unambiguously" do @@ -137,7 +137,7 @@

Tests

calculator.plus calculator.push(3) calculator.times - calculator.value.should == (1+2)*3 + expect(calculator.value).to eq((1+2)*3) # 1 2 3 * + => 1 + (2 * 3) calculator.push(1) @@ -145,7 +145,7 @@

Tests

calculator.push(3) calculator.times calculator.plus - calculator.value.should == 1+(2*3) + expect(calculator.value).to eq(1+(2*3)) end it "fails informatively when there's not enough values stacked away" do @@ -168,23 +168,18 @@

Tests

# extra credit it "tokenizes a string" do - calculator.tokens("1 2 3 * + 4 5 - /").should == - [1, 2, 3, :*, :+, 4, 5, :-, :/] + expect(calculator.tokens("1 2 3 * + 4 5 - /")).to eq([1, 2, 3, :*, :+, 4, 5, :-, :/]) end # extra credit it "evaluates a string" do - calculator.evaluate("1 2 3 * +").should == - ((2 * 3) + 1) + expect(calculator.evaluate("1 2 3 * +")).to eq((2 * 3) + 1) - calculator.evaluate("4 5 -").should == - (4 - 5) + expect(calculator.evaluate("4 5 -")).to eq(4 - 5) - calculator.evaluate("2 3 /").should == - (2.0 / 3.0) + expect(calculator.evaluate("2 3 /")).to eq(2.0 / 3.0) - calculator.evaluate("1 2 3 * + 4 5 - /").should == - (1.0 + (2 * 3)) / (4 - 5) + expect(calculator.evaluate("1 2 3 * + 4 5 - /")).to eq((1.0 + (2 * 3)) / (4 - 5)) end end diff --git a/12_rpn_calculator/rpn_calculator_spec.rb b/12_rpn_calculator/rpn_calculator_spec.rb index 0b57f136b..a79d0a369 100644 --- a/12_rpn_calculator/rpn_calculator_spec.rb +++ b/12_rpn_calculator/rpn_calculator_spec.rb @@ -47,7 +47,7 @@ calculator.push(2) calculator.push(3) calculator.plus - calculator.value.should == 5 + expect(calculator.value).to eq(5) end it "adds three numbers" do @@ -55,16 +55,16 @@ calculator.push(3) calculator.push(4) calculator.plus - calculator.value.should == 7 + expect(calculator.value).to eq(7) calculator.plus - calculator.value.should == 9 + expect(calculator.value).to eq(9) end it "subtracts the second number from the first number" do calculator.push(2) calculator.push(3) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) end it "adds and subtracts" do @@ -72,9 +72,9 @@ calculator.push(3) calculator.push(4) calculator.minus - calculator.value.should == -1 + expect(calculator.value).to eq(-1) calculator.plus - calculator.value.should == 1 + expect(calculator.value).to eq(1) end it "multiplies and divides" do @@ -82,9 +82,9 @@ calculator.push(3) calculator.push(4) calculator.divide - calculator.value.should == (3.0 / 4.0) + expect(calculator.value).to eq(3.0 / 4.0) calculator.times - calculator.value.should == 2.0 * (3.0 / 4.0) + expect(calculator.value).to eq(2.0 * (3.0 / 4.0)) end it "resolves operator precedence unambiguously" do @@ -94,7 +94,7 @@ calculator.plus calculator.push(3) calculator.times - calculator.value.should == (1+2)*3 + expect(calculator.value).to eq((1+2)*3) # 1 2 3 * + => 1 + (2 * 3) calculator.push(1) @@ -102,7 +102,7 @@ calculator.push(3) calculator.times calculator.plus - calculator.value.should == 1+(2*3) + expect(calculator.value).to eq(1+(2*3)) end it "fails informatively when there's not enough values stacked away" do @@ -125,23 +125,18 @@ # extra credit it "tokenizes a string" do - calculator.tokens("1 2 3 * + 4 5 - /").should == - [1, 2, 3, :*, :+, 4, 5, :-, :/] + expect(calculator.tokens("1 2 3 * + 4 5 - /")).to eq([1, 2, 3, :*, :+, 4, 5, :-, :/]) end # extra credit it "evaluates a string" do - calculator.evaluate("1 2 3 * +").should == - ((2 * 3) + 1) + expect(calculator.evaluate("1 2 3 * +")).to eq((2 * 3) + 1) - calculator.evaluate("4 5 -").should == - (4 - 5) + expect(calculator.evaluate("4 5 -")).to eq(4 - 5) - calculator.evaluate("2 3 /").should == - (2.0 / 3.0) + expect(calculator.evaluate("2 3 /")).to eq(2.0 / 3.0) - calculator.evaluate("1 2 3 * + 4 5 - /").should == - (1.0 + (2 * 3)) / (4 - 5) + expect(calculator.evaluate("1 2 3 * + 4 5 - /")).to eq( (1.0 + (2 * 3)) / (4 - 5) ) end end diff --git a/13_xml_document/index.html b/13_xml_document/index.html index e7fbeb7ad..900ff72d5 100644 --- a/13_xml_document/index.html +++ b/13_xml_document/index.html @@ -62,57 +62,57 @@

Tests

end it "renders an empty tag" do - @xml.hello.should == "<hello/>" + expect(@xml.hello).to eq("<hello/>") end it "renders a tag with attributes" do - @xml.hello(:name => 'dolly').should == "<hello name='dolly'/>" + expect(@xml.hello(:name => 'dolly')).to eq("<hello name='dolly'/>") end it "renders a randomly named tag" do tag_name = (1..8).map{|i| ('a'..'z').to_a[rand(26)]}.join - @xml.send(tag_name).should == "<#{tag_name}/>" + expect(@xml.send(tag_name)).to eq("<#{tag_name}/>") end it "renders block with text inside" do - @xml.hello do + expect(@xml.hello do "dolly" - end.should == "<hello>dolly</hello>" + end).to eq("<hello>dolly</hello>") end it "nests one level" do - @xml.hello do + expect(@xml.hello do @xml.goodbye - end.should == "<hello><goodbye/></hello>" + end).to eq("<hello><goodbye/></hello>") end it "nests several levels" do xml = XmlDocument.new - xml.hello do + expect(xml.hello do xml.goodbye do xml.come_back do xml.ok_fine(:be => "that_way") end end - end.should == "<hello><goodbye><come_back><ok_fine be='that_way'/></come_back></goodbye></hello>" + end).to eq("<hello><goodbye><come_back><ok_fine be='that_way'/></come_back></goodbye></hello>") end it "indents" do @xml = XmlDocument.new(true) - @xml.hello do + expect(@xml.hello do @xml.goodbye do @xml.come_back do @xml.ok_fine(:be => "that_way") end end - end.should == + end).to eq( "<hello>\n" + " <goodbye>\n" + " <come_back>\n" + " <ok_fine be='that_way'/>\n" + " </come_back>\n" + " </goodbye>\n" + - "</hello>\n" + "</hello>\n") end end diff --git a/13_xml_document/xml_document_spec.rb b/13_xml_document/xml_document_spec.rb index 88ce3ae69..fa1995818 100644 --- a/13_xml_document/xml_document_spec.rb +++ b/13_xml_document/xml_document_spec.rb @@ -22,56 +22,56 @@ end it "renders an empty tag" do - @xml.hello.should == "" + expect(@xml.hello).to eq("") end it "renders a tag with attributes" do - @xml.hello(:name => 'dolly').should == "" + expect(@xml.hello(:name => 'dolly')).to eq("") end it "renders a randomly named tag" do tag_name = (1..8).map{|i| ('a'..'z').to_a[rand(26)]}.join - @xml.send(tag_name).should == "<#{tag_name}/>" + expect(@xml.send(tag_name)).to eq("<#{tag_name}/>") end it "renders block with text inside" do - @xml.hello do + expect(@xml.hello do "dolly" - end.should == "dolly" + end).to eq("dolly") end it "nests one level" do - @xml.hello do + expect(@xml.hello do @xml.goodbye - end.should == "" + end).to eq("") end it "nests several levels" do xml = XmlDocument.new - xml.hello do + expect(xml.hello do xml.goodbye do xml.come_back do xml.ok_fine(:be => "that_way") end end - end.should == "" + end).to eq("") end it "indents" do @xml = XmlDocument.new(true) - @xml.hello do + expect(@xml.hello do @xml.goodbye do @xml.come_back do @xml.ok_fine(:be => "that_way") end end - end.should == + end).to eq( "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + - "\n" + "\n") end end diff --git a/14_array_extensions/array_extensions_spec.rb b/14_array_extensions/array_extensions_spec.rb index a755ac899..4c6b075a2 100755 --- a/14_array_extensions/array_extensions_spec.rb +++ b/14_array_extensions/array_extensions_spec.rb @@ -12,25 +12,25 @@ describe "#sum" do it "has a #sum method" do - [].should respond_to(:sum) + expect([]).to respond_to(:sum) end it "should be 0 for an empty array" do - [].sum.should == 0 + expect([].sum).to eq(0) end it "should add all of the elements" do - [1,2,4].sum.should == 7 + expect([1,2,4].sum).to eq(7) end end describe '#square' do it "does nothing to an empty array" do - [].square.should == [] + expect([].square).to eq([]) end it "returns a new array containing the squares of each element" do - [1,2,3].square.should == [1,4,9] + expect([1,2,3].square).to eq([1,4,9]) end end @@ -38,7 +38,7 @@ it "squares each element of the original array" do array = [1,2,3] array.square! - array.should == [1,4,9] + expect(array).to eq([1,4,9]) end end diff --git a/14_array_extensions/index.html b/14_array_extensions/index.html index 28005d4ca..ebbe06502 100644 --- a/14_array_extensions/index.html +++ b/14_array_extensions/index.html @@ -51,25 +51,25 @@

Tests

describe "#sum" do it "has a #sum method" do - [].should respond_to(:sum) + expect([]).to respond_to(:sum) end it "should be 0 for an empty array" do - [].sum.should == 0 + expect([].sum).to eq(0) end it "should add all of the elements" do - [1,2,4].sum.should == 7 + expect([1,2,4].sum).to eq(7) end end describe '#square' do it "does nothing to an empty array" do - [].square.should == [] + expect([].square).to eq([]) end it "returns a new array containing the squares of each element" do - [1,2,3].square.should == [1,4,9] + expect([1,2,3].square).to eq([1,4,9]) end end @@ -77,7 +77,7 @@

Tests

it "squares each element of the original array" do array = [1,2,3] array.square! - array.should == [1,4,9] + expect(array).to eq([1,4,9]) end end diff --git a/15_in_words/in_words_spec.rb b/15_in_words/in_words_spec.rb index d9872e767..1f5768575 100644 --- a/15_in_words/in_words_spec.rb +++ b/15_in_words/in_words_spec.rb @@ -23,80 +23,80 @@ describe Fixnum do it "reads 0 to 9" do - 0.in_words.should == 'zero' - 1.in_words.should == 'one' - 2.in_words.should == 'two' - 3.in_words.should == 'three' - 4.in_words.should == 'four' - 5.in_words.should == 'five' - 6.in_words.should == 'six' - 7.in_words.should == 'seven' - 8.in_words.should == 'eight' - 9.in_words.should == 'nine' + expect(0.in_words).to eq('zero') + expect(1.in_words).to eq('one') + expect(2.in_words).to eq('two') + expect(3.in_words).to eq('three') + expect(4.in_words).to eq('four') + expect(5.in_words).to eq('five') + expect(6.in_words).to eq('six') + expect(7.in_words).to eq('seven') + expect(8.in_words).to eq('eight') + expect(9.in_words).to eq('nine') end it "reads 10 to 12" do - 10.in_words.should == 'ten' - 11.in_words.should == 'eleven' - 12.in_words.should == 'twelve' + expect(10.in_words).to eq('ten') + expect(11.in_words).to eq('eleven') + expect(12.in_words).to eq ('twelve') end it "reads teens" do - 13.in_words.should == 'thirteen' - 14.in_words.should == 'fourteen' - 15.in_words.should == 'fifteen' - 16.in_words.should == 'sixteen' - 17.in_words.should == 'seventeen' - 18.in_words.should == 'eighteen' - 19.in_words.should == 'nineteen' + expect(13.in_words).to eq('thirteen') + expect(14.in_words).to eq('fourteen') + expect(15.in_words).to eq('fifteen') + expect(16.in_words).to eq('sixteen') + expect(17.in_words).to eq('seventeen') + expect(18.in_words).to eq('eighteen') + expect(19.in_words).to eq('nineteen') end it "reads tens" do - 20.in_words.should == 'twenty' - 30.in_words.should == 'thirty' - 40.in_words.should == 'forty' - 50.in_words.should == 'fifty' - 60.in_words.should == 'sixty' - 70.in_words.should == 'seventy' - 80.in_words.should == 'eighty' - 90.in_words.should == 'ninety' + expect(20.in_words).to eq('twenty') + expect(30.in_words).to eq('thirty') + expect(40.in_words).to eq('forty') + expect(50.in_words).to eq('fifty') + expect(60.in_words).to eq('sixty') + expect(70.in_words).to eq('seventy') + expect(80.in_words).to eq('eighty') + expect(90.in_words).to eq('ninety') end it "reads various other numbers less than 100" do - 20.in_words.should == 'twenty' - 77.in_words.should == 'seventy seven' - 99.in_words.should == 'ninety nine' + expect(20.in_words).to eq('twenty') + expect(77.in_words).to eq('seventy seven') + expect(99.in_words).to eq('ninety nine') end it "reads hundreds" do - 100.in_words.should == 'one hundred' - 200.in_words.should == 'two hundred' - 300.in_words.should == 'three hundred' - 123.in_words.should == 'one hundred twenty three' - 777.in_words.should == 'seven hundred seventy seven' - 818.in_words.should == 'eight hundred eighteen' - 512.in_words.should == 'five hundred twelve' - 999.in_words.should == 'nine hundred ninety nine' + expect(100.in_words).to eq('one hundred') + expect(200.in_words).to eq('two hundred') + expect(300.in_words).to eq('three hundred') + expect(123.in_words).to eq('one hundred twenty three') + expect(777.in_words).to eq('seven hundred seventy seven') + expect(818.in_words).to eq('eight hundred eighteen') + expect(512.in_words).to eq('five hundred twelve') + expect(999.in_words).to eq('nine hundred ninety nine') end it "reads thousands" do - 1000.in_words.should == 'one thousand' - 32767.in_words.should == 'thirty two thousand seven hundred sixty seven' - 32768.in_words.should == 'thirty two thousand seven hundred sixty eight' + expect(1000.in_words).to eq('one thousand') + expect(32767.in_words).to eq('thirty two thousand seven hundred sixty seven') + expect(32768.in_words).to eq('thirty two thousand seven hundred sixty eight') end it "reads millions" do - 10_000_001.in_words.should == 'ten million one' + expect(10_000_001.in_words).to eq('ten million one') end it "reads billions" do - 1_234_567_890.in_words.should == 'one billion two hundred thirty four million five hundred sixty seven thousand eight hundred ninety' + expect(1_234_567_890.in_words).to eq('one billion two hundred thirty four million five hundred sixty seven thousand eight hundred ninety') end it "reads trillions" do - 1_000_000_000_000.in_words.should == 'one trillion' - 1_000_000_000_001.in_words.should == 'one trillion one' - 1_888_259_040_036.in_words.should == 'one trillion eight hundred eighty eight billion two hundred fifty nine million forty thousand thirty six' + expect(1_000_000_000_000.in_words).to eq('one trillion') + expect(1_000_000_000_001.in_words).to eq('one trillion one') + expect(1_888_259_040_036.in_words).to eq('one trillion eight hundred eighty eight billion two hundred fifty nine million forty thousand thirty six') end end diff --git a/15_in_words/index.html b/15_in_words/index.html index 6525174c1..e235d4796 100644 --- a/15_in_words/index.html +++ b/15_in_words/index.html @@ -63,80 +63,80 @@

Tests

describe Fixnum do it "reads 0 to 9" do - 0.in_words.should == 'zero' - 1.in_words.should == 'one' - 2.in_words.should == 'two' - 3.in_words.should == 'three' - 4.in_words.should == 'four' - 5.in_words.should == 'five' - 6.in_words.should == 'six' - 7.in_words.should == 'seven' - 8.in_words.should == 'eight' - 9.in_words.should == 'nine' + expect(0.in_words).to eq('zero') + expect(1.in_words).to eq('one') + expect(2.in_words).to eq('two') + expect(3.in_words).to eq('three') + expect(4.in_words).to eq('four') + expect(5.in_words).to eq('five') + expect(6.in_words).to eq('six') + expect(7.in_words).to eq('seven') + expect(8.in_words).to eq('eight') + expect(9.in_words).to eq('nine') end it "reads 10 to 12" do - 10.in_words.should == 'ten' - 11.in_words.should == 'eleven' - 12.in_words.should == 'twelve' + expect(10.in_words).to eq('ten') + expect(11.in_words).to eq('eleven') + expect(12.in_words).to eq('twelve') end it "reads teens" do - 13.in_words.should == 'thirteen' - 14.in_words.should == 'fourteen' - 15.in_words.should == 'fifteen' - 16.in_words.should == 'sixteen' - 17.in_words.should == 'seventeen' - 18.in_words.should == 'eighteen' - 19.in_words.should == 'nineteen' + expect(13.in_words).to eq('thirteen') + expect(14.in_words).to eq('fourteen') + expect(15.in_words).to eq('fifteen') + expect(16.in_words).to eq('sixteen') + expect(17.in_words).to eq('seventeen') + expect(18.in_words).to eq('eighteen') + expect(19.in_words).to eq('nineteen') end it "reads tens" do - 20.in_words.should == 'twenty' - 30.in_words.should == 'thirty' - 40.in_words.should == 'forty' - 50.in_words.should == 'fifty' - 60.in_words.should == 'sixty' - 70.in_words.should == 'seventy' - 80.in_words.should == 'eighty' - 90.in_words.should == 'ninety' + expect(20.in_words).to eq('twenty') + expect(30.in_words).to eq('thirty') + expect(40.in_words).to eq('forty') + expect(50.in_words).to eq('fifty') + expect(60.in_words).to eq('sixty') + expect(70.in_words).to eq('seventy') + expect(80.in_words).to eq('eighty') + expect(90.in_words).to eq('ninety') end it "reads various other numbers less than 100" do - 20.in_words.should == 'twenty' - 77.in_words.should == 'seventy seven' - 99.in_words.should == 'ninety nine' + expect(20.in_words).to eq('twenty') + expect(77.in_words).to eq('seventy seven') + expect(99.in_words).to eq('ninety nine') end it "reads hundreds" do - 100.in_words.should == 'one hundred' - 200.in_words.should == 'two hundred' - 300.in_words.should == 'three hundred' - 123.in_words.should == 'one hundred twenty three' - 777.in_words.should == 'seven hundred seventy seven' - 818.in_words.should == 'eight hundred eighteen' - 512.in_words.should == 'five hundred twelve' - 999.in_words.should == 'nine hundred ninety nine' + expect(100.in_words).to eq('one hundred') + expect(200.in_words).to eq('two hundred') + expect(300.in_words).to eq('three hundred') + expect(123.in_words).to eq('one hundred twenty three') + expect(777.in_words).to eq('seven hundred seventy seven') + expect(818.in_words).to eq('eight hundred eighteen') + expect(512.in_words).to eq('five hundred twelve') + expect(999.in_words).to eq('nine hundred ninety nine') end it "reads thousands" do - 1000.in_words.should == 'one thousand' - 32767.in_words.should == 'thirty two thousand seven hundred sixty seven' - 32768.in_words.should == 'thirty two thousand seven hundred sixty eight' + expect(1000.in_words).to eq('one thousand') + expect(32767.in_words).to eq('thirty two thousand seven hundred sixty seven') + expect(32768.in_words).to eq('thirty two thousand seven hundred sixty eight') end it "reads millions" do - 10_000_001.in_words.should == 'ten million one' + expect(10_000_001.in_words).to eq('ten million one') end it "reads billions" do - 1_234_567_890.in_words.should == 'one billion two hundred thirty four million five hundred sixty seven thousand eight hundred ninety' + expect(1_234_567_890.in_words).to eq('one billion two hundred thirty four million five hundred sixty seven thousand eight hundred ninety') end it "reads trillions" do - 1_000_000_000_000.in_words.should == 'one trillion' - 1_000_000_000_001.in_words.should == 'one trillion one' - 1_888_259_040_036.in_words.should == 'one trillion eight hundred eighty eight billion two hundred fifty nine million forty thousand thirty six' + expect(1_000_000_000_000.in_words).to eq('one trillion') + expect(1_000_000_000_001.in_words).to eq('one trillion one') + expect(1_888_259_040_036.in_words).to eq('one trillion eight hundred eighty eight billion two hundred fifty nine million forty thousand thirty six') end end diff --git a/Gemfile b/Gemfile index 3821439e2..4831cf1c1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,9 @@ source "https://rubygems.org" gem "rake" -gem "rspec", ">=2.0" +gem "rspec", "~>3.0" + +# So you can use binding.pry anywhere in your +# script to freeze time. This happens when the +# specs run too +gem "pry-byebug" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..1f62661aa --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,41 @@ +GEM + remote: https://rubygems.org/ + specs: + byebug (5.0.0) + columnize (= 0.9.0) + coderay (1.1.0) + columnize (0.9.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) + pry-byebug (3.2.0) + byebug (~> 5.0) + pry (~> 0.10) + rake (10.4.2) + rspec (3.1.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + rspec-mocks (~> 3.1.0) + rspec-core (3.1.7) + rspec-support (~> 3.1.0) + rspec-expectations (3.1.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.1.0) + rspec-mocks (3.1.3) + rspec-support (~> 3.1.0) + rspec-support (3.1.2) + slop (3.6.0) + +PLATFORMS + ruby + +DEPENDENCIES + pry-byebug + rake + rspec (~> 3.0) + +BUNDLED WITH + 1.10.5 diff --git a/README.md b/README.md new file mode 100644 index 000000000..706b785e9 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +Test First Ruby -- RSpec 3 Edition +========== + +See [testfirst.org/learn_ruby](http://testfirst.org/learn_ruby#install) for more information about how this will work. These test-first Ruby challenges have been forked from [https://github.com/alexch/learn_ruby](https://github.com/alexch/learn_ruby) and updated to use RSpec 3 instead of RSpec 2. + + +### On a High Level + +Basically, you will fork this repository and then clone it onto your local computer. For each of the exercises, you will run the specs from the command line to see what tests you need to make pass (see the link above for more info about how to do that). You will then write the Ruby code that makes those tests pass and move on to the next exercise. + + +### Getting Started + +To get started, jump into the `/00_hello` directory, run `bundle install` from the command line to install the required libraries, and then view the `hello_spec.rb` file in your text editor. The comments at the top will kick things off. + +Basically, this is "error-driven development"... you'll keep running tests, hitting error messages, fixing those messages, running more tests... It is meant to not only test your Ruby skills but also get you comfortable seeing big scary looking stack traces and error messages. Most of the development you do at first will be just like this. In fact, most of *all* development is error-driven. So get comfortable with it! + + +### Finishing Up + +When you're done, push your changes to your forked repo and then submit a pull request to this repo so we can see your solutions and verify that you've completed the exercises. + + +### Troubleshooting + +* Don't name any of your directories with spaces in them! It will give you horribly frustrating error messages and code hates dealing with spaces. For instance: + + ```language-bash + # BAD: + /Documents/My Homework/ruby + + # GOOD: + /Documents/my_homework/ruby + ``` + + +### Credit + +This is forked from [https://github.com/alexch/learn_ruby](https://github.com/alexch/learn_ruby), its original creator. diff --git a/Rakefile b/Rakefile index 22162469d..e024f9b81 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ # This Rakefile has all the right settings to run the tests inside each lab -gem 'rspec', '~>2' + require 'rspec/core/rake_task' task :default => :spec @@ -8,6 +8,6 @@ desc "run tests for this lab" RSpec::Core::RakeTask.new do |task| lab = Rake.application.original_dir task.pattern = "#{lab}/*_spec.rb" - task.rspec_opts = [ "-I#{lab}", "-I#{lab}/solution", '-f documentation', '-r ./rspec_config'] + task.rspec_opts = [ "-I#{Shellwords.escape(lab)}", "-I#{Shellwords.escape(lab)}/solution", '-f documentation', '-r ./rspec_config'] task.verbose = false end diff --git a/rspec_config.rb b/rspec_config.rb index fbc53440c..d3b116831 100644 --- a/rspec_config.rb +++ b/rspec_config.rb @@ -1,3 +1,6 @@ +# Allow people to use binding.pry with the pry-byebug gem +require 'pry-byebug' + RSpec.configure do |c| c.fail_fast = true c.color = true