spec/fontcustom/options_spec.rb in fontcustom-1.3.3 vs spec/fontcustom/options_spec.rb in fontcustom-1.3.4
- old
+ new
@@ -6,37 +6,37 @@
args[:manifest] = fixture(".fontcustom-manifest.json") if args[:manifest].nil?
Fontcustom::Options.new(args)
end
before(:each) do
- Fontcustom::Options.any_instance.stub :say_message
- Fontcustom::Options.any_instance.stub :parse_options
+ allow_any_instance_of(Fontcustom::Options).to receive(:say_message)
+ allow_any_instance_of(Fontcustom::Options).to receive(:parse_options)
end
context ".overwrite_examples" do
it "should overwite example defaults with real defaults" do
o = options Fontcustom::EXAMPLE_OPTIONS.dup
o.send :overwrite_examples
cli = o.instance_variable_get(:@cli_options)
Fontcustom::EXAMPLE_OPTIONS.keys.each do |key|
- cli[key].should == Fontcustom::DEFAULT_OPTIONS[key]
+ expect(cli[key]).to eq(Fontcustom::DEFAULT_OPTIONS[key])
end
end
end
context ".set_config_path" do
context "when :config is set" do
it "should use options[:config] if it's a file" do
o = options :config => "options/any-file-name.yml"
o.send :set_config_path
- o.instance_variable_get(:@cli_options)[:config].should == "options/any-file-name.yml"
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("options/any-file-name.yml")
end
it "should search for fontcustom.yml if options[:config] is a dir" do
o = options :config => "options/config-is-in-dir"
o.send :set_config_path
- o.instance_variable_get(:@cli_options)[:config].should == "options/config-is-in-dir/fontcustom.yml"
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("options/config-is-in-dir/fontcustom.yml")
end
it "should raise error if :config doesn't exist" do
o = options :config => "does-not-exist"
expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file/
@@ -46,35 +46,35 @@
context "when :config is not set" do
it "should find fontcustom.yml in the same dir as the manifest" do
FileUtils.cd fixture("options") do
o = options
o.send :set_config_path
- o.instance_variable_get(:@cli_options)[:config].should == "fontcustom.yml"
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("fontcustom.yml")
end
end
it "should find fontcustom.yml at config/fontcustom.yml" do
FileUtils.cd fixture("options/rails-like") do
o = options
o.send :set_config_path
- o.instance_variable_get(:@cli_options)[:config].should == "config/fontcustom.yml"
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("config/fontcustom.yml")
end
end
it "should be false if nothing is found" do
o = options :manifest => "options/no-config-here/.fontcustom-manifest.json"
o.send :set_config_path
- o.instance_variable_get(:@cli_options)[:config].should == false
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq(false)
end
end
end
context ".load_config" do
it "should warn if fontcustom.yml is blank" do
o = options
o.instance_variable_set :@cli_options, {:config => fixture("options/fontcustom-empty.yml")}
- o.should_receive(:say_message).with :warn, /was empty/
+ expect(o).to receive(:say_message).with :warn, /was empty/
o.send :load_config
end
it "should raise error if fontcustom.yml isn't valid" do
o = options
@@ -84,50 +84,50 @@
it "should assign empty hash :config is false" do
o = options
o.instance_variable_set :@cli_options, {:config => false}
o.send :load_config
- o.instance_variable_get(:@config_options).should == {}
+ expect(o.instance_variable_get(:@config_options)).to eq({})
end
context "when :debug is true" do
it "should report which configuration file it's using" do
o = options
o.instance_variable_set :@cli_options, {
:config => fixture("options/any-file-name.yml"),
:debug => true
}
- o.should_receive(:say_message).with :debug, /Using settings/
+ expect(o).to receive(:say_message).with :debug, /Using settings/
o.send :load_config
end
end
end
context ".merge_options" do
it "should overwrite defaults with config options" do
o = options
o.instance_variable_set :@config_options, { :input => "config" }
o.send :merge_options
- o.options[:input].should == "config"
+ expect(o.options[:input]).to eq("config")
end
it "should overwrite config file and defaults with CLI options" do
o = options
o.instance_variable_set :@config_options, { :input => "config", :output => "output" }
o.instance_variable_set :@cli_options, { :input => "cli" }
o.send :merge_options
- o.options[:input].should == "cli"
- o.options[:output].should == "output"
+ expect(o.options[:input]).to eq("cli")
+ expect(o.options[:output]).to eq("output")
end
end
context ".clean_font_name" do
it "should normalize the font name" do
o = options
o.instance_variable_set :@options, { :font_name => " A_stR4nG3 nAm3 Ø& " }
o.send :clean_font_name
- o.options[:font_name].should == "A_stR4nG3--nAm3---"
+ expect(o.options[:font_name]).to eq("A_stR4nG3--nAm3---")
end
end
context ".set_input_paths" do
it "should raise error if input[:vectors] doesn't contain SVGs" do
@@ -142,20 +142,20 @@
it "should set :templates as :vectors if :templates isn't set" do
FileUtils.cd fixture("shared") do
o = options
o.instance_variable_set :@options, { :input => { :vectors => "vectors" } }
o.send :set_input_paths
- o.options[:input][:templates].should == "vectors"
+ expect(o.options[:input][:templates]).to eq("vectors")
end
end
it "should preserve :templates if it's set" do
FileUtils.cd fixture("shared") do
o = options
o.instance_variable_set :@options, { :input => { :vectors => "vectors", :templates => "templates" } }
o.send :set_input_paths
- o.options[:input][:templates].should == "templates"
+ expect(o.options[:input][:templates]).to eq("templates")
end
end
it "should raise an error if :vectors isn't set" do
FileUtils.cd fixture("shared") do
@@ -181,21 +181,21 @@
it "should return a hash of locations" do
FileUtils.cd fixture("shared") do
o = options
o.instance_variable_set :@options, { :input => "vectors" }
o.send :set_input_paths
- o.options[:input].should have_key(:vectors)
- o.options[:input].should have_key(:templates)
+ expect(o.options[:input]).to have_key(:vectors)
+ expect(o.options[:input]).to have_key(:templates)
end
end
it "should set :templates to match :vectors" do
FileUtils.cd fixture("shared") do
o = options
o.instance_variable_set :@options, { :input => "vectors" }
o.send :set_input_paths
- o.options[:input][:templates].should == "vectors"
+ expect(o.options[:input][:templates]).to eq("vectors")
end
end
it "should raise an error if :vectors doesn't point to a directory" do
FileUtils.cd fixture("shared") do
@@ -217,23 +217,23 @@
o = options
o.instance_variable_set :@options, {
:debug => true,
:font_name => "Test-Font"
}
- o.should_receive(:say_message).with :debug, /Test-Font/
+ expect(o).to receive(:say_message).with :debug, /Test-Font/
o.send :set_output_paths
end
end
end
context "when :output is a hash" do
it "should set :css and :preview to match :fonts if either aren't set" do
o = options
o.instance_variable_set :@options, { :output => { :fonts => "output/fonts" } }
o.send :set_output_paths
- o.options[:output][:css].should == "output/fonts"
- o.options[:output][:preview].should == "output/fonts"
+ expect(o.options[:output][:css]).to eq("output/fonts")
+ expect(o.options[:output][:preview]).to eq("output/fonts")
end
it "should preserve :css and :preview if they do exist" do
o = options
o.instance_variable_set :@options, {
@@ -242,12 +242,12 @@
:css => "output/styles",
:preview => "output/preview"
}
}
o.send :set_output_paths
- o.options[:output][:css].should == "output/styles"
- o.options[:output][:preview].should == "output/preview"
+ expect(o.options[:output][:css]).to eq("output/styles")
+ expect(o.options[:output][:preview]).to eq("output/preview")
end
it "should create additional paths if they are given" do
o = options
o.instance_variable_set :@options, {
@@ -255,11 +255,11 @@
:fonts => "output/fonts",
"special.js" => "assets/javascripts"
}
}
o.send :set_output_paths
- o.options[:output][:"special.js"].should == "assets/javascripts"
+ expect(o.options[:output][:"special.js"]).to eq("assets/javascripts")
end
it "should raise an error if :fonts isn't set" do
o = options
o.instance_variable_set :@options, {
@@ -273,21 +273,21 @@
context "when :output is a string" do
it "should return a hash of output locations" do
o = options
o.instance_variable_set :@options, { :output => "output/fonts" }
o.send :set_output_paths
- o.options[:output].should be_a(Hash)
- o.options[:output].should have_key(:fonts)
- o.options[:output].should have_key(:css)
- o.options[:output].should have_key(:preview)
+ expect(o.options[:output]).to be_a(Hash)
+ expect(o.options[:output]).to have_key(:fonts)
+ expect(o.options[:output]).to have_key(:css)
+ expect(o.options[:output]).to have_key(:preview)
end
it "should set :css and :preview to match :fonts" do
o = options
o.instance_variable_set :@options, { :output => "output/fonts" }
o.send :set_output_paths
- o.options[:output][:css].should == "output/fonts"
- o.options[:output][:preview].should == "output/fonts"
+ expect(o.options[:output][:css]).to eq("output/fonts")
+ expect(o.options[:output][:preview]).to eq("output/fonts")
end
it "should raise an error if :fonts exists but isn't a directory" do
FileUtils.cd fixture("shared") do
o = options