spec/spec/cicero_spec.rb in cicero-0.0.1 vs spec/spec/cicero_spec.rb in cicero-0.0.2iain
- old
+ new
@@ -17,10 +17,18 @@
it 'Gets the locale' do
Cicero.locale.should eql('LA')
end
end
+ describe "locales" do
+ subject { Cicero.locales }
+ it { should_not be_nil }
+ it { should be_a_kind_of Array }
+ it { should_not be_empty }
+ it { should include 'LA' }
+ end
+
describe "#full_text" do
it 'Returns the full lorem ipsum text' do
Cicero.full_text.should eql(CiceroText::LA)
end
end
@@ -87,17 +95,31 @@
end
end
describe '#paragraphs' do
context 'With no parameters' do
- it 'Returns a single paragraph' do
- Cicero.paragraphs.split('. ').size.should eql 7
- end
+ subject { Cicero.paragraphs }
+ it { subject.split('. ').should have_exactly(7).sentences }
+ it { should end_with "\n" }
+ it { should match /\A\w[^\n]+\Z/ }
end
context 'With parameters' do
- it "Returns 'n' paragraphs" do
- Cicero.paragraphs(3).split('. ').size.should eql (19)
+ context "for 1 paragraph" do
+ let(:n) { 1 }
+ subject { Cicero.paragraphs( n ) }
+ it { should end_with "\n" }
+ it { should match /\A\w[^\n]+\Z/ }
+ it { subject.split("\n").should have_exactly(n).paragraphs }
+ it { subject.split('. ').should have_exactly(7).sentences }
+ end
+ context "for greater than 1 paragraph" do
+ let(:n) { rand(7) + 2 }
+ subject { Cicero.paragraphs( n ) }
+ it { should end_with "\n" }
+ it { should_not match /\A\w[^\n]+\Z/ }
+ it { subject.split("\n").should have_exactly(n).paragraphs }
+ it { subject.split("\n").join(" ").split('. ').should have_exactly(n * 7).sentences }
end
end
end
end