test/unit/rake_task_test.rb in rails-erd-0.4.5 vs test/unit/rake_task_test.rb in rails-erd-1.0.0
- old
+ new
@@ -11,11 +11,11 @@
RailsERD.options.warn = false
Rake.application.options.silent = true
end
def teardown
- FileUtils.rm "ERD.dot" rescue nil
+ FileUtils.rm "erd.dot" rescue nil
RailsERD::Diagram.send :remove_const, :Graphviz rescue nil
end
define_method :create_app do
Object::Quux = Module.new
@@ -33,16 +33,16 @@
# Diagram generation =======================================================
test "generate task should create output based on domain model" do
create_simple_domain
Rake::Task["erd:generate"].execute
- assert File.exists?("ERD.dot")
+ assert File.exists?("erd.dot")
end
test "generate task should not create output if there are no connected models" do
Rake::Task["erd:generate"].execute rescue nil
- assert !File.exists?("ERD.dot")
+ assert !File.exists?("erd.dot")
end
test "generate task should eager load application environment" do
eager_loaded, environment_loaded = nil
create_app
@@ -90,15 +90,15 @@
l2 = __LINE__ + 1
Rake::Task["erd:generate"].invoke
rescue => e
message = e.message
end
- assert_equal <<-MSG.strip, message
+ assert_match /#{Regexp.escape(<<-MSG.strip).gsub("xxx", ".*?")}/, message
Loading models failed!
Error occurred while loading application: FooBar (RuntimeError)
- test/unit/rake_task_test.rb:#{l1}:in `block (3 levels) in <class:RakeTaskTest>'
- test/unit/rake_task_test.rb:#{l2}:in `block in <class:RakeTaskTest>'
+ test/unit/rake_task_test.rb:#{l1}:in `xxx'
+ test/unit/rake_task_test.rb:#{l2}:in `xxx'
MSG
end
test "generate task should reraise if application could not be loaded and trace option is enabled" do
create_app
@@ -108,16 +108,16 @@
end
end
Rake::Task.define_task :environment
message = nil
begin
- old_stdout, $stdout = $stdout, StringIO.new
+ old_stderr, $stderr = $stderr, StringIO.new
Rake.application.options.trace = true
Rake::Task["erd:generate"].invoke
rescue => e
message = e.message
ensure
- $stdout = old_stdout
+ $stderr = old_stderr
end
assert_equal "FooBar", message
end
# Option processing ========================================================