Skip to content
Browse files

Add specs

  • Loading branch information...
1 parent 051cc2a commit d461e6e2badb9666e270cbce2c73c97f713769be @lenniboy lenniboy committed
Showing with 108 additions and 0 deletions.
  1. +5 −0 Gemfile
  2. +20 −0 Gemfile.lock
  3. +6 −0 Rakefile
  4. +9 −0 spec/fixtures/vanilla.expected.scala
  5. +9 −0 spec/fixtures/vanilla.scala
  6. +15 −0 spec/import_sorting_spec.rb
  7. +44 −0 spec/spec_helper.rb
View
5 Gemfile
@@ -0,0 +1,5 @@
+source 'https://rubygems.org'
+gem 'vimrunner', '0.3.0'
+gem 'rake', '10.0.4'
+gem 'rspec', '~> 2.13.0'
+
View
20 Gemfile.lock
@@ -0,0 +1,20 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ diff-lcs (1.1.3)
+ rake (0.9.2.2)
+ rspec (2.9.0)
+ rspec-core (~> 2.9.0)
+ rspec-expectations (~> 2.9.0)
+ rspec-mocks (~> 2.9.0)
+ rspec-core (2.9.0)
+ rspec-expectations (2.9.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.9.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ rake
+ rspec
View
6 Rakefile
@@ -0,0 +1,6 @@
+require 'rspec/core/rake_task'
+
+RSpec::Core::RakeTask.new
+
+task :test => :spec
+task :default => :spec
View
9 spec/fixtures/vanilla.expected.scala
@@ -0,0 +1,9 @@
+package com.foo
+
+import java.bla
+import scala.horst
+
+import AgentTypes._
+import akka.actor.{Actor, ActorLogging, ActorRef, ActorRefFactory, ActorSystem, Props, Stash, Terminated}
+
+class Bar
View
9 spec/fixtures/vanilla.scala
@@ -0,0 +1,9 @@
+package com.foo
+
+import java.bla
+import AgentTypes._
+import scala.horst
+
+import akka.actor.{Actor, ActorLogging, ActorRef, ActorRefFactory, ActorSystem, Props, Stash, Terminated}
+
+class Bar
View
15 spec/import_sorting_spec.rb
@@ -0,0 +1,15 @@
+require "spec_helper"
+
+describe ":SortScalaImports" do
+
+ describe "Sorting across groups" do
+ ["vanilla"].each do |name|
+ it "should sort vanilla file" do
+ actual = sort_fixture_across_groups name
+ expected = expected(name)
+ actual.should eq(expected)
+ end
+ end
+ end
+
+end
View
44 spec/spec_helper.rb
@@ -0,0 +1,44 @@
+require 'vimrunner'
+require 'tempfile'
+
+PWD = File.expand_path File.dirname(__FILE__)
+
+RSpec.configure do |config|
+
+ config.before(:suite) do
+ VIM = Vimrunner.start
+ VIM.add_plugin(File.expand_path('../..', __FILE__), 'plugin/scala.vim')
+ end
+
+ config.after(:suite) do
+ VIM.kill
+ end
+end
+
+def sort_fixture_across_groups(name)
+ fixture_path = "#{PWD}/fixtures/#{name}.scala"
+
+ temp_file = Tempfile.new('vim-scala-')
+ temp_file.write File.read(fixture_path)
+ temp_file.rewind
+
+ VIM.edit temp_file.path
+
+ VIM.command "let g:scala_sort_across_groups=1"
+ VIM.command "SortScalaImports"
+ VIM.write
+
+ temp_file.rewind
+ output = temp_file.read
+
+ temp_file.close
+ temp_file.unlink
+
+ output
+end
+
+def expected(name)
+ path = "#{PWD}/fixtures/#{name}.expected.scala"
+ File.read(path)
+end
+

0 comments on commit d461e6e

Please sign in to comment.
Something went wrong with that request. Please try again.