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
# Put your name (or username/alias) between the quotes | |
name = "Caley" | |
# Put your favorite fruit between the quotes | |
favorite_fruit = "Braeburn Apples" | |
puts "Hi! My name is #{name} and my favorite fruit is #{favorite_fruit}" |
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
<script type="text/javascript" src="<%=Url.Content("~/path/to/tiny_mce.js") %>"</script> |
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
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil | |
begin | |
nil.some_method_nil_doesnt_know_about | |
rescue Exception => ex | |
puts ex.class | |
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
def test_strings_are_unique_objects | |
a = "a string" | |
b = "a string" | |
assert_equal __, a == b | |
assert_equal __, a.object_id == b.object_id | |
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
def test_method_names_become_symbols | |
symbols_as_strings = Symbol.all_symbols.map { |x| x.to_s } | |
assert_equal true, symbols_as_strings.include?("test_method_names_become_symbols") | |
end | |
# THINK ABOUT IT: | |
# | |
# Why do we convert the list of symbols to strings and then compare | |
# against the string value rather than against symbols? |
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
111 def test_slash_b_anchors_to_a_word_boundary | |
112 assert_equal "vines", "bovine vines"[/\bvine./] | |
113 assert_equal "super dooper", "super dooper pooper scooper"[/\bsuper\s\S+/] | |
114 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
def test_calling_global_methods_without_parentheses | |
result = my_global_method 2, 3 | |
assert_equal 5, result | |
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
def text(a,b) | |
a + b | |
end | |
lm = lambda { |n| n.upcase } |
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
def upcase(text): | |
upper = text.upper() | |
return upper | |
@upcase | |
def regular_text(a,b) | |
a + b | |
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
require 'spec_helper' | |
describe PagesController do | |
render_views | |
describe "GET 'home'" do | |
it "should be successful" do | |
get 'home' | |
response.should be_success | |
end |
OlderNewer