spec/fbo/parser_spec.rb in fbo-0.0.2 vs spec/fbo/parser_spec.rb in fbo-0.0.3
- old
+ new
@@ -4,65 +4,34 @@
subject { FBO::Parser.new(file) }
let(:file) { File.new(filename) }
let!(:notices) { subject.notices }
- context "a file containing a presolicitation" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "presol") }
+ tag_to_name_map = {
+ amdcss: "Amendment", archive: "Archive", award: "Award",
+ combine: "Combined Solicitation", fairopp: "Fair Opportunity",
+ fstd: "Foreign Standard", itb: "Intent to Bundle",
+ ja: "Justification Approval", mod: "Modification",
+ presol: "Presolicitation", ssale: "Sale of Surplus",
+ srcsgt: "Sources Sought", snote: "Special Notice",
+ unarchive: "Unarchive" }
- it "should return an array with a single Presolicitation notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::Presolicitation)
- end
- end
+ tag_to_name_map.each do |tag, name|
+ notice_class_name = name.split.map { |w| w.capitalize }.join
+ notice_class = Kernel.const_get("FBO::Notices::#{ notice_class_name }")
- context "a file containing a combined solicitation" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "combine") }
+ context "a file containing a #{ name } notice" do
+ let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", tag.to_s) }
- it "should return an array with a single Combined Solicitation notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::CombinedSolicitation)
+ it "should return an array with a single #{ notice_class_name }" do
+ notices.count.should eq 1
+ notices[0].should be_an_instance_of(notice_class)
+ end
end
end
- context "a file containing a sources sought notice" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "srcsgt") }
-
- it "should return an array with a single Sources Sought notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::SourcesSought)
- end
- end
-
- context "a file containing a amendment" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "amdcss") }
-
- it "should return an array with a single Amendment notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::Amendment)
- end
- end
-
- context "a file containing a modification" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "mod") }
-
- it "should return an array with a single Modification notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::Modification)
- end
- end
-
- context "a file containing an award" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "award") }
-
- it "should return an array with a single Award notice" do
- notices.count.should eq 1
- notices[0].should be_an_instance_of(FBO::Notices::Award)
- end
- end
-
context "a file containing any other type of notice" do
- let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "snote") }
+ let(:filename) { File.join(File.dirname(__FILE__), "..", "fixtures", "notices", "notanotice") }
it "should return an array with a single Unknown notice" do
notices.count.should eq 1
notices[0].should be_an_instance_of(FBO::Notices::Unknown)
end