spec/views/specs/specs.html.erb_spec.rb in konacha-0.9.0 vs spec/views/specs/specs.html.erb_spec.rb in konacha-0.9.1
- old
+ new
@@ -1,15 +1,45 @@
require 'spec_helper'
-describe "layouts/konacha/specs" do
+describe "konacha/specs/specs" do
it "sets up the specified interface" do
- assign(:interface, :tdd)
+ Konacha.should_receive(:interface).any_number_of_times { :tdd }
render
rendered.should include('mocha.setup("tdd")')
end
it "includes konacha JS for given mode" do
- assign(:mode, :runner)
+ Konacha.should_receive(:mode).any_number_of_times { :runner }
render
rendered.should have_css("script[src='/assets/konacha/runner.js']")
+ end
+
+ let(:dependency) { asset_double("dependency") }
+
+ it "renders a script tag for each spec in @specs" do
+ assign(:specs, [spec_double("a_spec"),
+ spec_double("b_spec")])
+
+ render
+
+ rendered.should have_selector("script[src='/assets/a_spec.js?body=1']")
+ rendered.should have_selector("script[src='/assets/b_spec.js?body=1']")
+ end
+
+ it "renders a script tag for a spec's dependencies" do
+ assign(:specs, [spec_double("spec", [dependency])])
+
+ render
+
+ rendered.should have_selector("script[src='/assets/dependency.js?body=1']")
+ rendered.should have_selector("script[src='/assets/spec.js?body=1']")
+ end
+
+ it "renders only one script tag for common dependencies" do
+ assign(:specs, [spec_double("a_spec", [dependency]),
+ spec_double("b_spec", [dependency])])
+
+ render
+
+ rendered.should have_selector("script[src='/assets/dependency.js?body=1']", :count => 1)
end
end