spec/lib/configuration_spec.rb in jshint-0.0.1 vs spec/lib/configuration_spec.rb in jshint-0.0.2

- old
+ new

@@ -1,31 +1,34 @@ require 'spec_helper' require 'jshint/configuration' describe Jshint::Configuration do - let(:file) { { "include" => [ 'foo/bar/**/*', 'baz.js' ], "curly" => true } } - let(:yaml) { file.to_yaml } + let(:config) { File.join(Jshint.root, 'spec', 'fixtures', 'jshint.yml') } - before do - described_class.any_instance.stub(:default_config_path).and_return('/foo/bar.yml') - described_class.any_instance.stub(:read_config_file).and_return(yaml) - described_class.any_instance.stub(:parse_yaml_config).and_return(YAML.load(yaml)) - end + describe "core behaviour" do + before do + described_class.any_instance.stub(:default_config_path).and_return('/foo/bar.yml') + described_class.any_instance.stub(:parse_yaml_config).and_return(YAML.load_file(config)) + end - it "should fall back to the default JSHint config file when one is provided" do - described_class.any_instance.should_receive(:default_config_path) - config = described_class.new - config.options.should == file - end + it "should allow the developer to index in to config options" do + config = described_class.new + config[:boss].should be_true + config[:browser].should be_true + end - it "should return a hash of options when reading the contents of the passed in config file" do - described_class.any_instance.should_not_receive(:default_config_path) - config = described_class.new('/bar/baz.yml') - config.options.should == file - end + it "should return a Hash of the global variables declared" do + config = described_class.new + config.global_variables.should == { "jQuery" => true, "$" => true } + end - it "should allow the developer to index in to config options" do - config = described_class.new - config[:include].should == file["include"] - config[:curly].should == file["curly"] + it "should return a Hash of the lint options declared" do + config = described_class.new + config.lint_options.should == config.options["options"].reject { |key| key == "globals" } + end + + it "should return an array of files" do + config = described_class.new + config.files.should == ["**/*.js"] + end end end