sinatra / mustermann

your personal string matching expert
http://sinatrarb.com/mustermann/
MIT License
664 stars 63 forks source link

Add Ruby 2.6 to Travis CI #94

Closed junaruga closed 4 years ago

junaruga commented 5 years ago

I tried to add Ruby 2.6 case to Travis CI. But on Ruby 2.6 the keyword arguments allow only Symbol. Hash argument with the keyword argument should specify Hash with {}.

In the a test code of mustermann, there are tests to check the order of the hash object key word argument and another keyword argument as a option. This tests have to be changed to some better way.

There are error messages like this.

  5) Mustermann::Mapper initialize allows specifying type 
     Failure/Error: subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, "/foo" => "/bar") }

     ArgumentError:
       non-symbol key in keyword arguments: "/foo"
     # ./mustermann/spec/mapper_spec.rb:37:in `new'
     # ./mustermann/spec/mapper_spec.rb:37:in `block (4 levels) in <top (required)>'
     # ./mustermann/spec/mapper_spec.rb:40:in `block (4 levels) in <top (required)>'

How to fix it? Adding {} like this is grammatically not correct.

$ git diff mustermann/spec/mapper_spec.rb
diff --git a/mustermann/spec/mapper_spec.rb b/mustermann/spec/mapper_spec.rb
index 784a856..25150c3 100644
--- a/mustermann/spec/mapper_spec.rb
+++ b/mustermann/spec/mapper_spec.rb
@@ -33,7 +33,7 @@ describe Mustermann::Mapper do
     end

     context 'allows specifying type' do
-      subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, "/foo" => "/bar") }
+      subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, {"/foo" => "/bar"}) }
       its(:to_h) { should be == { Mustermann.new("/foo", type: :rails) => Mustermann::Expander.new("/bar", type: :rails) } }
       example { mapper['/foo'].should be == '/bar' }
       example { mapper['/fox'].should be == '/fox' }
junaruga commented 5 years ago

ping.

jkowens commented 5 years ago

Adding {} like this is grammatically not correct.

Can you explain what you mean?

junaruga commented 5 years ago

I just wanted to say { ... } in {"/foo" => "/bar"} in following line is not correct.

+      subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, {"/foo" => "/bar"}) }
junaruga commented 5 years ago
$ git diff
diff --git a/mustermann/spec/mapper_spec.rb b/mustermann/spec/mapper_spec.rb
index 784a856..25150c3 100644
--- a/mustermann/spec/mapper_spec.rb
+++ b/mustermann/spec/mapper_spec.rb
@@ -33,7 +33,7 @@ describe Mustermann::Mapper do
     end

     context 'allows specifying type' do
-      subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, "/foo" => "/bar") }
+      subject(:mapper) { Mustermann::Mapper.new(additional_values: :raise, type: :rails, {"/foo" => "/bar"}) }
       its(:to_h) { should be == { Mustermann.new("/foo", type: :rails) => Mustermann::Expander.new("/bar", type: :rails) } }
       example { mapper['/foo'].should be == '/bar' }
       example { mapper['/fox'].should be == '/fox' }

$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

$ ruby -cW mustermann/spec/mapper_spec.rb 
mustermann/spec/mapper_spec.rb:36: syntax error, unexpected ')', expecting =>
...pe: :rails, {"/foo" => "/bar"}) }
mustermann/spec/mapper_spec.rb:40: syntax error, unexpected end, expecting '}'
    end
mustermann/spec/mapper_spec.rb:84: syntax error, unexpected end-of-input, expecting end
namusyaka commented 4 years ago

Hey @junaruga, sorry for the late reply. I can't merge this because of conflicts, and I need to release a new version asap. But I put your name in our release notes, please check it out.

junaruga commented 4 years ago

But I put your name in our release notes, please check it out.

Hi namusyaka, sure. I checked it now, and it's okay.