test/unit/executable_test.rb in sprout-1.0.35.pre vs test/unit/executable_test.rb in sprout-1.1.2.pre
- old
+ new
@@ -3,11 +3,11 @@
require 'unit/fake_other_executable'
require 'fixtures/executable/subclass/executable_superclass'
require 'fixtures/executable/subclass/executable_subclass'
class ExecutableTest < Test::Unit::TestCase
- include SproutTestCase
+ include Sprout::TestHelper
context "a new executable delegate" do
setup do
@tool = FakeOtherExecutableTask.new
@@ -72,53 +72,48 @@
assert_equal ["a", "b"], @tool.sp
end
should "raise UsageError with unknown type" do
assert_raises Sprout::Errors::UsageError do
- class BrokenExecutable
- include Sprout::Executable
+ class BrokenExecutable < Sprout::Executable::Base
add_param :broken_param, nil
end
tool = BrokenExecutable.new
end
end
should "raise Error if type is not a Class" do
assert_raises Sprout::Errors::UsageError do
- class BrokenExecutable2
- include Sprout::Executable
+ class BrokenExecutable2 < Sprout::Executable::Base
add_param :some_name, :string
end
end
end
should "raise Error when requested param name already exists" do
assert_raises Sprout::Errors::DuplicateMemberError do
- class BrokenExecutable3
- include Sprout::Executable
+ class BrokenExecutable3 < Sprout::Executable::Base
attr_accessor :existing_method
add_param :existing_method, String
end
end
end
should "raise Error if a block is provided to add_param" do
assert_raises Sprout::Errors::UsageError do
- class BrokenExecutable4
- include Sprout::Executable
+ class BrokenExecutable4 < Sprout::Executable::Base
add_param :name, String do
# this is no longer how it's done...
end
end
end
end
should "define a new method" do
- class WorkingTool
- include Sprout::Executable
+ class WorkingTool < Sprout::Executable::Base
add_param :custom_name, String
end
tool1 = WorkingTool.new
tool1.custom_name = "Foo Bar"
@@ -128,12 +123,11 @@
tool2.custom_name = "Bar Baz"
assert_equal "Bar Baz", tool2.custom_name
end
should "accept custom reader" do
- class WorkingTool
- include Sprout::Executable
+ class WorkingTool < Sprout::Executable::Base
add_param :custom1, String, { :reader => :read_custom }
def read_custom
"#{@custom1} world"
end
end
@@ -142,11 +136,10 @@
tool.custom1 = 'hello'
assert_equal 'hello world', tool.custom1
end
should "accept custom writer" do
- class WorkingTool
- include Sprout::Executable
+ class WorkingTool < Sprout::Executable::Base
add_param :custom2, String, { :writer => :write_custom }
def write_custom(value)
@custom2 = "#{value} world"
end
end