Skip to content

Commit

Permalink
fix: specs
Browse files Browse the repository at this point in the history
  • Loading branch information
gottfrois committed Oct 27, 2013
1 parent 3ca84c4 commit e16d47e
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
dashing-rails (1.0.3)
dashing-rails (2.0.0.pre)
coffee-script (~> 2.2)
connection_pool (~> 1.1)
jquery-rails (~> 3.0)
Expand Down
13 changes: 13 additions & 0 deletions spec/dummy/app/assets/javascripts/dashing/widgets/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require_tree .
12 changes: 12 additions & 0 deletions spec/dummy/app/assets/stylesheets/dashing/widgets/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_tree .
*/
9 changes: 9 additions & 0 deletions spec/dummy/app/jobs/sample.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
current_valuation = 0

Dashing.scheduler.every '2s' do
last_valuation = current_valuation
current_valuation = rand(100)

Dashing.send_event('valuation', { current: current_valuation, last: last_valuation })
Dashing.send_event('synergy', { value: rand(100) })
end
28 changes: 28 additions & 0 deletions spec/dummy/app/views/dashing/dashboards/sample.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<% content_for :title do %>
My super sweet dashboard
<% end %>

<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="welcome" data-view="Text" data-title="Hello" data-text="This is your shiny new dashboard." data-moreinfo="Protip: You can drag the widgets around!"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="synergy" data-view="Meter" data-title="Synergy" data-min="0" data-max="100"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="2">
<div data-id="buzzwords" data-view="List" data-unordered="true" data-title="Buzzwords" data-moreinfo="# of times said around the office"></div>
</li>

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="valuation" data-view="Number" data-title="Current Valuation" data-moreinfo="In billions" data-prefix="$"></div>
</li>

<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="convergence" data-view="Graph" data-title="Convergence" style="background-color:#ff9618"></div>
</li>
</ul>
<center><div style="font-size: 12px">Try this: curl -X PUT 'http://<%= request.host %>:<%= request.port %>/dashing/widgets/welcome' --data "widget%5Btext%5D=Dashing+is+awesomecurl"</div></center>
</div>
57 changes: 57 additions & 0 deletions spec/dummy/config/initializers/dashing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Use this hook to configure Dashing bahaviors.
Dashing.configure do |config|
# Scheduler instance.
# config.scheduler = ::Rufus::Scheduler.new

# Redis credentials.
# See https://devcenter.heroku.com/articles/redistogo to configure redis for heroku.
# config.redis_host = '127.0.0.1'
# config.redis_port = '6379'
# config.redis_password = nil

# Redis namespace when pushing new data.
# config.redis_namespace = 'dashing_events'

# Dashing come with default widgets using css and coffeescript.
# You can create your own widgets by adding the following files:
#
# A widget is composed of:
# - an HTML file used for layout and bindings - app/views/dashing/widgets/foo.html
# - a SCSS file for styles - app/assets/stylesheets/dashing/widgets/foo.scss
# - a coffeescript file which allows you to handle incoming data & functionality - app/assets/javascripts/dashing/widgets/foo.coffee
#
# CSS and JS file will be added to the asset path and the asset pipeline automatically.
#
# More information at http://shopify.github.io/dashing/
#
# You can change default views and assets paths with the following config:
#
# config.widgets_views_path = 'app/views/dashing/widgets/'
# config.widgets_js_path = 'app/assets/javascripts/dashing'
# config.widgets_css_path = 'app/assets/stylesheets/dashing'

# rufus-scheduler worker path
# config.jobs_path = 'app/jobs/'

# Engine path to use for accessing engine's routes.
# Ex: http://your_app/dashing/dashboard/my_dashboard_name
# config.engine_path = '/dashing'

# The dashboards views path used to find dashboards.
# config.dashboards_views_path = 'app/views/dashing/dashboards/'

# The Dashing layout used to display metrics.
# config.dashboard_layout_path = 'dashing/dashboard'

# Default dashboard name to load when going to /dashing/dashboards
# config.default_dashboard = nil

# A secure random string to authenticate with for curl requests.
# Put nil if you don't want to use authentication.
# You can use SecureRandom.hex to generate a hex.
# config.auth_token = nil

# List of Devise models that should access the whole dashboard.
# List the models. E.g: '[:user, :admin]'
# config.devise_allowed_models = []
end
3 changes: 1 addition & 2 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Rails.application.routes.draw do

mount Dashing::Engine => "/dashing"
mount Dashing::Engine, at: Dashing.config.engine_path
end
28 changes: 19 additions & 9 deletions spec/lib/dashing/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@

let(:instance) { Dashing::Configuration.new }

it { expect(instance.scheduler).to be_a(::Rufus::Scheduler) }
it { expect(instance.engine_path).to eq('/dashing') }
# it { expect(instance.scheduler).to be_a(::Rufus::Scheduler.new) }
it { expect(instance.redis).to be_a(::Redis) }

# Redis
it { expect(instance.redis_host).to eq('127.0.0.1') }
it { expect(instance.redis_port).to eq('6379') }
it { expect(instance.redis_password).to be_nil }
it { expect(instance.redis_namespace).to eq('dashing_events') }
it { expect(instance.view_path).to eq('app/views/dashing/') }
it { expect(instance.jobs_path).to eq('app/jobs/') }
it { expect(instance.engine_path).to eq('/dashing') }
it { expect(instance.dashboards_path).to eq('app/views/dashing/dashboards/') }
it { expect(instance.dashboard_layout).to eq('dashing/dashboard') }
it { expect(instance.widgets_path).to eq('app/views/dashing/widgets/') }
it { expect(instance.default_dashboard).to be_nil }

# Authorization
it { expect(instance.auth_token).to be_nil }
it { expect(instance.devise_allowed_models).to be_empty }

it { expect(instance.redis).to be_a(::Redis) }
# Jobs
it { expect(instance.jobs_path).to eq('app/jobs/') }

# Dashboards
it { expect(instance.default_dashboard).to be_nil }
it { expect(instance.dashboards_views_path).to eq('app/views/dashing/dashboards/') }
it { expect(instance.dashboard_layout_path).to eq('dashing/dashboard') }

# Widgets
it { expect(instance.widgets_views_path).to eq('app/views/dashing/widgets/') }
it { expect(instance.widgets_js_path).to eq('app/assets/javascripts/dashing') }
it { expect(instance.widgets_css_path).to eq('app/assets/stylesheets/dashing') }

describe '#request_thread_count' do

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/dashing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

describe '.first_dashboard' do

let(:dir) { 'foo' }
let(:dirs) { [dir] }
let(:dir) { 'foo' }
let(:dirs) { [dir] }

before do
Dir.stub(:[]).and_return(dirs)
Expand Down

0 comments on commit e16d47e

Please sign in to comment.