Created
May 24, 2010 09:29
-
-
Save diabolo/411689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
module PriceBandSpecHelper | |
def valid_attributes | |
{ | |
:start_margin => 10, | |
:end_margin => 30 | |
} | |
end | |
end | |
describe PriceBand do | |
include PriceBandSpecHelper | |
before { @price_band = PriceBand.new } | |
subject { @price_band } | |
it { should respond_to :start_margin } | |
it { should respond_to :end_margin } | |
describe 'start_margin' do | |
it "should be mandatory" do | |
@price_band.attributes = valid_attributes.except(:start_margin) | |
@price_band.should have_at_least(1).error_on(:start_margin) | |
end | |
it "should be an integer" do | |
@price_band.attributes = valid_attributes.with(:start_margin => 10.1) | |
@price_band.start_margin.should == 10 | |
@price_band.start_margin.should_not == 10.1 | |
end | |
it "should be < 100" do | |
@price_band.attributes = valid_attributes.with(:start_margin => 100) | |
@price_band.should have(1).error_on(:start_margin) | |
end | |
it "should be > -100" do | |
@price_band.attributes = valid_attributes.with(:start_margin => -100) | |
@price_band.should have(1).error_on(:start_margin) | |
end | |
end | |
describe 'end_margin' do | |
it "should be mandatory" do | |
@price_band.attributes = valid_attributes.except(:end_margin) | |
@price_band.should have_at_least(1).error_on(:end_margin) | |
end | |
it "should be an integer" do | |
@price_band.attributes = valid_attributes.with(:end_margin => 10.1) | |
@price_band.end_margin.should == 10 | |
@price_band.end_margin.should_not == 10.1 | |
end | |
it "should be < 100" do | |
@price_band.attributes = valid_attributes.with(:end_margin => 100) | |
@price_band.should have(1).error_on(:end_margin) | |
end | |
it "should be > -100" do | |
@price_band.attributes = valid_attributes.with(:end_margin => -100) | |
@price_band.should have(1).error_on(:end_margin) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment