Skip to content

Commit

Permalink
Update everything to rspec 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyqs committed Jun 21, 2014
1 parent b6171cf commit 9d32f8f
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -4,7 +4,7 @@ gemspec

group :development, :test do
gem 'rake'
gem 'rspec'
gem 'rspec', '>= 3'
gem 'tilt'
end

Expand Down
24 changes: 12 additions & 12 deletions spec/headline_spec.rb
Expand Up @@ -12,53 +12,53 @@
end

it "should reject improper initialization" do
lambda { Orgmode::Headline.new " tricked**" }.should raise_error
expect { Orgmode::Headline.new " tricked**" }.to raise_error
end

it "should properly determine headline level" do
samples = ["* one", "** two", "*** three", "**** four"]
expected = 1
samples.each do |sample|
h = Orgmode::Headline.new sample
h.level.should eql(expected)
expect(h.level).to eql(expected)
expected += 1
end
end

it "should properly determine headline level with offset" do
h = Orgmode::Headline.new("* one", nil, 1)
h.level.should eql(2)
expect(h.level).to eql(2)
end

it "should find simple headline text" do
h = Orgmode::Headline.new "*** sample"
h.headline_text.should eql("sample")
expect(h.headline_text).to eql("sample")
end

it "should understand tags" do
h = Orgmode::Headline.new "*** sample :tag:tag2:\n"
h.headline_text.should eql("sample")
expect(h.headline_text).to eql("sample")
expect(h.tags.count).to eq(2)
h.tags[0].should eql("tag")
h.tags[1].should eql("tag2")
expect(h.tags[0]).to eql("tag")
expect(h.tags[1]).to eql("tag2")
end

it "should understand a single tag" do
h = Orgmode::Headline.new "*** sample :tag:\n"
h.headline_text.should eql("sample")
expect(h.headline_text).to eql("sample")
expect(h.tags.count).to eq(1)
h.tags[0].should eql("tag")
expect(h.tags[0]).to eql("tag")
end

it "should understand keywords" do
h = Orgmode::Headline.new "*** TODO Feed cat :home:"
h.headline_text.should eql("Feed cat")
h.keyword.should eql("TODO")
expect(h.headline_text).to eql("Feed cat")
expect(h.keyword).to eql("TODO")
end

it "should recognize headlines marked as COMMENT" do
h = Orgmode::Headline.new "* COMMENT This headline is a comment"
h.comment_headline?.should_not be_nil
expect(h.comment_headline?).to_not be_nil
end
end

32 changes: 16 additions & 16 deletions spec/line_spec.rb
Expand Up @@ -65,18 +65,18 @@
end

it "should recognize indentation" do
Orgmode::Line.new("").indent.should eql(0)
Orgmode::Line.new(" a").indent.should eql(1)
Orgmode::Line.new(" ").indent.should eql(0)
Orgmode::Line.new(" \n").indent.should eql(0)
Orgmode::Line.new(" a").indent.should eql(3)
expect(Orgmode::Line.new("").indent).to eql(0)
expect(Orgmode::Line.new(" a").indent).to eql(1)
expect(Orgmode::Line.new(" ").indent).to eql(0)
expect(Orgmode::Line.new(" \n").indent).to eql(0)
expect(Orgmode::Line.new(" a").indent).to eql(3)
end

it "should return paragraph type" do
Orgmode::Line.new("").paragraph_type.should eql(:blank)
Orgmode::Line.new("1. foo").paragraph_type.should eql(:list_item)
Orgmode::Line.new("- [ ] checkbox").paragraph_type.should eql(:list_item)
Orgmode::Line.new("hello!").paragraph_type.should eql(:paragraph)
expect(Orgmode::Line.new("").paragraph_type).to eql(:blank)
expect(Orgmode::Line.new("1. foo").paragraph_type).to eql(:list_item)
expect(Orgmode::Line.new("- [ ] checkbox").paragraph_type).to eql(:list_item)
expect(Orgmode::Line.new("hello!").paragraph_type).to eql(:paragraph)
end

it "should recognize BEGIN and END comments" do
Expand All @@ -95,13 +95,13 @@
begin_examples.each_key do |str|
line = Orgmode::Line.new str
expect(line.begin_block?).to be_truthy
line.block_type.should eql(begin_examples[str])
expect(line.block_type).to eql(begin_examples[str])
end

end_examples.each_key do |str|
line = Orgmode::Line.new str
expect(line.end_block?).to be_truthy
line.block_type.should eql(end_examples[str])
expect(line.block_type).to eql(end_examples[str])
end
end

Expand All @@ -127,7 +127,7 @@
cases.each_pair do |example, expected|
it "should recognize #{example}" do
line = Orgmode::Line.new example
line.block_header_arguments.should == expected
expect(line.block_header_arguments).to eq(expected)
end
end
end
Expand All @@ -145,7 +145,7 @@
cases.each_pair do |example, expected|
it "should accept '#{example}' with assigned type #{expected}" do
line = Orgmode::Line.new(example, nil, expected)
line.assigned_paragraph_type.should == expected
expect(line.assigned_paragraph_type).to eq(expected)
end
end
end
Expand All @@ -162,8 +162,8 @@
expect(l.in_buffer_setting?).to be_truthy
called = nil
l.in_buffer_setting? do |k, v|
k.should eql(value[:key])
v.should eql(value[:value])
expect(k).to eql(value[:key])
expect(v).to eql(value[:value])
called = true
end
expect(called).to be true
Expand All @@ -181,7 +181,7 @@

cases.each do |c|
l = Orgmode::Line.new c
l.in_buffer_setting?.should be_nil
expect(l.in_buffer_setting?).to be_nil
end
end

Expand Down
20 changes: 10 additions & 10 deletions spec/output_buffer_spec.rb
Expand Up @@ -4,16 +4,16 @@

it "computes outline level numbering" do
output_buffer = Orgmode::OutputBuffer.new ""
output_buffer.get_next_headline_number(1).should eql("1")
output_buffer.get_next_headline_number(1).should eql("2")
output_buffer.get_next_headline_number(1).should eql("3")
output_buffer.get_next_headline_number(1).should eql("4")
output_buffer.get_next_headline_number(2).should eql("4.1")
output_buffer.get_next_headline_number(2).should eql("4.2")
output_buffer.get_next_headline_number(1).should eql("5")
output_buffer.get_next_headline_number(2).should eql("5.1")
output_buffer.get_next_headline_number(2).should eql("5.2")
output_buffer.get_next_headline_number(4).should eql("5.2.0.1")
expect(output_buffer.get_next_headline_number(1)).to eql("1")
expect(output_buffer.get_next_headline_number(1)).to eql("2")
expect(output_buffer.get_next_headline_number(1)).to eql("3")
expect(output_buffer.get_next_headline_number(1)).to eql("4")
expect(output_buffer.get_next_headline_number(2)).to eql("4.1")
expect(output_buffer.get_next_headline_number(2)).to eql("4.2")
expect(output_buffer.get_next_headline_number(1)).to eql("5")
expect(output_buffer.get_next_headline_number(2)).to eql("5.1")
expect(output_buffer.get_next_headline_number(2)).to eql("5.2")
expect(output_buffer.get_next_headline_number(4)).to eql("5.2.0.1")
end

end

0 comments on commit 9d32f8f

Please sign in to comment.