spec/lib/snapdragon/suite_spec.rb in snapdragon-0.1.12 vs spec/lib/snapdragon/suite_spec.rb in snapdragon-0.2.0
- old
+ new
@@ -39,27 +39,67 @@
suite = Snapdragon::Suite.new(options, stub)
suite.use_color?.should eq color
end
end
- describe "#spec_files" do
- it "creates a path object to represent the path" do
- options = stub
- paths = ['path_a_str', 'path_b_str']
- suite = Snapdragon::Suite.new(options, 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
+ describe "#pattern" do
+ it "returns the configured pattern setting" do
+ pattern = stub
+ options = stub(pattern: pattern)
+ suite = Snapdragon::Suite.new(options, stub)
+ suite.pattern.should eq pattern
end
+ end
+
+ describe "#spec_files" do
+ context "when paths are provided" do
+ it "does not read pattern from options" do
+ pattern = stub
+ options = stub(pattern: pattern)
+ paths = ['path_a_str', 'path_b_str']
+ suite = Snapdragon::Suite.new(options, paths)
+ suite.should_not_receive(:pattern)
+ suite.spec_files
+ end
+
+ it "creates a path object to represent the path" do
+ options = stub
+ paths = ['path_a_str', 'path_b_str']
+ suite = Snapdragon::Suite.new(options, 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
- it "returns the collection of the spec files of all of the paths" do
- options = stub
- paths = ['path_a_str', 'path_b_str']
- suite = Snapdragon::Suite.new(options, 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])
+ it "returns the collection of the spec files of all of the paths" do
+ options = stub
+ paths = ['path_a_str', 'path_b_str']
+ suite = Snapdragon::Suite.new(options, 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
+ end
+
+ context "when paths are empty" do
+ it "reads the pattern from the options" do
+ pattern = stub
+ options = stub(pattern: pattern)
+ suite = Snapdragon::Suite.new(options, [])
+ suite.should_receive(:pattern).and_return(pattern)
+ suite.spec_files
+ end
+
+ it "returns the collection of spec files matching the pattern" do
+ pattern = stub
+ options = stub(pattern: pattern)
+ Dir.stub!(:[]) { ['path_c_str'] }
+ suite = Snapdragon::Suite.new(options, [])
+ spec_file_c = stub('spec_file_c')
+ Snapdragon::Path.stub(:new).with('path_c_str').and_return(stub(spec_files: [spec_file_c]))
+ suite.spec_files.should eq([spec_file_c])
+ end
end
end
describe "#require_paths" do
it "returns the merged set of the require paths of each spec file" do