Permalink
Browse files

add InvalidDescriptorFileError and spec

  • Loading branch information...
1 parent fdc35b1 commit 2a543d4ac0ffec3fdfbcd64c17ac9f9a59d3c220 @ruprict ruprict committed Feb 10, 2013
View
@@ -1,5 +1,6 @@
*.gem
*.rbc
+*.swp
.bundle
.config
.yardoc
@@ -4,6 +4,7 @@
module Obvious
module Generators
+ class InvalidDescriptorFileError < StandardError; end
class Descriptor
def initialize descriptor
@descriptor = descriptor
@@ -14,6 +15,8 @@ def to_file
@jacks, @entities = {}, {}
@code = ''
+ raise InvalidDescriptorFileError unless action
+
action['Code'].each do |entry|
write_comments_for entry
process_requirements_for entry if entry['requires']
View
@@ -1,3 +1,3 @@
module Obvious
- VERSION = "0.0.8"
+ VERSION = "0.0.9"
end
View
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
+
+ gem.add_development_dependency "rspec"
end
View
Binary file not shown.
No changes.
Binary file not shown.
@@ -0,0 +1,21 @@
+require_relative '../../lib/generators/descriptor'
+
+require File.expand_path('spec/spec_helper')
+
+module Obvious
+ module Generators
+ describe Descriptor do
+ subject {Descriptor.new(yaml_file)}
+
+ describe "#to_file" do
+
+ let( :yaml_file ) { "spec/fixtures/empty_descriptor.yml" }
+
+ it "should raise a meaningful error if no Code section in descriptor" do
+ expect {subject.to_file}.to raise_error(InvalidDescriptorFileError)
+ end
+ end
+
+ end
+ end
+end
View
No changes.

0 comments on commit 2a543d4

Please sign in to comment.