Created
December 14, 2011 11:03
-
-
Save marekkirejczyk/1476137 to your computer and use it in GitHub Desktop.
Some spec
This file contains 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' | |
describe OpenQuestionnaire::Question::Item do | |
let(:item) { OpenQuestionnaire::Question::Item.new } | |
context 'before create' do | |
it 'should set position' do | |
item.should_receive :set_position | |
item.save | |
end | |
end | |
describe '#set_position' do | |
subject { item.send :set_position } | |
context 'when at least one item exist' do | |
before do | |
item.stub_chain(:question, :items, :count).and_return 9 | |
item.stub_chain(:question, :items, :order, :last, :position).and_return 9 | |
end | |
it { should eql 10 } | |
end | |
context 'when item does not exist' do | |
before { item.stub_chain(:question, :items, :count).and_return 0 } | |
it { should eql 0 } | |
end | |
end | |
describe '#current_language' do | |
let(:mock_lang) { mock 'Lang' } | |
subject { item.current_language } | |
before { item.stub_chain(:question, :group, :open_questionnaire, :current_language).and_return mock_lang } | |
it { should be mock_lang } | |
end | |
describe '#reference_language' do | |
let(:mock_lang) { mock 'Lang' } | |
subject { item.reference_language } | |
before { item.stub_chain(:question, :group, :open_questionnaire, :reference_language).and_return mock_lang } | |
it { should be mock_lang } | |
end | |
describe '#languages' do | |
let(:mock_lang) { mock 'Lang' } | |
subject { item.languages } | |
before { item.stub_chain(:question, :group, :open_questionnaire, :languages).and_return [mock_lang] } | |
it { should eql [mock_lang] } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment