Skip to content
Browse files

Initial Commit

  Gemfile, Rakefile, and Guardfile

  Specs for reference that cover variable assignment, booleans, nil, strings,
  and symbols
  • Loading branch information...
0 parents commit 987fea5f3b17cd3d6cb33a3ab7dbbd877a896131 @burtlo burtlo committed
Showing with 504 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +5 −0 Gemfile
  3. +25 −0 Gemfile.lock
  4. +6 −0 Guardfile
  5. +34 −0 README.md
  6. +6 −0 Rakefile
  7. +101 −0 spec/assignment_spec.rb
  8. +89 −0 spec/boolean_spec.rb
  9. +22 −0 spec/nil_spec.rb
  10. +168 −0 spec/strings_spec.rb
  11. +47 −0 spec/symbols_spec.rb
1 .gitignore
@@ -0,0 +1 @@
+.DS_Store
5 Gemfile
@@ -0,0 +1,5 @@
+source :rubygems
+
+gem 'rspec'
+gem 'guard'
+gem 'guard-rspec'
25 Gemfile.lock
@@ -0,0 +1,25 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ guard (0.5.1)
+ thor (~> 0.14.6)
+ guard-rspec (0.4.0)
+ guard (>= 0.4.0)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ thor (0.14.6)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ guard
+ guard-rspec
+ rspec
6 Guardfile
@@ -0,0 +1,6 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2, :cli => "--color --format d" do
+ watch(%r{^spec/.+_spec\.rb$})
+end
34 README.md
@@ -0,0 +1,34 @@
+## Sharpening your Weapons
+
+1. Install Git
+2. Install RVM
+3. Install Ruby 1.9.2
+
+## Using Git and Github
+
+1. Create a Github account
+2. Send me a message so I know who you are @burtlo
+3. Add you the UWE Ruby organization
+3. Fork this repository to your account
+4. Clone the repository on your system
+
+## Traveling through the Land of Ruby
+
+1. Install Bundler
+2. bundle install
+2. Run the tests for week 1
+3. Fix the tests
+4. Commit the changes locally
+5. Push the changes to your repository
+
+## Using the resources of the land
+
+1. Login to Travis CI and authorize Travis CI
+2. Select your forked repository to be built
+
+## Getting to know your neighbors
+
+1. Find, follow and share a ruby blog through an RSS reader
+2. Watch a person or another project on Github
+3. Login to us.freenode.net
+4. Login to our Hipchat
6 Rakefile
@@ -0,0 +1,6 @@
+
+task :default => :spec
+
+task :spec do
+ system "rspec -c spec/*_spec.rb"
+end
101 spec/assignment_spec.rb
@@ -0,0 +1,101 @@
+
+describe "Variable assignment" do
+
+ context "when assignining values" do
+
+ it "should equal the value assigned to it" do
+
+ a = 1
+ a.should eq 1
+
+ end
+
+ it "should allow integers" do
+
+ number = 12
+ number.should eq 12
+
+ end
+
+ it "should allow decimal values" do
+
+ decimal = 3.1425
+ decimal.should eq 3.1425
+
+ end
+
+ it "should allow letters (String)" do
+
+ words = "I welcome you to Munchkin land!"
+ words.should eq "I welcome you to Munchkin land!"
+
+ end
+
+ it "should allow true value (boolean)" do
+
+ boolean = true
+ boolean.should be_true
+
+ end
+
+ it "should allow false value (boolean)" do
+
+ boolean = false
+ boolean.should be_false
+
+ end
+
+ end
+
+ context "when assigning a value multiple times" do
+
+ it "should be the last assigned value" do
+
+ number = 23
+ number = 12
+
+ number.should eq 12
+
+ end
+
+ it "should allow multiple different assignments" do
+
+ value = 1
+ value = "a"
+
+ value.should eq "a"
+
+ end
+
+ end
+
+ context "when comparing two" do
+
+ it "numbers should be equal" do
+
+ a = 1
+ b = 1
+
+ a.should eq b
+
+ end
+
+ it "strings should be equal" do
+
+ a = "abba"
+ b = 'abba'
+
+ a.should eq b
+
+ end
+
+ it "booleans should be equal" do
+
+ a = true
+ b = true
+
+ a.should eq b
+
+ end
+ end
+end
89 spec/boolean_spec.rb
@@ -0,0 +1,89 @@
+
+describe "Boolean" do
+
+ context "when true" do
+
+ it "should be true" do
+
+ value = true
+
+ value.should be_true
+ value.should eq true
+
+ end
+
+ it "should be a TrueClass" do
+
+ value = true
+ value.should be_kind_of TrueClass
+
+ end
+
+ end
+
+ context "when false" do
+
+ it "should be false" do
+
+ value = false
+
+ value.should be_false
+ value.should eq false
+
+ end
+
+ it "should be a FalseClass" do
+
+ value = false
+ value.should be_kind_of FalseClass
+
+ end
+
+ end
+
+ context "when any assigned value" do
+
+ it "should be true" do
+
+ value = "false"
+
+ value.should be_true
+ value.should_not be_kind_of TrueClass
+ value.should be_kind_of String
+ value.should eq "false"
+
+ end
+
+ end
+
+ context "when 0" do
+
+ it "should be true" do
+
+ value = 0
+
+ value.should be_true
+ value.should_not be_kind_of TrueClass
+ value.should be_kind_of Integer
+ value.should eq 0
+
+ end
+
+ end
+
+
+ context "when nil" do
+
+ it "should be false" do
+
+ value = nil
+
+ value.should be_false
+ value.should be_kind_of NilClass
+ value.should be_nil
+
+ end
+
+ end
+
+end
22 spec/nil_spec.rb
@@ -0,0 +1,22 @@
+
+describe "Nil and the NilClass" do
+
+ context "when assigned to nil" do
+
+ it "should be nil" do
+
+ value = nil
+ value.should be_nil
+
+ end
+
+ it "should be a NilClass" do
+
+ value = nil
+ value.should be_kind_of NilClass
+
+ end
+
+ end
+
+end
168 spec/strings_spec.rb
@@ -0,0 +1,168 @@
+
+describe "Strings" do
+
+ context "when created with double quotes" do
+
+ it "should be valid" do
+
+ word = "Ruby Course"
+ word.should eq 'Ruby Course'
+
+ end
+
+ it "should be a String" do
+
+ word = "Art Puzzle"
+ word.should be_kind_of String
+
+ end
+
+ it "should allow single-quote (') characters" do
+
+ word = "Frank 'The Tank' Webber"
+ word.should eq 'Frank \'The Tank\' Webber'
+
+ end
+
+ it "should allow the escape of double quote (\") characters" do
+
+ word = "Frank \"The Tank\" Webber"
+ word.should eq 'Frank "The Tank" Webber'
+
+ end
+
+ it "should allow interpolation (Ruby code within the string)" do
+
+ word = "1 + 1 = #{1 + 1}"
+ word.should eq '1 + 1 = 2'
+
+ end
+
+ it "should replace \n with a new line" do
+
+ two_line_word = "First\nSecond"
+
+ two_line_word.should eq %{First
+Second}
+ end
+
+ #
+ # There are many more special characters that are provided through this
+ # escape sequence.
+ #
+ # @see http://en.wikibooks.org/wiki/Ruby_Programming/Strings
+ #
+
+ it "should replace special characters when values are specified at the end" do
+
+ word = "1 + 1 = %d" % [ 2 ]
+ word.should eq "1 + 1 = 2"
+
+ end
+
+ end
+
+ context "when created with single quotes" do
+
+ it "should be valid" do
+
+ word = 'Alfred E. Newman'
+ word.should eq 'Alfred E. Newman'
+
+ end
+
+ it "should be a String" do
+
+ word = 'Art Puzzle'
+ word.should be_kind_of String
+
+ end
+
+
+ it "should allow double-quote (\") characters" do
+
+ word = 'Frank "The Tank" Webber'
+ word.should eq "Frank \"The Tank\" Webber"
+
+ end
+
+ it "should allow the escape of single quote (') characters" do
+
+ word = 'Frank \'The Tank\' Webber'
+ word.should eq "Frank 'The Tank' Webber"
+
+ end
+
+ it "should not allow interpolation (Ruby code within the string)" do
+
+ word = '1 + 1 = #{1 + 1}'
+ word.should eq "1 + 1 = \#{1 + 1}"
+
+ end
+
+ it "should not escape newline characters" do
+
+ two_line_word = 'First\nSecond'
+ two_line_word.should eq "First\\nSecond"
+
+ end
+
+ end
+
+ context "when created with the pattern %{ }" do
+
+ it "should be a String" do
+
+ word = %{Art Puzzle}
+ word.should be_kind_of String
+
+ end
+
+
+ it "should allow double-quote (\") characters" do
+
+ word = %{Frank "The Tank" Webber}
+ word.should eq "Frank \"The Tank\" Webber"
+
+ end
+
+ it "should allow single quote (') characters" do
+
+ word = %{Frank 'The Tank' Webber}
+ word.should eq "Frank 'The Tank' Webber"
+
+ end
+
+ it "should allow interpolation (Ruby code within the string)" do
+
+ word = %{1 + 1 = #{1 + 1}}
+ word.should eq "1 + 1 = 2"
+
+ end
+
+ it "should escape newline characters" do
+
+ two_line_word = %{First\nSecond}
+ two_line_word.should eq "First\nSecond"
+
+ end
+
+ it "should be treat a new line within the string as a new line" do
+
+ two_line_word = %{First
+Second}
+
+ two_line_word.should eq "First\nSecond"
+
+ end
+
+ it "should replace special characters when values are specified at the end" do
+
+ word = %{1 + 1 = %d} % [ 2 ]
+ word.should eq "1 + 1 = 2"
+
+ end
+
+ end
+
+end
47 spec/symbols_spec.rb
@@ -0,0 +1,47 @@
+
+describe "Symbols", "not quite a string, not yet a constant" do
+
+ it "should assignable" do
+
+ value = :prince
+ value.should eq :prince
+
+ end
+
+ it "should be a Symbol class" do
+
+ value = :prince
+ value.should be_kind_of Symbol
+
+ end
+
+ it "should not be the same as a string with the same name" do
+
+ value = :prince
+ value.should_not eq "prince"
+
+ end
+
+
+ context "when converting from a string" do
+
+ it "should be a Symbol class" do
+
+ value = "prince"
+ value.to_sym.should be_kind_of Symbol
+
+ end
+
+ it "should be equal to the symbol" do
+
+ value = "prince"
+ expected_value = :prince
+
+ value.to_sym.should eq expected_value
+
+ end
+
+ end
+
+
+end

0 comments on commit 987fea5

Please sign in to comment.
Something went wrong with that request. Please try again.