Sha256: cc5cef4f9481bf0ffc4117c689b54df5e1712302ce1c68c2c30dec9e2391aa1c

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe PulseMeter::DygraphsVisualize::DSL::Layout do
  let(:interval){ 100 }
  let(:sensor_name) { "some_sensor" }
  let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(sensor_name, :ttl => 1000, :interval => interval) }
  let(:layout){ described_class.new }

  describe '.new' do
    it "should initialize pages, title, use_utc, dygraphs_options" do
      l = layout.to_data
      l.title.should == PulseMeter::DygraphsVisualize::DSL::Layout::DEFAULT_TITLE
      l.pages.should == []
      l.use_utc.should be_false
      l.dygraphs_options.should == {}
    end
  end

  describe "#page" do
    it "should add page constructed by block to pages" do
      layout.page "My Foo Page" do |p|
        p.stack "foo_widget", sensor: sensor_name
        p.line "bar_widget" do |w|
          w.sensor(sensor_name)
        end
      end
      l = layout.to_data
      l.pages.size.should == 1
      p = l.pages.first
      p.title.should == "My Foo Page"
      p.widgets.size.should == 2
      p.widgets.first.title.should == "foo_widget"
      p.widgets.last.title.should == "bar_widget"
    end
  end

  describe "#title" do
    it "should set layout title" do
      layout.title "Foo Title"
      layout.to_data.title.should == 'Foo Title'
    end
  end

  describe "#use_utc" do
    it "should set use_utc" do
      layout.use_utc false
      layout.to_data.use_utc.should be_false
    end
  end

  describe "#dygraphs_options" do
    it "should set dygraphs_options" do
      layout.dygraphs_options({b: 1})
      layout.to_data.dygraphs_options.should == {b: 1}
    end
  end

  describe "#to_data" do
    it "should convert layout dsl data to DygraphsVisualize::Layout" do
      layout.to_data.should be_kind_of(PulseMeter::DygraphsVisualize::Layout)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pulse_meter-dygraphs_visualizer-0.4.20 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb
pulse_meter-dygraphs_visualizer-0.4.19 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb
pulse_meter-dygraphs_visualizer-0.4.18 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb
pulse_meter-dygraphs_visualizer-0.4.17 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb
pulse_meter-dygraphs_visualizer-0.4.16 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb
pulse_meter-dygraphs_visualizer-0.4.15 spec/pulse_meter/dygraphs_visualize/dsl/layout_spec.rb