spec/generator_spec.rb in webidl-0.1.4 vs spec/generator_spec.rb in webidl-0.1.5
- old
+ new
@@ -1,53 +1,28 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe WebIDL::Generator do
- it "generates an empty module" do
- expected = %Q{module Gui\n # do nothing\nend\n}
- actual = generate(fixture('empty_module.idl'))
-
- actual.should == expected
- end
-
it "generates an empty interface" do
expected = %Q{module System\n # do nothing\nend}
actual = generate(fixture('empty_interface.idl'))
actual.should == expected
end
- it "generates nested modules/interfaces" do
+ it "generates an exception" do
expected = <<-RUBY
-module Foo
- module Bar
- # do nothing
- end
- module Baz
- # do nothing
- end
+class FrameworkException < StandardError
+ ERR_NOT_FOUND = 1
+ attr_accessor(:code)
end
RUBY
- actual = generate(fixture("nested.idl"))
- actual.should == expected
+ actual = generate(fixture('exception.idl'))
+ actual.should == expected.strip
end
- it "generates a module with an exception" do
- expected = <<-RUBY
-module Framework
- class FrameworkException < StandardError
- ERR_NOT_FOUND = 1
- attr_accessor(:code)
- end
-end
-RUBY
-
- actual = generate(fixture('module_with_exception.idl'))
- actual.should == expected
- end
-
it "generates an interface with attributes" do
expected = <<-RUBY
module Foo
attr_accessor(:const)
attr_accessor(:value)
@@ -71,25 +46,25 @@
actual.should == expected.strip
end
it "generates an implements statement" do
expected = <<-RUBY
-module Foo
- module Bar
- # do nothing
- end
- module Baz
- # do nothing
- end
- module Foo::Bar
- include(Foo::Baz)
- end
+module Bar
+ # do nothing
end
+
+module Baz
+ # do nothing
+end
+
+module Bar
+ include(Baz)
+end
RUBY
- actual = generate(fixture("module_with_implements_statement.idl"))
- actual.should == expected
+ actual = generate(fixture("implements_statement.idl"))
+ actual.should == expected.strip
end
it "generates code for no-name setters, getters, creators, stringifier and deleters" do
expected = <<-RUBY
module Foo
@@ -114,10 +89,10 @@
actual = generate(fixture("interface_with_specials.idl"))
actual.should == expected.strip
end
it "accepts an array of AST nodes or a single AST node as input" do
- ast_nodes = parse(fixture("module_with_implements_statement.idl")).build
+ ast_nodes = parse(fixture("implements_statement.idl")).build
lambda { generate(ast_nodes.first) }.should_not raise_error
lambda { generate(ast_nodes) }.should_not raise_error
end