Sha256: b0c510537203fa92f5688e4568332323bb85c2d516df63140d6a78845e164605
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
require 'spec_helper' describe PulseMeter::Visualize::DSL::Page do let(:interval){ 100 } let(:sensor_name) { "some_sensor" } let!(:sensor){ PulseMeter::Sensor::Timelined::Max.new(sensor_name, :ttl => 1000, :interval => interval) } let(:title) { "page title" } let(:page){ PulseMeter::Visualize::DSL::Page.new(title) } describe '.new' do it "initializes title and widgets" do p = page.to_data expect(p.title).to eq(title) expect(p.widgets).to eq([]) end end [:area, :line, :table, :pie, :gauge].each do |widget_type| describe "##{widget_type}" do it "adds #{widget_type} widget initialized by args to widgets" do page.send(widget_type, :some_widget_name, sensor: sensor_name, width: 7) w = page.to_data.widgets.first expect(w.width).to eq(7) expect(w.title).to eq("some_widget_name") expect(w.sensors.first.name).to eq(sensor_name) end it "adds #{widget_type} widget initialized by block" do page.send(widget_type, :some_widget_name) do |w| w.sensor(sensor_name) w.sensor(sensor_name) w.title "foo_widget" w.width 7 end w = page.to_data.widgets.first expect(w.type).to eq(widget_type.to_s) expect(w.width).to eq(7) expect(w.title).to eq("foo_widget") expect(w.sensors.size).to eq(2) expect(w.sensors.first.name).to eq(sensor_name) expect(w.sensors.last.name).to eq(sensor_name) end end end describe "#title" do it "sets page title" do page.title "Foo Title" expect(page.to_data.title).to eq('Foo Title') end end describe "#to_data" do it "converts DSL data to Visualize::Page" do expect(page.to_data).to be_kind_of(PulseMeter::Visualize::Page) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pulse_meter_visualizer-0.4.22 | spec/pulse_meter/visualize/dsl/page_spec.rb |
pulse_meter_visualizer-0.4.21 | spec/pulse_meter/visualize/dsl/page_spec.rb |