Skip to content

Commit 37f9ce0

Browse files
author
Ryan Jacobs
committed
update specs
1 parent dccea7e commit 37f9ce0

2 files changed

Lines changed: 68 additions & 11 deletions

File tree

spec/accepted_name_spec.rb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
require "spec_helper"
22

3+
###
4+
# This spec desperately needs a rewrite.
5+
# It works, but the display is all wrong
6+
# and unreadable.
7+
#
8+
# (Sorry, I'm still learning how to format my rpecs.)
9+
###
10+
311
describe Copywriter do
412
regex = Copywriter::Regex
513

614
# Accepted
7-
it { expect(regex.accepted_name? "README") .to be(true) }
8-
it { expect(regex.accepted_name? "LICENSE") .to be(true) }
9-
it { expect(regex.accepted_name? "README.md") .to be(true) }
10-
it { expect(regex.accepted_name? "LICENSE.md") .to be(true) }
15+
context "a filename matching README, LICENSE, or with the extensions .md, .txt, or .html" do
16+
it { expect(regex.accepted_name? "README") .to be(true) }
17+
it { expect(regex.accepted_name? "LICENSE") .to be(true) }
18+
it { expect(regex.accepted_name? "README.md") .to be(true) }
19+
it { expect(regex.accepted_name? "LICENSE.md") .to be(true) }
1120

12-
# Accepted
13-
it { expect(regex.accepted_name? "whatever.md") .to be(true) }
14-
it { expect(regex.accepted_name? "thing.html") .to be(true) }
21+
it { expect(regex.accepted_name? "whatever.md") .to be(true) }
22+
it { expect(regex.accepted_name? "thing.html") .to be(true) }
23+
end
1524

1625
# Not Accepted
17-
it { expect(regex.accepted_name? "garbage") .to be(false) }
18-
it { expect(regex.accepted_name? "colors.py") .to be(false) }
19-
it { expect(regex.accepted_name? "list_files.c") .to be(false) }
20-
it { expect(regex.accepted_name? "coolLib.js") .to be(false) }
26+
context "a filename NOT matching README, LICENSE, or with the extensions .md, .txt, or .html" do
27+
it { expect(regex.accepted_name? "garbage") .to be(false) }
28+
it { expect(regex.accepted_name? "colors.py") .to be(false) }
29+
it { expect(regex.accepted_name? "list_files.c") .to be(false) }
30+
it { expect(regex.accepted_name? "coolLib.js") .to be(false) }
31+
end
2132
end

spec/copyright_spec.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require "spec_helper"
2+
3+
###
4+
# This spec desperately needs a rewrite.
5+
# It works, but the display is all wrong
6+
# and unreadable.
7+
#
8+
# (Sorry, I'm still learning how to format my rpecs.)
9+
###
10+
11+
copyrights = [
12+
{ :old => "Copyright 1970", :new => "Copyright 2014" },
13+
{ :old => "copyright 1970", :new => "copyright 2014" },
14+
15+
{ :old => "Copyright (C) 1970", :new => "Copyright (C) 2014" },
16+
{ :old => "copyright (c) 1970", :new => "copyright (c) 2014" },
17+
{ :old => "Copyright © 1970", :new => "Copyright © 2014" },
18+
{ :old => "copyright © 1970", :new => "copyright © 2014" },
19+
20+
{ :old => "(c) 1970", :new => "(c) 2014" },
21+
{ :old => "(C) 1970", :new => "(C) 2014" },
22+
{ :old => "© 1970", :new => "© 2014" },
23+
]
24+
25+
# ./lib/github-copywriter/regex.rb
26+
describe Copywriter do
27+
regex = Copywriter::Regex
28+
29+
# Copywriter::Regex.update_copyright ->
30+
# should return the updated copyright if the input was out of date
31+
context "an out-of-date copyright..." do
32+
copyrights.each do |copyright|
33+
updated_copyright = regex.update_copyright(2014, copyright[:old])
34+
it { expect(updated_copyright).to eq(copyright[:new]) }
35+
end
36+
end
37+
38+
# Copywriter::Regex.update_copyright ->
39+
# should return nil if the input was up-to-date
40+
context "an up-to-date copyright..." do
41+
copyrights.each do |copyright|
42+
updated_copyright = regex.update_copyright(2014, copyright[:new])
43+
it { expect(updated_copyright).to be(nil) }
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)