spec/groupdocs/api/helpers/actions_helper_spec.rb in groupdocs-0.2.3 vs spec/groupdocs/api/helpers/actions_helper_spec.rb in groupdocs-0.2.4

- old
+ new

@@ -4,10 +4,14 @@ subject do Object.extend(described_class) end + let(:actions) do + %w(convert combine compress_zip compress_rar trace convert_body bind_data print import_annotations) + end + describe 'ACTIONS' do it 'contains hash of actions' do described_class::ACTIONS.should == { none: 0, convert: 1, @@ -21,31 +25,41 @@ import_annotations: 256, } end end - describe '.convert_actions' do + describe '.convert_actions_to_byte' do it 'raises error if actions is not an array' do - -> { subject.convert_actions(:convert) }.should raise_error(ArgumentError) + -> { subject.convert_actions_to_byte(:convert) }.should raise_error(ArgumentError) end it 'raises error if action is unknown' do - -> { subject.convert_actions(%w(unknown)) }.should raise_error(ArgumentError) + -> { subject.convert_actions_to_byte(%w(unknown)) }.should raise_error(ArgumentError) end it 'converts each action to Symbol' do actions = %w(none convert) actions.each do |action| symbol = action.to_sym action.should_receive(:to_sym).and_return(symbol) end - subject.convert_actions(actions) + subject.convert_actions_to_byte(actions) end it 'returns correct byte flag' do - actions = %w(none convert combine compress_zip compress_rar trace convert_body bind_data print import_annotations) - flag = subject.convert_actions(actions) + flag = subject.convert_actions_to_byte(actions) flag.should be_an(Integer) flag.should == 511 + end + end + + describe '#convert_byte_to_actions' do + it 'raises error if byte is not an integer' do + -> { subject.convert_byte_to_actions('byte') }.should raise_error(ArgumentError) + end + + + it 'returns correct array of actions' do + subject.convert_byte_to_actions(511).should =~ actions.map(&:to_sym) end end end