Permalink
Browse files

Rename legacy snippet to classic

As I've been banging on about in #409
  • Loading branch information...
mattwynne committed Mar 29, 2013
1 parent 56cfdb5 commit 757bf9f7b0d96b75158fd901625197f02c9b743d
@@ -172,7 +172,7 @@ def check_nil(o, proc)
SNIPPET_TYPES = {
:regexp => Snippet::Regexp,
- :legacy => Snippet::Legacy,
+ :classic => Snippet::Classic,
:percent => Snippet::Percent
}
@@ -83,13 +83,13 @@ def self.description
end
end
- class Legacy < BaseSnippet
+ class Classic < BaseSnippet
def typed_pattern
" /^#{pattern}$/"
end
def self.description
- "Snippets without parentheses"
+ "Snippets without parentheses. Note that these cause a warning from modern versions of Ruby."
end
end
@@ -442,13 +442,13 @@ def reset_config
describe "#snippet_type" do
it "returns the snippet type when it was set" do
- config.parse!(["--snippet-type", "legacy"])
- config.snippet_type.should eql :legacy
+ config.parse!(["--snippet-type", "classic"])
+ config.snippet_type.should eql :classic
end
it "returns the snippet type when it was set with shorthand option" do
- config.parse!(["-I", "legacy"])
- config.snippet_type.should eql :legacy
+ config.parse!(["-I", "classic"])
+ config.snippet_type.should eql :classic
end
it "returns the default snippet type if it was not set" do
@@ -296,8 +296,8 @@ def after_parsing(args)
context '--snippet-type' do
it "parses the snippet type argument" do
- after_parsing('--snippet-type legacy') do
- options[:snippet_type].should eql :legacy
+ after_parsing('--snippet-type classic') do
+ options[:snippet_type].should eql :classic
end
end
end
@@ -16,51 +16,37 @@ module RbSupport
end
describe "snippets" do
-
let(:snippet) { stub.as_null_object }
- before do
- Snippet::Regexp.stub(:new => snippet)
- end
it "creates a regexp Snippet class by default" do
- Snippet::Regexp.should_receive(:new)
-
+ Snippet::Regexp.should_receive(:new).and_return(snippet)
rb.snippet_text('Given', 'A "string" with 4 spaces', nil)
end
it "creates a regexp Snippet class explicitly" do
- Snippet::Regexp.should_receive(:new)
-
+ Snippet::Regexp.should_receive(:new).and_return(snippet)
rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :regexp)
end
- it "creates a legacy Snippet class" do
- Snippet::Legacy.stub(:new => stub.as_null_object)
- Snippet::Legacy.should_receive(:new)
-
- rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :legacy)
+ it "creates a classic Snippet class" do
+ Snippet::Classic.should_receive(:new).and_return(snippet)
+ rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :classic)
end
it "creates a percent Snippet class" do
- Snippet::Percent.stub(:new => stub.as_null_object)
- Snippet::Percent.should_receive(:new)
-
+ Snippet::Percent.should_receive(:new).and_return(snippet)
rb.snippet_text('Given', 'A "string" with 4 spaces', nil, :percent)
end
it "passes all parameters to Snippet contructor" do
- code_keyword = stub
- pattern = stub
- multiline_argument_class = stub
-
+ code_keyword, pattern, multiline_argument_class = stub, stub, stub
Snippet::Regexp.should_receive(:new).with(code_keyword, pattern, multiline_argument_class)
-
rb.snippet_text(code_keyword, pattern, multiline_argument_class)
end
it "renders the snippet" do
+ Snippet::Regexp.stub(:new => snippet)
snippet.should_receive(:to_s)
-
rb.snippet_text('Given', 'A "string" with 4 spaces', nil)
end
@@ -99,8 +99,8 @@ def unindented(s)
end
end
- describe Snippet::Legacy do
- let(:snippet_class) { Snippet::Legacy }
+ describe Snippet::Classic do
+ let(:snippet_class) { Snippet::Classic }
it "renders snippet as unwrapped regular expression" do
snippet.to_s.should eql unindented(%{

0 comments on commit 757bf9f

Please sign in to comment.