Skip to content

Commit

Permalink
Essential HTML spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jschementi committed Jun 22, 2008
1 parent 50135ad commit 8bddfd9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vendor/plugins/silverline/lib/silverline/essential/html.rb
@@ -1,6 +1,6 @@
module Silverline::Essential::Html

def silverlight_include_tag(options)
def silverlight_include_tag(options = :defaults)
templatify("head.html.erb", binding)
end

Expand Down
Expand Up @@ -15,6 +15,8 @@ class Base
describe Silverline::Essential do

before do
Object.instance_eval{remove_const :FileSystemWatcher} if defined?(::FileSystemWatcher)
::FileSystemWatcher = mock("FileSystemWatcher", :null_object => true)
require 'silverline/essential'
end

Expand All @@ -31,7 +33,7 @@ class Base
end

it "should tell the generator to register itself" do
Silverline::Essential.instance_eval{remove_const :Generator}
Silverline::Essential.instance_eval{remove_const :Generator} if defined?(Silverline::Essential::Generator)
gen = Silverline::Essential::Generator = mock("Generator")
gen.should_receive(:register)
load 'silverline/essential.rb'
Expand Down
@@ -1,17 +1,17 @@
require File.dirname(__FILE__) + '/../../spec_nonrails.rb'

Silverline.instance_eval{remove_const :Essential} if defined?(Silveline::Essential)
Silverline.instance_eval{remove_const :Essential} if defined?(Silverline::Essential)
Silverline::Essential = Module.new

Silverline::Essential.instance_eval{remove_const :Xap} if defined?(Silveline::Essential::Xap)
Silverline::Essential.instance_eval{remove_const :Xap} if defined?(Silverline::Essential::Xap)
Silverline::Essential::Xap = :chiron

load 'silverline/essential/generator.rb'

describe Silverline::Essential::Generator do

before do
Silverline::Essential.instance_eval{remove_const :Generator}
Silverline::Essential.instance_eval{remove_const :Generator} if defined?(Silverline::Essential::Generator)
Silverline::Essential::Generator = Module.new
end

Expand Down
45 changes: 45 additions & 0 deletions vendor/plugins/silverline/spec/silverline/essential/html_spec.rb
@@ -0,0 +1,45 @@
require File.dirname(__FILE__) + '/../../spec_nonrails.rb'

Silverline.instance_eval{remove_const :Essential} if defined?(Silverline::Essential)
Silverline::Essential = Module.new

load 'silverline/essential/html.rb'

Object.instance_eval{remove_const :HtmlTesttHost} if defined? HtmlTesttHost
HtmlTesttHost = Class.new
HtmlTesttHost.class_eval { include Silverline::Essential::Html }

describe Silverline::Essential::Html do

before(:each) do
@html = HtmlTesttHost.new
end

it "should render a silverlight include tag" do
@html.should_receive(:templatify).with("head.html.erb", anything)
@html.silverlight_include_tag
end

it "should render a silverlight control" do
@html.should_receive(:require).with('erb')
@html.stub!(:public_xap_file).and_return "/public.xap"
@html.stub!(:generate_init_params).and_return "debug=true"
result = @html.silverlight_object
result['position: absolute'].should_not be_nil
result['<object'].should_not be_nil
result['data="data:application/x-silverlight'].should_not be_nil
result['type="application/x-silverlight-2-b2"'].should_not be_nil
result['<param name="source" value="/public.xap" />'].should_not be_nil
result['width="1" height="1"'].should_not be_nil
result['<param name="initParams" value="debug=true" />'].should_not be_nil
end

end

describe "Private functionality of essential HTML" do
it "should know the HTTP_HOST"
it "should generate initParams for Silverlight and the DLR"
it "should know the XAP file location"
it "should know how to put JSON in initParams"
it "should know how to render a template"
end
5 changes: 5 additions & 0 deletions vendor/plugins/silverline/spec/silverline/silverline_spec.rb
@@ -1,6 +1,11 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'

describe Silverline do
before do
Object.instance_eval{remove_const :FileSystemWatcher} if defined?(::FileSystemWatcher)
::FileSystemWatcher = mock("FileSystemWatcher", :null_object => true)
end

it "should define path to Rails views" do
Silverline::RAILS_VIEWS.should be_relative_to("app/views")
end
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/silverline/spec/spec_init.rb
Expand Up @@ -7,4 +7,4 @@

require 'rubygems'
require 'ruby-debug'
Debugger.start
#Debugger.start

0 comments on commit 8bddfd9

Please sign in to comment.