Permalink
Browse files

Added specs for Protocol::Loader

  • Loading branch information...
1 parent e00cc12 commit e497075cf6e84bce7cb76b64512e9ebab305f5fd @krakatoa krakatoa committed Oct 4, 2012
@@ -1,6 +1,6 @@
module Cucub
module Protocol
- class ActionSpecification < Specification
+ class ActionSpecification < Cucub::Protocol::Specification
attr_reader :class_name, :action_name
attr_reader :from, :respond_to, :read_by
View
@@ -16,6 +16,7 @@ def specifications
def parse
basefile = IniFile.load(@filepath)
+ return false if not basefile
current_specifications = Cucub::Protocol::SpecificationSet.new
basefile.sections.reject { |x| x.include?("#") }.each { |section|
@@ -1,6 +1,6 @@
module Cucub
module Protocol
- class ObjectSpecification < Specification
+ class ObjectSpecification < Cucub::Protocol::Specification
attr_reader :class_name
attr_reader :role
View
@@ -6,6 +6,17 @@
end
describe "#parse" do
+ subject { Cucub::Protocol::Loader.instance }
+ context "when parsing a valid config" do
+ before { subject.set_path(@filepath + "/mock/protocol.ini") }
+ it { subject.parse.should be_a Cucub::Protocol::SpecificationSet }
+ end
+
+ context "when parsing an unexisting file" do
+ before { subject.set_path(@filepath + "/mock/unexisting.ini") }
+ it { subject.parse.should == false }
+ end
+
=begin
it "should return a valid SpecificationSet" do
@loader = Cucub::Protocol::Loader.instance
@@ -24,6 +35,7 @@
end
=end
+=begin
it "should return a valid SpecificationSet" do
@loader = Cucub::Protocol::Loader.instance
@loader.set_path(@filepath + "/mock/protocol.ini")
@@ -43,62 +55,6 @@
#puts obj_spec.inspect
}
end
- end
-
-=begin
- describe 'run!' do
- it 'should pass' do
- constraint = Bliss::Constraint.new("root", :tag_name_required)
- constraint.run!({'root' => {'tag_1' => 'test', 'tag_2' => 'test'}})
- constraint.state.should == :passed
- end
-
- it 'should pass too' do
- constraint = Bliss::Constraint.new("(root|ROOT)", :tag_name_required)
- constraint.run!({'ROOT' => {'tag_1' => 'test', 'tag_2' => 'test'}})
- constraint.state.should == :passed
- end
-
- it 'should not pass' do
- constraint = Bliss::Constraint.new("(root|ROOT)", :tag_name_required)
- constraint.run!({'another' => {'tag_1' => 'test', 'tag_2' => 'test'}})
- constraint.state.should == :not_passed
- end
-
- context "multiple depth levels" do
- it "should pass" do
- constraint = Bliss::Constraint.new("(root|ROOT)/id", :tag_name_required)
- constraint.run!({'id' => 'test', 'tag_2' => 'test'})
- constraint.state.should == :passed
- end
-
- it "should not pass" do
- constraint = Bliss::Constraint.new("(root|ROOT)/id", :tag_name_required)
- constraint.run!({'root' => {'tag_1' => 'test', 'tag_2' => 'test'}})
- constraint.state.should == :not_passed
- end
- end
- end
-
- describe '#settings_to_constraints' do
- it 'should return an array with a Bliss::Constraint object' do
- constraints = Bliss::Constraint.build_from_settings(['root'], {'tag_name_required' => true})
- constraints.should be_a(Array)
- constraints.size.should == 1
- constraints.first.should be_a(Bliss::Constraint)
- end
-
- it 'should have depth and setting loaded' do
- constraints = Bliss::Constraint.build_from_settings(['root'], {'tag_name_required' => true})
- constraints.first.depth.should == 'root'
- constraints.first.setting.should == :tag_name_required
- end
-
- it 'should have multiple depths' do
- constraints = Bliss::Constraint.build_from_settings(['root'], {'tag_name_required' => true, 'tag_name_values' => ['root', 'ROOT']})
- constraints.first.depth.should == '(root|ROOT)'
- constraints.first.setting.should == :tag_name_required
- end
- end
=end
+ end
end
View
@@ -5,7 +5,8 @@
require 'bundler'
Bundler.require(:default, :development)
-Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
+Dir["#{File.dirname(__FILE__)}/../lib/*.rb"].each {|f| require f}
+#Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.

0 comments on commit e497075

Please sign in to comment.