Permalink
Browse files

upadte rspec layout

  • Loading branch information...
xiaods committed Sep 14, 2010
1 parent 6068b2c commit 01e3b6d72e05368240782b2ce83f9925a3d545c1
Showing with 39 additions and 42 deletions.
  1. 0 spec/spec.opts → .rspec
  2. +0 −1 Rakefile
  3. +1 −1 install.rb
  4. +1 −1 lib/high_charts_helper.rb
  5. +31 −35 spec/lazy_high_charts_spec.rb
  6. +6 −4 spec/spec_helper.rb
File renamed without changes.
View
@@ -11,5 +11,4 @@ if defined?(RSpec)
RSpec::Core::RakeTask.new('spec') do |t| RSpec::Core::RakeTask.new('spec') do |t|
t.pattern = FileList['spec/**/*_spec.rb'] t.pattern = FileList['spec/**/*_spec.rb']
end end
end end
View
@@ -1,7 +1,7 @@
# Install hook code here # Install hook code here
puts "Copying files..." puts "Copying files..."
dir = "javascripts" dir = "javascripts"
["excanvas.compiled.js", "highcharts.js"].each do |js_file| ["highcharts.js"].each do |js_file|
dest_file = File.join(Rails.root, "public", dir, js_file) dest_file = File.join(Rails.root, "public", dir, js_file)
src_file = File.join(File.dirname(__FILE__) , dir, js_file) src_file = File.join(File.dirname(__FILE__) , dir, js_file)
FileUtils.cp_r(src_file, dest_file) FileUtils.cp_r(src_file, dest_file)
@@ -9,7 +9,7 @@ def high_chart(placeholder, object , &block)
def high_graph(placeholder, object, &block) def high_graph(placeholder, object, &block)
graph = javascript_tag <<-EOJS graph =<<-EOJS
jQuery(function() { jQuery(function() {
// 1. Define JSON options // 1. Define JSON options
var options = { var options = {
@@ -1,6 +1,8 @@
# coding: utf-8 # coding: utf-8
require 'spec_helper' require 'spec_helper'
require 'pp'
describe HighChartsHelper do describe HighChartsHelper do
include HighChartsHelper include HighChartsHelper
@@ -12,46 +14,40 @@
@options = "options" @options = "options"
end end
describe "high_chart_includes" do
it "should have a script tag" do
javascript_include_tag(:high_charts).should have_tag('script')
end
end
describe "high_chart_helper" do describe "high_chart_helper" do
it "should return a div with an id of high_chart object" do
hc = HighChart.new("placeholder", :class => 'stylin')
high_chart(hc.placeholder, hc).should have_tag('div[id=?][class=?]', hc.placeholder, 'stylin')
end
it "should return a div with an id of high_chart object" do it "should return a script" do
hc = HighChart.new("placeholder", :class => 'stylin') hc = HighChart.new("placeholder")
high_chart(hc.placeholder, hc).should have_tag('div[id=?][class=?]', hc.placeholder, 'stylin') pp hc.inspect
end high_chart(hc.placeholder, hc).should have_tag('script')
end
it "should return a script" do
hc = HighChart.new("placeholder")
high_chart(hc.placeholder, hc).should have_tag('script')
end
end end
describe "high_chart_graph" do describe "high_chart_graph" do
describe "ready function" do describe "ready function" do
it "should be a javascript script" do it "should be a javascript script" do
high_chart(@placeholder, @chart).should have_tag('script[type=?]', 'text/javascript') high_chart(@placeholder, @chart).should have_tag('script[type=?]', 'text/javascript')
high_chart(@placeholder, @chart).should match(/\}\s*\)\s*;/) high_chart(@placeholder, @chart).should match(/\}\s*\)\s*;/)
end end
it "should generate generate ready function (no conflict with prototype)" do it "should generate generate ready function (no conflict with prototype)" do
high_chart(@placeholder, @chart).should match(/jQuery\(function\(\)\s*\{/) high_chart(@placeholder, @chart).should match(/jQuery\(function\(\)\s*\{/)
end end
end end
describe "initialize HighChart" do describe "initialize HighChart" do
it "should set Chart data" do it "should set Chart data" do
high_chart(@placeholder, @chart).should =~ /var\s+chart\s+=\s+new\s+Highcharts.Chart/ high_chart(@placeholder, @chart).should match(/var\s+chart\s+=\s+new\s+Highcharts.Chart/)
end end
it "should set chart renderTo" do it "should set chart renderTo" do
high_chart(@placeholder, @chart).should match(/chart:\s+{\"renderTo\":\"placeholder\"/) high_chart(@placeholder, @chart).should match(/chart:\s+{\"renderTo\":\"placeholder\"/)
end end
end end
end end
View
@@ -6,6 +6,12 @@
require 'action_controller' require 'action_controller'
require 'action_mailer' require 'action_mailer'
require 'rspec'
Rspec.configure do |c|
c.mock_with :rspec
end
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/high_chart')) require File.expand_path(File.join(File.dirname(__FILE__), '../lib/high_chart'))
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/high_charts_helper')) require File.expand_path(File.join(File.dirname(__FILE__), '../lib/high_charts_helper'))
@@ -21,10 +27,6 @@ module HighChartsHelper
include ActionView::Helpers::CaptureHelper include ActionView::Helpers::CaptureHelper
include ActionView::Helpers::AssetTagHelper include ActionView::Helpers::AssetTagHelper
include ActiveSupport include ActiveSupport
end end

0 comments on commit 01e3b6d

Please sign in to comment.