Skip to content

Commit 062f583

Browse files
committed
Use new RSpec expectation syntax.
1 parent bb0a486 commit 062f583

File tree

7 files changed

+51
-49
lines changed

7 files changed

+51
-49
lines changed

spec/pith/config_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
describe "#ignore_patterns" do
99

1010
it "is a set" do
11-
config.ignore_patterns.should be_kind_of(Set)
11+
expect(config.ignore_patterns).to be_kind_of(Set)
1212
end
1313

1414
it "includes some sensible defaults" do
15-
config.ignore_patterns.should include("_*")
16-
config.ignore_patterns.should include(".git")
17-
config.ignore_patterns.should include(".svn")
15+
expect(config.ignore_patterns).to include("_*")
16+
expect(config.ignore_patterns).to include(".git")
17+
expect(config.ignore_patterns).to include(".svn")
1818
end
1919

2020
end
@@ -23,19 +23,19 @@
2323

2424
it "adds to ignore_patterns" do
2525
config.ignore("foo")
26-
config.ignore_patterns.should be_member('foo')
26+
expect(config.ignore_patterns).to be_member('foo')
2727
end
2828

2929
it "adds multiple patterns to ignore_patterns (when passed multiple arguments)" do
3030
config.ignore("foo", "bar")
31-
config.ignore_patterns.should be_member('foo')
32-
config.ignore_patterns.should be_member('bar')
31+
expect(config.ignore_patterns).to be_member('foo')
32+
expect(config.ignore_patterns).to be_member('bar')
3333
end
3434

3535
it "adds multiple patterns to ignore_patterns (when passed an array)" do
3636
config.ignore(["foo", "bar"])
37-
config.ignore_patterns.should be_member('foo')
38-
config.ignore_patterns.should be_member('bar')
37+
expect(config.ignore_patterns).to be_member('foo')
38+
expect(config.ignore_patterns).to be_member('bar')
3939
end
4040

4141
end

spec/pith/input_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def make_input(path)
2424
make_input("dir/some_page.html.md.erb")
2525
end
2626

27-
it { should be_template }
27+
it { is_expected.to be_template }
2828

2929
describe "#title" do
3030

3131
it "is based on last component of filename" do
32-
subject.title.should == "Some page"
32+
expect(subject.title).to eq("Some page")
3333
end
3434

3535
it "can be over-ridden in metadata" do
@@ -38,31 +38,31 @@ def make_input(path)
3838
i.puts "title: Blah blah"
3939
i.puts "..."
4040
end
41-
input.title.should == "Blah blah"
41+
expect(input.title).to eq("Blah blah")
4242
end
4343

4444
end
4545

4646
describe "#output" do
4747

4848
it "returns an Output" do
49-
subject.output.should_not be_nil
49+
expect(subject.output).not_to be_nil
5050
end
5151

5252
end
5353

5454
describe "#output_path" do
5555

5656
it "excludes the template-type extensions" do
57-
subject.output_path.should == Pathname("dir/some_page.html")
57+
expect(subject.output_path).to eq(Pathname("dir/some_page.html"))
5858
end
5959

6060
end
6161

6262
describe "#pipeline" do
6363

6464
it "is a list of Tilt processors" do
65-
subject.pipeline.should == [Tilt["erb"], Tilt["md"]]
65+
expect(subject.pipeline).to eq([Tilt["erb"], Tilt["md"]])
6666
end
6767

6868
end
@@ -75,11 +75,11 @@ def make_input(path)
7575
make_input("dir/some_image.gif")
7676
end
7777

78-
it { should_not be_template }
78+
it { is_expected.not_to be_template }
7979

8080
describe "pipeline" do
8181
it "should be empty" do
82-
subject.pipeline.should be_empty
82+
expect(subject.pipeline).to be_empty
8383
end
8484
end
8585

@@ -93,7 +93,7 @@ def make_input(path)
9393

9494
describe "output" do
9595
it "should be nil" do
96-
subject.output.should be_nil
96+
expect(subject.output).to be_nil
9797
end
9898
end
9999

spec/pith/pathname_ext_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
describe "#in?" do
99

1010
it "returns false for siblings" do
11-
pathname.in?("foo/baz").should == false
11+
expect(pathname.in?("foo/baz")).to eq(false)
1212
end
1313

1414
it "returns true for ancestors" do
15-
pathname.in?("foo").should == true
15+
expect(pathname.in?("foo")).to eq(true)
1616
end
1717

1818
it "returns false for other prefixes" do
19-
pathname.in?("fo").should == false
20-
pathname.in?("foo/b").should == false
19+
expect(pathname.in?("fo")).to eq(false)
20+
expect(pathname.in?("foo/b")).to eq(false)
2121
end
2222

2323
it "returns false for itself" do
24-
pathname.in?("foo/bar").should == false
24+
expect(pathname.in?("foo/bar")).to eq(false)
2525
end
2626

2727
end

spec/pith/plugins/publication_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
describe "#published_at" do
1212

1313
it "defaults to nil" do
14-
@template.published_at.should be_nil
14+
expect(@template.published_at).to be_nil
1515
end
1616

1717
it "is derived by parsing the 'published' meta-field" do
1818
@template.meta["published"] = "25 Dec 1999 22:30"
19-
@template.published_at.should == Time.local(1999, 12, 25, 22, 30)
19+
expect(@template.published_at).to eq(Time.local(1999, 12, 25, 22, 30))
2020
end
2121

2222
it "honours any parsing (of Time) that yaml may do on the 'published' meta-field" do
2323
@template.meta["published"] = Time.local(1999, 12, 25, 22, 30)
24-
@template.published_at.should == Time.local(1999, 12, 25, 22, 30)
24+
expect(@template.published_at).to eq(Time.local(1999, 12, 25, 22, 30))
2525
end
2626

2727
it "honours any parsing (to Date) of time that yaml may do on the 'published' meta-field" do
2828
@template.meta["published"] = Date.new(1999, 12, 25)
29-
@template.published_at.should == Time.local(1999, 12, 25)
29+
expect(@template.published_at).to eq(Time.local(1999, 12, 25))
3030
end
3131

3232
end
@@ -35,18 +35,18 @@
3535

3636
it "defaults to #published_at" do
3737
@template.meta["published"] = "25 Dec 1999 22:30"
38-
@template.updated_at.should == Time.local(1999, 12, 25, 22, 30)
38+
expect(@template.updated_at).to eq(Time.local(1999, 12, 25, 22, 30))
3939
end
4040

4141
it "can be overridden with an 'updated' meta-field" do
4242
@template.meta["published"] = "25 Dec 1999 22:30"
4343
@template.meta["updated"] = "1 Jan 2000 03:00"
44-
@template.updated_at.should == Time.local(2000, 1, 1, 3, 0)
44+
expect(@template.updated_at).to eq(Time.local(2000, 1, 1, 3, 0))
4545
end
4646

4747
it "honours any parsing of time that yaml may do on the 'updated' meta-field" do
4848
@template.meta["updated"] = Date.new(2000, 1, 1)
49-
@template.updated_at.should == Time.local(2000, 1, 1)
49+
expect(@template.updated_at).to eq(Time.local(2000, 1, 1))
5050
end
5151

5252
end

spec/pith/project_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
end
1515

1616
it "creates the output directory" do
17-
$output_dir.should be_directory
17+
expect($output_dir).to be_directory
1818
end
1919

2020
end
@@ -31,22 +31,22 @@
3131

3232
it "returns an Input object" do
3333
@input = @project.input("input.html.haml")
34-
@input.should be_kind_of(Pith::Input)
35-
@input.file.should == @input_file
34+
expect(@input).to be_kind_of(Pith::Input)
35+
expect(@input.file).to eq(@input_file)
3636
end
3737

3838
it "returns the same object the second time" do
3939
first_time = @project.input("input.html.haml")
4040
second_time = @project.input("input.html.haml")
41-
second_time.should equal(first_time)
41+
expect(second_time).to equal(first_time)
4242
end
4343

4444
end
4545

4646
describe "(with an invalid input path)" do
4747

4848
it "returns nil" do
49-
@project.input("bogus.path").should be_nil
49+
expect(@project.input("bogus.path")).to be_nil
5050
end
5151

5252
end
@@ -66,8 +66,8 @@
6666
let(:output) { @project.output("input.html") }
6767

6868
it "returns the matching Output" do
69-
output.should be_kind_of(Pith::Output)
70-
output.file.should == $output_dir + "input.html"
69+
expect(output).to be_kind_of(Pith::Output)
70+
expect(output.file).to eq($output_dir + "input.html")
7171
end
7272

7373
end
@@ -77,7 +77,7 @@
7777
let(:output) { @project.output("bogus.html.haml") }
7878

7979
it "returns nil" do
80-
output.should be_nil
80+
expect(output).to be_nil
8181
end
8282

8383
end
@@ -90,26 +90,26 @@
9090
@input_file = $input_dir + "input.html.haml"
9191
@input_file.touch(Time.now - 10)
9292
@project.sync
93-
@project.input("input.html.haml").should_not be_nil
94-
@project.output("input.html").should_not be_nil
93+
expect(@project.input("input.html.haml")).not_to be_nil
94+
expect(@project.output("input.html")).not_to be_nil
9595
FileUtils.rm(@input_file)
9696
@project.sync
9797
end
9898

9999
describe "#input" do
100100
it "returns nil" do
101-
@project.input("input.html.haml").should be_nil
101+
expect(@project.input("input.html.haml")).to be_nil
102102
end
103103
end
104104

105105
describe "#output" do
106106
it "returns nil" do
107-
@project.output("input.html").should be_nil
107+
expect(@project.output("input.html")).to be_nil
108108
end
109109
end
110110

111111
it "doesn't confuse subsequent calls to #sync" do
112-
proc { @project.sync }.should_not raise_error
112+
expect { @project.sync }.not_to raise_error
113113
end
114114

115115
end

spec/pith/server_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
let(:request_uri) { "/bogus.html" }
5252

5353
it "does not build the output" do
54-
output.should_not_receive(:build)
54+
expect(output).not_to receive(:build)
5555
result_path
5656
end
5757

5858
it "passes on the env unchanged" do
59-
result_path.should == "/bogus.html"
59+
expect(result_path).to eq("/bogus.html")
6060
end
6161

6262
end
@@ -68,12 +68,12 @@ def self.can_request_output(description, uri)
6868
let(:request_uri) { uri }
6969

7070
it "builds the output" do
71-
output.should_receive(:build)
71+
expect(output).to receive(:build)
7272
result_path
7373
end
7474

7575
it "passes on request" do
76-
result_path.should == "/dir/index.html"
76+
expect(result_path).to eq("/dir/index.html")
7777
end
7878

7979
end
@@ -91,8 +91,8 @@ def self.can_request_output(description, uri)
9191
let(:request_uri) { "/dir" }
9292

9393
it "redirects" do
94-
result_status.should == 302
95-
result_headers["Location"].should == "/dir/"
94+
expect(result_status).to eq(302)
95+
expect(result_headers["Location"]).to eq("/dir/")
9696
end
9797

9898
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
RSpec.configure do |config|
1111

12+
config.raise_errors_for_deprecations!
13+
1214
config.before(:suite) do
1315
[$input_dir, $output_dir].each do |dir|
1416
dir.rmtree if dir.exist?

0 commit comments

Comments
 (0)