spec/lib/snapdragon/suite_spec.rb in snapdragon-0.1.5 vs spec/lib/snapdragon/suite_spec.rb in snapdragon-0.1.6

- old
+ new

@@ -1,111 +1,41 @@ require_relative '../../../lib/snapdragon/suite' describe Snapdragon::Suite do describe "#initialize" do - it "assigns an empty array to hold all the spec files" do - suite = Snapdragon::Suite.new - suite.instance_variable_get(:@specs).should eq([]) + it "constucts an instance of a Suite given an array of paths" do + paths = [stub, stub, stub] + Snapdragon::Suite.new(paths) end - it "assigns an empty set to hold all the require files" do - suite = Snapdragon::Suite.new - suite.instance_variable_get(:@require_paths).should be_kind_of(Set) + it "stores the paths in an instance variable" do + paths = [stub, stub, stub] + suite = Snapdragon::Suite.new(paths) + suite.instance_variable_get(:@paths).should eq(paths) end - - it "assigns @filtered to an initial state of false" do - suite = Snapdragon::Suite.new - suite.instance_variable_get(:@filtered).should be_false - end - - it "assigns @spec_query_param to an initial state of empty string" do - suite = Snapdragon::Suite.new - suite.instance_variable_get(:@spec_query_param).should eq('') - end end describe "#spec_files" do - it "returns the array of specs which the suite contains" do - spec_file = stub(:require_paths => []) - subject.instance_variable_set(:@specs, [spec_file]) - subject.spec_files.should eq([spec_file]) + it "creates a path object to represent the path" do + paths = ['path_a_str', 'path_b_str'] + suite = Snapdragon::Suite.new(paths) + Snapdragon::Path.should_receive(:new).with('path_a_str').and_return(stub(spec_files: [])) + Snapdragon::Path.should_receive(:new).with('path_b_str').and_return(stub(spec_files: [])) + suite.spec_files end - end - describe "#add_spec_file" do - it "appends the given SpecFile to the suite of specs" do - spec_file = stub(:require_paths => [], :filtered? => false) - specs = mock - subject.instance_variable_set(:@specs, specs) - specs.should_receive(:<<).with(spec_file) - subject.add_spec_file(spec_file) + it "returns the collection of the spec files of all of the paths" do + paths = ['path_a_str', 'path_b_str'] + suite = Snapdragon::Suite.new(paths) + spec_file_a = stub('spec_file_a'), spec_file_b = stub('spec_file_b') + Snapdragon::Path.stub(:new).with('path_a_str').and_return(stub(spec_files: [spec_file_a])) + Snapdragon::Path.stub(:new).with('path_b_str').and_return(stub(spec_files: [spec_file_b])) + suite.spec_files.should eq([spec_file_a, spec_file_b]) end - - it "gets the require paths outlined in the spec" do - spec_file = mock(:filtered? => false) - spec_file.should_receive(:require_paths).and_return([]) - subject.add_spec_file(spec_file) - end - - it "contactinates the specs require paths to the suites require paths collection" do - spec_file = stub(:filtered? => false) - require_paths = stub - suite_require_paths = mock - subject.instance_variable_set(:@require_paths, suite_require_paths) - spec_file.stub(:require_paths).and_return(require_paths) - suite_require_paths.should_receive(:merge).with(require_paths) - subject.add_spec_file(spec_file) - end - - context "when spec is filtered" do - it "assigns @filtered to true" do - spec_file = stub(:require_paths => [], :filtered? => true, :spec_query_param => '') - subject.add_spec_file(spec_file) - subject.instance_variable_get(:@filtered).should be_true - end - - it "assigns @spec_query_parm to the spec_files spec_query_parma" do - spec_file = stub(:require_paths => [], :filtered? => true, :spec_query_param => 'some_spec_query_param') - subject.add_spec_file(spec_file) - subject.instance_variable_get(:@spec_query_param).should eq('some_spec_query_param') - end - end end - describe "#add_spec_files" do - it "adds each of the spec files" do - spec_file_one = stub('spec_file_one') - spec_file_two = stub('spec_file_two') - subject.should_receive(:add_spec_file).with(spec_file_one) - subject.should_receive(:add_spec_file).with(spec_file_two) - subject.add_spec_files([spec_file_one, spec_file_two]) - end - end - - describe "#spec_files" do - it "returns the internal collection of spec files" do - specs = stub - subject.instance_variable_set(:@specs, specs) - subject.spec_files.should eq(specs) - end - end - - describe "#output_spec_dependencies" do - it "needs to be tested" - end - - describe "#spec_query_param" do - it "returns the suites spec_query_param" do - spec_query_param = stub - subject.instance_variable_set(:@spec_query_param, spec_query_param) - subject.spec_query_param.should eq(spec_query_param) - end - end - - describe "#filtered?" do - it "returns the filtered state of the suite" do - filtered = stub - subject.instance_variable_set(:@filtered, filtered) - subject.filtered?.should eq(filtered) + describe "#require_paths" do + it "returns the merged set of the require paths of each spec file" do + pending end end end