|
| 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