spec/citeproc/variable_spec.rb in citeproc-1.0.1 vs spec/citeproc/variable_spec.rb in citeproc-1.0.2
- old
+ new
@@ -5,184 +5,184 @@
describe '.new' do
it { should be_an_instance_of(Variable) }
it 'is empty by default' do
- Variable.new.should be_empty
+ expect(Variable.new).to be_empty
end
it 'equals an empty string (==) by default' do
- Variable.new.should == ''
+ expect(Variable.new).to eq('')
end
it 'matches an empty pattern by default' do
- Variable.new.should =~ /^$/
+ expect(Variable.new).to match(/^$/)
end
it 'accepts a string value' do
- Variable.new('test').should == 'test'
+ expect(Variable.new('test')).to eq('test')
end
it 'accepts a numeric value' do
- Variable.new(23).should == '23'
+ expect(Variable.new(23)).to eq('23')
end
it 'accepts a floating point value' do
- Variable.new(23.12).should == '23.12'
+ expect(Variable.new(23.12)).to eq('23.12')
end
end
describe '.fields' do
it 'contains :names fields' do
- Variable.fields[:names].should_not be_empty
- Variable.fields[:name].should equal Variable.fields[:names]
+ expect(Variable.fields[:names]).not_to be_empty
+ expect(Variable.fields[:name]).to equal Variable.fields[:names]
end
it 'contains :date fields' do
- Variable.fields[:date].should_not be_empty
- Variable.fields[:dates].should equal Variable.fields[:date]
+ expect(Variable.fields[:date]).not_to be_empty
+ expect(Variable.fields[:dates]).to equal Variable.fields[:date]
end
it 'contains :text fields' do
- Variable.fields[:text].should_not be_empty
+ expect(Variable.fields[:text]).not_to be_empty
end
it 'contains :number fields' do
- Variable.fields[:numbers].should_not be_empty
- Variable.fields[:number].should_not be_empty
+ expect(Variable.fields[:numbers]).not_to be_empty
+ expect(Variable.fields[:number]).not_to be_empty
end
it 'accepts either string or symbol input' do
- Variable.fields[:names].should equal Variable.fields['names']
+ expect(Variable.fields[:names]).to equal Variable.fields['names']
end
end
describe '.types' do
it 'given a field name returns the corresponding type' do
- Variable.types.values_at(:author, :issued, :abstract, :issue).should == [:names, :date, :text, :number]
+ expect(Variable.types.values_at(:author, :issued, :abstract, :issue)).to eq([:names, :date, :text, :number])
end
it 'accepts either string or symbol input' do
- Variable.types.should have_key(:author)
- Variable.types['author'].should equal Variable.types[:author]
+ expect(Variable.types).to have_key(:author)
+ expect(Variable.types['author']).to equal Variable.types[:author]
end
end
describe '#to_s' do
it 'displays the value' do
- Variable.new('test').to_s.should == 'test'
+ expect(Variable.new('test').to_s).to eq('test')
end
end
describe '#to_i' do
it 'returns zero by default' do
- Variable.new.to_i.should == 0
+ expect(Variable.new.to_i).to eq(0)
end
context 'when the value is numeric' do
%w{ -23 -1 0 1 23 }.each do |value|
it "returns the integer value (#{value})" do
- Variable.new(value).to_i.should equal(value.to_i)
+ expect(Variable.new(value).to_i).to equal(value.to_i)
end
end
it 'returns only the first numeric value if there are several' do
- Variable.new('testing 1, 2, 3...').to_i.should == 1
+ expect(Variable.new('testing 1, 2, 3...').to_i).to eq(1)
end
end
end
describe '#to_f' do
it 'returns zero by default' do
- Variable.new.to_f.should == 0.0
+ expect(Variable.new.to_f).to eq(0.0)
end
context 'when the value is numeric' do
%w{ -23.2 -1.45 0.2 1.733 23 }.each do |value|
it "returns the integer value (#{value})" do
- Variable.new(value).to_f.should == value.to_f
+ expect(Variable.new(value).to_f).to eq(value.to_f)
end
end
it 'returns only the first numeric value if there are several' do
- Variable.new('testing 1, 2, 3...').to_f.should == 1.0
+ expect(Variable.new('testing 1, 2, 3...').to_f).to eq(1.0)
end
it 'works with dot and comma separators' do
- Variable.new('1,23').to_f.should == Variable.new('1.23').to_f
+ expect(Variable.new('1,23').to_f).to eq(Variable.new('1.23').to_f)
end
end
end
describe '#numeric?' do
it 'returns false by default' do
- Variable.new.should_not be_numeric
+ expect(Variable.new).not_to be_numeric
end
context 'variable contains a number' do
it 'returns true (string initialized)' do
- Variable.new('23').should be_numeric
- Variable.new('X23').should be_numeric
- Variable.new('23rd').should be_numeric
+ expect(Variable.new('23')).to be_numeric
+ expect(Variable.new('X23')).to be_numeric
+ expect(Variable.new('23rd')).to be_numeric
end
it 'returns true (integer initialized)' do
- Variable.new(23).should be_numeric
+ expect(Variable.new(23)).to be_numeric
end
end
context 'variable does not contain a number' do
it 'returns false for strings' do
- Variable.new('test').should_not be_numeric
+ expect(Variable.new('test')).not_to be_numeric
end
end
context 'variable contains numbers but is not numeric' do
it 'returns false for strings' do
- Variable.new('23rd test').should_not be_numeric
- Variable.new('23rd, 24th & 25th edition').should_not be_numeric
+ expect(Variable.new('23rd test')).not_to be_numeric
+ expect(Variable.new('23rd, 24th & 25th edition')).not_to be_numeric
end
end
context 'variable contains multiple numbers' do
it 'returns true for simple ranges' do
- Variable.new('23-24').should be_numeric
- Variable.new('23 - 24').should be_numeric
- Variable.new('23- 24').should be_numeric
+ expect(Variable.new('23-24')).to be_numeric
+ expect(Variable.new('23 - 24')).to be_numeric
+ expect(Variable.new('23- 24')).to be_numeric
end
it 'returns true for simple lists' do
- Variable.new('23,24').should be_numeric
- Variable.new('23 , 24').should be_numeric
- Variable.new('23, 24').should be_numeric
- Variable.new('23 ,24').should be_numeric
- Variable.new('23 ,24,25 , 26, 27').should be_numeric
+ expect(Variable.new('23,24')).to be_numeric
+ expect(Variable.new('23 , 24')).to be_numeric
+ expect(Variable.new('23, 24')).to be_numeric
+ expect(Variable.new('23 ,24')).to be_numeric
+ expect(Variable.new('23 ,24,25 , 26, 27')).to be_numeric
end
it 'returns true for complex lists' do
- Variable.new('23rd, 24th & 25th').should be_numeric
- Variable.new('X23, A2-49th & 25th & A1, B2').should be_numeric
+ expect(Variable.new('23rd, 24th & 25th')).to be_numeric
+ expect(Variable.new('X23, A2-49th & 25th & A1, B2')).to be_numeric
end
end
end
describe '#strip_markup' do
let(:greeting) { '<h1>hello<b> world</b></h1>' }
it 'returns a string stripped of html tags' do
- Variable.new(greeting).strip_markup.should == 'hello world'
+ expect(Variable.new(greeting).strip_markup).to eq('hello world')
end
it 'does not alter the value itself' do
v = Variable.new(greeting)
v.strip_markup
- v.should == greeting
+ expect(v).to eq(greeting)
end
end
describe '#strip_markup!' do
let(:greeting) { '<h1>hello<b> world</b></h1>' }
it 'strips of html tags' do
v = Variable.new(greeting)
v.strip_markup!
- v.should == 'hello world'
+ expect(v).to eq('hello world')
end
end
describe 'sorting' do