spec/lib/whipped-cream/switch_spec.rb in whipped-cream-0.1.0 vs spec/lib/whipped-cream/switch_spec.rb in whipped-cream-0.1.1
- old
+ new
@@ -1,13 +1,23 @@
require 'spec_helper'
describe WhippedCream::Switch do
- subject(:switch) { described_class.new(name, pin: pin) }
+ context 'valid switch' do
+ subject(:switch) { described_class.new(name, pin: valid_pin) }
- let(:name) { "Light" }
- let(:pin) { 3 }
+ let(:name) { "Light" }
+ let(:valid_pin) { 18 }
- its(:name) { should eq(name) }
- its(:id) { should eq(:light) }
- its(:type) { should eq(:switch) }
- its(:pin) { should eq(3) }
+ its(:name) { should eq(name) }
+ its(:id) { should eq(:light) }
+ its(:type) { should eq(:switch) }
+ its(:pin) { should eq(18) }
+ end
+
+ context 'invalid switch' do
+ let(:invalid_pin) { 3 }
+
+ it 'should raise an error upon initialization' do
+ expect { described_class.new(name, pin: invalid_pin) }.to raise_error
+ end
+ end
end