spec/rack_backbone_spec.rb in rack-backbone-0.1.0 vs spec/rack_backbone_spec.rb in rack-backbone-0.1.1

- old
+ new

@@ -17,51 +17,54 @@ let(:env) { {"rack.backbone.http_path" => path} } let(:default_options) { {} } subject(:cdn) { Rack::Backbone.cdn env, default_options.merge(options) } context "Given the organisation option" do + let(:fallback) { "#{FALLBACK_TOP.chomp}#{path}#{FALLBACK_BOTTOM}" } + let(:expected){ "<script src='#{cdn_name}'></script>\n#{fallback}"} context "of nil (the default)" do let(:options) { {:organisation => nil } } - let(:expected){ "<script src='#{CDN::CLOUDFLARE}'></script>\n#{FALLBACK_TOP}#{path}#{FALLBACK_BOTTOM}"} + let(:cdn_name) {CDN::CLOUDFLARE } it { should == expected } context "and debug" do - let(:unminified) { "#{CDN::CLOUDFLARE[0..-8]}.js" } + let(:unminified) { "#{cdn_name[0..-8]}.js" } let(:options) { {:organisation => nil, :debug => true } } it_should_behave_like "the debug option is set" end end context "of :jsdelivr" do let(:options) { {:organisation => :jsdelivr } } - let(:expected){ "<script src='#{CDN::JSDELIVR}'></script>\n#{FALLBACK_TOP}#{path}#{FALLBACK_BOTTOM}" } + let(:cdn_name) {CDN::JSDELIVR } it { should == expected } context "and debug" do - let(:unminified) { "#{CDN::JSDELIVR[0..-8]}.js" } + let(:unminified) { "#{cdn_name[0..-8]}.js" } let(:options) { {:organisation => :jsdelivr, :debug => true } } it_should_behave_like "the debug option is set" end end context "of :cloudflare" do let(:options) { {:organisation => :cloudflare } } - let(:expected){ "<script src='#{CDN::CLOUDFLARE}'></script>\n#{FALLBACK_TOP}#{path}#{FALLBACK_BOTTOM}"} + let(:cdn_name) {CDN::CLOUDFLARE } it { should == expected } context "and debug" do - let(:unminified) { "#{CDN::CLOUDFLARE[0..-8]}.js" } + let(:unminified) { "#{cdn_name[0..-8]}.js" } let(:options) { {:organisation => nil, :debug => true } } it_should_behave_like "the debug option is set" end end context "of false, to get the fallback script only" do let(:options) { {:organisation => false } } + let(:cdn_name) { CDN::CLOUDFLARE } let(:expected){ "<script src='#{path}'></script>" } it { should == expected } context "and debug" do - let(:unminified) { "#{CDN::CLOUDFLARE[0..-8]}.js" } + let(:unminified) { "#{cdn_name[0..-8]}.js" } let(:options) { {:organisation => false, :debug => true } } it { should == expected } end \ No newline at end of file