[macruby-changes] [4716] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 04:03:53 PDT 2010
Revision: 4716
http://trac.macosforge.org/projects/ruby/changeset/4716
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 04:03:51 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Migrate spec suite to MSpec's API.
And comment the Jeweler stuff in the Rakefile for now, as MacRuby segfaults.
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/Rakefile
DietRB/trunk/spec/completion_spec.rb
DietRB/trunk/spec/context_spec.rb
DietRB/trunk/spec/formatter_spec.rb
DietRB/trunk/spec/history_spec.rb
DietRB/trunk/spec/regression/context_spec.rb
DietRB/trunk/spec/source_spec.rb
DietRB/trunk/spec/spec_helper.rb
Modified: DietRB/trunk/Rakefile
===================================================================
--- DietRB/trunk/Rakefile 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/Rakefile 2010-10-08 11:03:51 UTC (rev 4716)
@@ -7,7 +7,7 @@
desc "Run the specs (run it with a rake installed on the Ruby version you want to run the specs on)"
task :spec do
- sh "#{ruby_bin} -r #{FileList['./spec/**/*_spec.rb'].join(' -r ')} -e ''"
+ sh "mspec -t #{ruby_bin} spec"
end
desc "Run dietrb"
@@ -50,19 +50,20 @@
end
end
-begin
- require 'jeweler'
- require File.expand_path('../lib/irb/version', __FILE__)
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "dietrb"
- gemspec.version = IRB::VERSION::STRING
- gemspec.summary = gemspec.description = "IRB on a diet, for MacRuby / Ruby 1.9"
- gemspec.email = "eloy.de.enige at gmail.com"
- gemspec.homepage = "http://github.com/alloy/dietrb"
- gemspec.authors = ["Eloy Duran"]
-
- gemspec.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
- gemspec.files.reject! { |file| file =~ /^(extensions|\.gitignore)/ }
- end
-rescue LoadError
-end
+# begin
+# require 'rubygems'
+# require 'jeweler'
+# require File.expand_path('../lib/irb/version', __FILE__)
+# Jeweler::Tasks.new do |gemspec|
+# gemspec.name = "dietrb"
+# gemspec.version = IRB::VERSION::STRING
+# gemspec.summary = gemspec.description = "IRB on a diet, for MacRuby / Ruby 1.9"
+# gemspec.email = "eloy.de.enige at gmail.com"
+# gemspec.homepage = "http://github.com/alloy/dietrb"
+# gemspec.authors = ["Eloy Duran"]
+#
+# gemspec.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
+# gemspec.files.reject! { |file| file =~ /^(extensions|\.gitignore)/ }
+# end
+# rescue LoadError
+# end
Modified: DietRB/trunk/spec/completion_spec.rb
===================================================================
--- DietRB/trunk/spec/completion_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/completion_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -15,8 +15,6 @@
end
end
-Bacon::Context.send(:include, CompletionHelper)
-
class CompletionStub
def self.a_cmethod
end
@@ -35,6 +33,8 @@
$a_completion_stub = CompletionStub.new
describe "IRB::Completion" do
+ extend CompletionHelper
+
before do
@context = IRB::Context.new(Playground.new)
end
@@ -51,7 +51,7 @@
complete('foo.').should == imethods(::CompletionStub, 'foo')
@context.__evaluate__('def foo.singleton_method; end')
- complete('foo.').should.include('foo.singleton_method')
+ complete('foo.').should include('foo.singleton_method')
end
it "matches as a global variable" do
@@ -231,7 +231,7 @@
it "completes reserved words as variables or constants" do
(IRB::Completion::RESERVED_DOWNCASE_WORDS +
IRB::Completion::RESERVED_UPCASE_WORDS).each do |word|
- complete(word[0..-2]).should.include word
+ complete(word[0..-2]).should include(word)
end
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -41,12 +41,12 @@
it "initializes with an object and an explicit binding" do
context = IRB::Context.new(Object.new, TOPLEVEL_BINDING)
eval("class InTopLevel; end", context.binding)
- lambda { ::InTopLevel }.should.not.raise NameError
+ lambda { ::InTopLevel }.should_not raise_error(NameError)
end
it "initializes with an 'empty' state" do
@context.line.should == 1
- @context.source.should.be.instance_of IRB::Source
+ @context.source.class.should == IRB::Source
@context.source.to_s.should == ""
end
@@ -55,14 +55,14 @@
begin
IRB::Context.processors << TestProcessor
@context = IRB::Context.new(main)
- @context.processors.last.should.be.instance_of TestProcessor
+ @context.processors.last.class.should == TestProcessor
ensure
IRB::Context.processors.replace(before)
end
end
it "does not use the same binding copy of the top level object" do
- lambda { eval("x", @context.binding) }.should.raise NameError
+ lambda { eval("x", @context.binding) }.should raise_error(NameError)
end
it "makes itself the current running context during the runloop and resigns once it's done" do
@@ -109,28 +109,28 @@
lambda {
@context.evaluate("DoesNotExist")
@context.evaluate("raise Exception")
- }.should.not.raise
+ }.should_not.raise_error
end
it "assigns the last raised exception to the global variable `$EXCEPTION' / `$e'" do
@context.evaluate("DoesNotExist")
- $EXCEPTION.should.be.instance_of NameError
- $EXCEPTION.message.should.include 'DoesNotExist'
+ $EXCEPTION.class.should == NameError
+ $EXCEPTION.message.should include('DoesNotExist')
$e.should == $EXCEPTION
end
it "prints the exception that occurs" do
@context.evaluate("DoesNotExist")
- @context.printed.should.match /^NameError:.+DoesNotExist/
+ @context.printed.should =~ /^NameError:.+DoesNotExist/
end
it "uses the line number of the *first* line in the buffer, for the line parameter of eval" do
@context.process_line("DoesNotExist")
- @context.printed.should.match /\(irb\):1:in/
+ @context.printed.should =~ /\(irb\):1:in/
@context.process_line("class A")
@context.process_line("DoesNotExist")
@context.process_line("end")
- @context.printed.should.match /\(irb\):3:in.+\(irb\):2:in/m
+ @context.printed.should =~ /\(irb\):3:in.+\(irb\):2:in/m
end
it "inputs a line to be processed, skipping readline" do
@@ -181,7 +181,7 @@
end
end
- lambda { @context.run }.should.not.raise Interrupt
+ lambda { @context.run }.should_not raise_error(Interrupt)
@context.source.to_s.should == ""
ensure
stub_Readline
@@ -230,7 +230,7 @@
Readline.stub_input("quit", "def foo")
def @context.process_line(line); @received = line; super; end
@context.run
- @context.instance_variable_get(:@received).should.not == "def foo"
+ @context.instance_variable_get(:@received).should_not == "def foo"
end
end
Modified: DietRB/trunk/spec/formatter_spec.rb
===================================================================
--- DietRB/trunk/spec/formatter_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/formatter_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -68,7 +68,7 @@
def object.__id__; 2158110700; end
@formatter.result(object).should == "=> #<Object:0x101444fd8>"
- object.instance_variable_get(:@inspected).should.not == true
+ object.instance_variable_get(:@inspected).should_not == true
end
it "prints that a syntax error occurred on the last line and reset the buffer to the previous line" do
Modified: DietRB/trunk/spec/history_spec.rb
===================================================================
--- DietRB/trunk/spec/history_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/history_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -1,11 +1,13 @@
require File.expand_path('../spec_helper', __FILE__)
require "tempfile"
-describe "IRB::History" do
- it "stores the history by default in ~/.irb_history" do
+describe "IRB::History, by default," do
+ it "stores the history in ~/.irb_history" do
IRB::History.file.should == File.expand_path("~/.irb_history")
end
-
+end
+
+describe "IRB::History" do
before do
@file = Tempfile.new("irb_history.txt")
IRB::History.file = @file.path
@@ -39,10 +41,10 @@
FileUtils.rm(@file.path)
@history.to_a.should == []
- File.should.not.exist @file.path
+ File.exist?(@file.path).should == false
@history.input "puts :ok"
- File.should.exist @file.path
+ File.exist?(@file.path).should == true
@history.to_a.should == ["puts :ok"]
end
@@ -63,8 +65,8 @@
@history.input "foo(x)"
@history.clear!
- @file.rewind; @file.read.should.be.empty
- Readline::HISTORY.to_a.should.be.empty
+ @file.rewind; @file.read.should == ""
+ Readline::HISTORY.to_a.should == []
end
end
@@ -89,11 +91,13 @@
end
end
-describe "IRB::History, concerning the user api" do
- it "shows by default a maximum of 50 history entries" do
+describe "IRB::History, concerning the user api, by default," do
+ it "shows a maximum of 50 history entries" do
IRB::History.max_entries_in_overview.should == 50
end
-
+end
+
+describe "IRB::History, concerning the user api," do
before do
sources = [
"puts :ok",
@@ -178,6 +182,6 @@
it "clears the history and history file" do
clear_history!
- @history.should.be.cleared
+ @history.cleared?.should == true
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/regression/context_spec.rb
===================================================================
--- DietRB/trunk/spec/regression/context_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/regression/context_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -11,6 +11,6 @@
it "does not assign the result to the `_' variable in one go, so it doesn't show up in a syntax error" do
@context.evaluate("'banana;")
- @context.printed.should.not.include "_ = ('banana;)"
+ @context.printed.should_not include("_ = ('banana;)")
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/source_spec.rb
===================================================================
--- DietRB/trunk/spec/source_spec.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/source_spec.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -1,9 +1,5 @@
require File.expand_path('../spec_helper', __FILE__)
-class Should
- alias have be
-end
-
describe "IRB::Source" do
before do
@source = IRB::Source.new
@@ -51,7 +47,7 @@
["def foo", "p :ok", "end"],
["class A; def", "foo(x); p x", "end; end"]
].each do |buffer|
- IRB::Source.new(buffer).should.be.code_block
+ IRB::Source.new(buffer).code_block?.should == true
end
end
@@ -60,16 +56,16 @@
["def foo", "p :ok"],
["class A; def", "foo(x); p x", "end"]
].each do |buffer|
- IRB::Source.new(buffer).should.not.be.code_block
+ IRB::Source.new(buffer).code_block?.should == false
end
end
it "returns whether or not the accumulated source contains a syntax error" do
- @source.should.not.have.syntax_error
+ @source.syntax_error?.should == false
@source << "def foo"
- @source.should.not.have.syntax_error
+ @source.syntax_error?.should == false
@source << " def;"
- @source.should.have.syntax_error
+ @source.syntax_error?.should == true
end
it "returns the current code block indentation level" do
@@ -102,7 +98,7 @@
@source << "end"
@source.level
new_reflection = @source.reflect
- new_reflection.should.not == reflection
+ new_reflection.should_not == reflection
@source.code_block?
@source.reflect.should == new_reflection
@@ -111,7 +107,7 @@
@source.pop
@source.level
new_reflection = @source.reflect
- new_reflection.should.not == reflection
+ new_reflection.should_not == reflection
@source.syntax_error?
@source.reflect.should == new_reflection
end
@@ -123,32 +119,32 @@
end
it "returns whether or not the source is a valid code block" do
- reflect("def foo").should.not.be.code_block
- reflect("def foo; p :ok").should.not.be.code_block
- reflect("def foo; p :ok; end").should.be.code_block
+ reflect("def foo").code_block?.should == false
+ reflect("def foo; p :ok").code_block?.should == false
+ reflect("def foo; p :ok; end").code_block?.should == true
- reflect("if true").should.not.be.code_block
- reflect("p :ok if true").should.be.code_block
+ reflect("if true").code_block?.should == false
+ reflect("p :ok if true").code_block?.should == true
end
it "returns whether or not the current session should be terminated" do
- reflect("exit").should.terminate
- reflect("quit").should.terminate
- reflect("def foo; end; exit").should.terminate
- reflect("def foo; end; quit").should.terminate
+ reflect("exit").terminate?.should == true
+ reflect("quit").terminate?.should == true
+ reflect("def foo; end; exit").terminate?.should == true
+ reflect("def foo; end; quit").terminate?.should == true
- reflect("def foo; exit; end").should.not.terminate
- reflect("def foo; quit; end").should.not.terminate
+ reflect("def foo; exit; end").terminate?.should == false
+ reflect("def foo; quit; end").terminate?.should == false
end
it "returns whether or not the source contains a syntax error, except a code block not ending" do
- reflect("def;").should.have.syntax_error
- reflect("def;").should.have.syntax_error
- reflect("def foo").should.not.have.syntax_error
- reflect("class A; }").should.have.syntax_error
- reflect("class A; {" ).should.not.have.syntax_error
- reflect("class A def foo").should.have.syntax_error
- reflect("class A; def foo" ).should.not.have.syntax_error
+ reflect("def;").syntax_error?.should == true
+ reflect("def;").syntax_error?.should == true
+ reflect("def foo").syntax_error?.should == false
+ reflect("class A; }").syntax_error?.should == true
+ reflect("class A; {" ).syntax_error?.should == false
+ reflect("class A def foo").syntax_error?.should == true
+ reflect("class A; def foo" ).syntax_error?.should == false
end
it "returns the actual syntax error message if one occurs" do
Modified: DietRB/trunk/spec/spec_helper.rb
===================================================================
--- DietRB/trunk/spec/spec_helper.rb 2010-10-08 11:03:41 UTC (rev 4715)
+++ DietRB/trunk/spec/spec_helper.rb 2010-10-08 11:03:51 UTC (rev 4716)
@@ -1,8 +1,6 @@
require 'rubygems'
-require 'bacon'
+require 'mspec'
-Bacon.summary_on_exit
-
ENV['SPECCING'] = 'true'
ROOT = File.expand_path('../../', __FILE__)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/1a3b4cca/attachment-0001.html>
More information about the macruby-changes
mailing list