Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move everything to rspec

  • Loading branch information...
commit e2f2aef8d0fc6b6084ee463ac9837e2df1e46964 1 parent 94605ea
@phoet authored
View
6 Gemfile
@@ -0,0 +1,6 @@
+# A sample Gemfile
+source "http://rubygems.org"
+
+gem "rspec"
+gem "mocha"
+gem "fuubar"
View
27 Gemfile.lock
@@ -0,0 +1,27 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ chalofa_ruby-progressbar (0.0.9.1)
+ diff-lcs (1.1.2)
+ fuubar (0.0.4)
+ chalofa_ruby-progressbar (~> 0.0.9)
+ rspec (~> 2.0)
+ rspec-instafail (~> 0.1.4)
+ mocha (0.9.12)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-instafail (0.1.7)
+ rspec-mocks (2.5.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ fuubar
+ mocha
+ rspec
View
11 Rakefile
@@ -0,0 +1,11 @@
+require "bundler"
+require 'rspec/core/rake_task'
+
+Bundler::GemHelper.install_tasks
+
+RSpec::Core::RakeTask.new do |t|
+ t.rspec_opts = ["--format Fuubar", "--color", "-r ./spec/spec_helper.rb"]
+ t.pattern = 'spec/**/*_spec.rb'
+end
+
+task :default=>:spec
View
58 spec/percent_style_spec.rb
@@ -0,0 +1,58 @@
+require 'spec_helper'
+
+describe 'percent style variables' do
+
+ it "should have syntactical expressions" do
+ %(double-quoted string with parenthesis).should_not be_nil
+ %q(a (nested) string).should_not be_nil
+ %[double-quoted string with brackets].should_not be_nil
+ %{double-quoted string with curly braces}.should_not be_nil
+ %<double-quoted string with angle brackets>.should_not be_nil
+ %!double-quoted string with exclamation mark!.should_not be_nil
+ %/double-quoted string with slashes/.should_not be_nil
+ %-double\-quoted string with minus-.should_not be_nil
+ # ...
+ %[
+ multi
+ line
+ expression
+ ].should_not be_nil
+ end
+
+ it "should have double quoted string" do
+ "double-quoted string".should eql(%[double-quoted string])
+ "double-quoted string".should eql(%Q[double-quoted string])
+ "double-quoted string with interpolation".should eql(%[double-quoted string #{'with interpolation'}])
+ "double-quoted string with interpolation".should eql(%Q[double-quoted string #{'with interpolation'}])
+ end
+
+ it "should have single quoted_string" do
+ 'single-quoted string'.should eql(%q[single-quoted string])
+ 'single-quoted string #{\'without interpolation\'}'.should eql(%q[single-quoted string #{'without interpolation'}])
+ end
+
+ it "should have double quoted words" do
+ ["double", "quoted", "words"].should eql(%W[double quoted words])
+ ["double", "quoted words"].should eql(%W[double quoted\ words])
+ ["double", "quoted", "words", "with interpolation"].should eql(%W[double quoted words #{'with interpolation'}])
+ end
+
+ it "should have single quoted words" do
+ ['single', 'quoted', 'words'].should eql(%w[single quoted words])
+ ['single', 'quoted', 'words', '#{\'without', 'interpolation\'}'].should eql(%w[single quoted words #{'without interpolation'}])
+ end
+
+ it "should have backtick execute" do
+ `ls`.should eql(%x[ls])
+ end
+
+ it "should have reqular expressions" do
+ /regexp/.should eql(%r[regexp])
+ /regexp/i.should eql(%r[regexp]i)
+ end
+
+ it "should have symbol" do
+ :symbol.should eql(%s[symbol])
+ end
+
+end
View
57 spec/predefined_variables_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+require 'english'
+
+# http://www.cs.auckland.ac.nz/references/ruby/ProgrammingRuby/language.html
+
+describe "predifined variables" do
+
+ it "should have exceptions" do
+ begin
+ raise 'an error'
+ rescue => err
+ err.should_not be_nil
+ $!.should_not be_nil
+ $ERROR_INFO.should_not be_nil
+ $@.should_not be_nil
+ $ERROR_POSITION.should_not be_nil
+ caller.should_not be_nil
+ end
+ end
+
+ it "should have args" do
+ $*.should have(0).things
+ $*.should eql($ARGV)
+ $*.should be_an_instance_of(Array)
+ end
+
+ it "should have child status" do
+ fork { sleep 1}
+ Process.wait()
+ $?.should_not be_nil
+ $?.should eql($CHILD_STATUS)
+ $?.should be_an_instance_of(Process::Status)
+ end
+
+ it "should have default input" do
+ $<.should_not be_nil
+ $<.should eql($DEFAULT_INPUT)
+ end
+
+ it "should have default output" do
+ $>.should_not be_nil
+ $>.should eql($DEFAULT_OUTPUT)
+ $>.should be_an_instance_of(IO)
+ end
+
+ it "should have field separator" do
+ $;.should eql($FIELD_SEPARATOR)
+ $;.should eql($FS)
+ $;.should be_nil
+ end
+
+ it "should have input linenumber" do
+ IO.readlines(__FILE__)
+ $..should_not be_nil
+ $..should eql($INPUT_LINE_NUMBER)
+ end
+end
View
5 spec/spec_helper.rb
@@ -0,0 +1,5 @@
+require 'rspec'
+
+Rspec.configure do |c|
+ c.mock_with :rspec
+end
View
7 test/string_substitution_test.rb → spec/string_substitution_spec.rb
@@ -1,8 +1,9 @@
-require 'test_helper'
+#encoding: utf-8
+require 'spec_helper'
-class StringSubstitutionTest < Test::Unit::TestCase
+describe 'string substitution' do
- def test_substitution
+ it "should have substitution" do
{
:alert => "\a", :backspace => "\b",
:escape => "\e", :formfeed => "\f",
View
58 test/percent_style_test.rb
@@ -1,58 +0,0 @@
-require 'test_helper'
-
-class PercentStyleTest < Test::Unit::TestCase
-
- def test_syntactical_expression
- %(double-quoted string with parenthesis)
- %q(a (nested) string)
- %[double-quoted string with brackets]
- %{double-quoted string with curly braces}
- %<double-quoted string with angle brackets>
- %!double-quoted string with exclamation mark!
- %/double-quoted string with slashes/
- %-double\-quoted string with minus-
- # ...
- %[
- multi
- line
- expression
- ]
- end
-
- def test_double_quoted_string
- assert_equal("double-quoted string", %[double-quoted string])
- assert_equal("double-quoted string", %Q[double-quoted string])
- assert_equal("double-quoted string with interpolation", %[double-quoted string #{'with interpolation'}])
- assert_equal("double-quoted string with interpolation", %Q[double-quoted string #{'with interpolation'}])
- end
-
- def test_single_quoted_string
- assert_equal('single-quoted string', %q[single-quoted string])
- assert_equal('single-quoted string #{\'without interpolation\'}', %q[single-quoted string #{'without interpolation'}])
- end
-
- def test_double_quoted_words
- assert_equal(["double", "quoted", "words"], %W[double quoted words])
- assert_equal(["double", "quoted words"], %W[double quoted\ words])
- assert_equal(["double", "quoted", "words", "with interpolation"], %W[double quoted words #{'with interpolation'}])
- end
-
- def test_single_quoted_words
- assert_equal(['single', 'quoted', 'words'], %w[single quoted words])
- assert_equal(['single', 'quoted', 'words', '#{\'without', 'interpolation\'}'], %w[single quoted words #{'without interpolation'}])
- end
-
- def test_backtick_execute
- assert_equal(`ls`, %x[ls])
- end
-
- def test_reqular_expressions
- assert_equal(/regexp/, %r[regexp])
- assert_equal(/regexp/i, %r[regexp]i)
- end
-
- def test_symbol
- assert_equal(:symbol, %s[symbol])
- end
-
-end
View
66 test/predefined_variables_test.rb
@@ -1,66 +0,0 @@
-require 'test_helper'
-require 'english'
-
-# http://www.cs.auckland.ac.nz/references/ruby/ProgrammingRuby/language.html
-
-class PredefinedVariablesTest < Test::Unit::TestCase
-
- def test_exceptions
- begin
- raise 'an error'
- rescue => err
- puts "the error #{err}"
- puts "the error #{$!}"
- puts "the error #{$ERROR_INFO}"
- puts "the stack #{$@}"
- puts "the stack #{$ERROR_POSITION}"
- puts "the stack #{caller}"
- end
- end
-
- def test_argv
- p $*
- assert_equal($*, $ARGV)
- assert_equal($*.is_a?(Array), true)
- assert_kind_of(Array, $*)
- end
-
- def test_child_status
- fork { puts "i am a child"}
- Process.wait()
- p $?
- assert_equal($?, $CHILD_STATUS)
- assert_kind_of(Process::Status, $?)
- end
-
- def test_default_input
- p $<
- assert_equal($<, $DEFAULT_INPUT)
- assert_kind_of(Object, $<)
- end
-
- def test_default_output
- p $>
- assert_equal($>, $DEFAULT_OUTPUT)
- assert_kind_of(IO, $>)
- end
-
- def test_field_separator
- p $;
- assert_equal($;, $FIELD_SEPARATOR)
- assert_equal($;, $FS)
- assert_equal($;, nil)
- end
-
- def test_ignorecase
- p $=
- assert_equal($=, $IGNORECASE)
- assert_kind_of(FalseClass, $=)
- end
-
- def test_input_linenumber
- IO.readlines(__FILE__)
- p $.
- assert_equal($., $INPUT_LINE_NUMBER)
- end
-end
View
2  test/test_helper.rb
@@ -1,2 +0,0 @@
-$:.unshift File.join(File.dirname(__FILE__),'..','..','lib')
-require 'test/unit'
Please sign in to comment.
Something went wrong with that request. Please try again.