despeckle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in despeckle.gemspec
4
+ gemspec
@@ -0,0 +1,25 @@
1
+ despeckle
2
+ =========
3
+
4
+ A script that helps you do most of the work required to convert RSpec
5
+ tests to use MiniTest and Nutrasuite.
6
+
7
+ Currently only the xUnit style assertions are supported, but if there's
8
+ much interest in it, MiniTest::Spec support would be easy to add.
9
+
10
+ Features
11
+ --------
12
+
13
+ - Top level `describe` blocks are converted to class statements.
14
+ - Nested `describe` blocks are converted to Nutrasuite `the` blocks.
15
+ - Many `.should` statements are mapped to their equivalent assertions.
16
+
17
+ Installation
18
+ ------------
19
+
20
+ $ gem install despeckle
21
+
22
+ Usage
23
+ -----
24
+
25
+ $ despeckle < spec/thing_spec.rb > test/thing_test.rb
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Does most of the work required to convert RSpec tests to use MiniTest
4
+ # and Nutrasuite.
5
+ #
6
+ # Usage: despeckle < spec/thing_spec.rb > test/thing_test.rb
7
+
8
+ def convert_require_statements(line)
9
+ line.sub /^(require.*)(spec)/, '\1test'
10
+ end
11
+
12
+ def convert_top_level_describe_to_class(line)
13
+ if line =~ /^describe (["'](.+)["']|(\w+)) do/
14
+ testable = ($2.to_s + $3.to_s).split.map { |word| word.capitalize }.join
15
+ "class #{testable}Test < MiniTest::Unit::TestCase"
16
+ else
17
+ line
18
+ end
19
+ end
20
+
21
+ def convert_nested_describe(line)
22
+ line.sub /^(\s*)describe/, '\1the'
23
+ end
24
+
25
+ def convert_before_and_after(line)
26
+ line.sub /(before|after)[(\s]+:each\)?/, '\1'
27
+ end
28
+
29
+ def convert_should_double_equals(line)
30
+ line.sub /^(\s*)(.*)\.should == (.*)/, '\1assert_equal \3, \2'
31
+ end
32
+
33
+ def convert_should_be_comparable(line)
34
+ line.sub /^(\s*)(.*)\.should ([<>=]{1,2}) (.*)/,
35
+ '\1assert \2 \3 \4, "should be \3 #{\4}"'
36
+ end
37
+
38
+ def convert_should_be_something(line)
39
+ line.sub /^(\s*)(.*)\.should be_(.*)/, %q{\1assert \2.\3?, 'should be \3'}
40
+ end
41
+
42
+ def convert_should_match(line)
43
+ line.sub /^(\s*)(.*)\.should match\((.*)\)\s*$/,
44
+ %q{\1assert_match \3, \2, 'should match \3'}
45
+ end
46
+
47
+ def convert_should_include(line)
48
+ line.sub /^(\s*)(.*)\.should include\((.*)\)\s*$/, '\1assert_includes \2, \3'
49
+ end
50
+
51
+ def convert_should_not_include(line)
52
+ line.sub /^(\s*)(.*)\.should_not include\((.*)\)\s*$/, '\1refute_includes \2, \3'
53
+ end
54
+
55
+ def convert_have_matcher(line)
56
+ line.sub /^(\s*)(.*)\.should have\((\d+)\).*/, '\1assert_equal \3, \2.size'
57
+ end
58
+
59
+ ARGF.each_line do |line|
60
+ puts [
61
+ :convert_require_statements,
62
+ :convert_top_level_describe_to_class,
63
+ :convert_nested_describe,
64
+ :convert_before_and_after,
65
+ :convert_should_double_equals,
66
+ :convert_should_be_comparable,
67
+ :convert_should_be_something,
68
+ :convert_should_match,
69
+ :convert_should_include,
70
+ :convert_should_not_include,
71
+ :convert_have_matcher
72
+ ].inject(line) { |line, method| send(method, line) }
73
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "despeckle/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "despeckle"
7
+ s.version = Despeckle::VERSION
8
+ s.authors = ["Graham Ashton"]
9
+ s.email = ["graham@effectif.com"]
10
+ s.homepage = "https://github.com/gma/despeckle"
11
+ s.summary = %q{Script to help migrate from RSpect to MiniTest}
12
+ s.description = <<-EOF
13
+ RSpec is fine and everything, but now that MiniTest ships with Ruby 1.9
14
+ (and comes with the MiniTest::Spec language that's similar to RSpec),
15
+ it's easy to give MiniTest a try. This gem provides a command line
16
+ script that will do a lot of the drudgery involved in converting a spec
17
+ file to MiniTest.
18
+ EOF
19
+
20
+ s.rubyforge_project = "despeckle"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+
27
+ # specify any dependencies here; for example:
28
+ s.add_development_dependency "rake"
29
+ # s.add_runtime_dependency "rest-client"
30
+ end
@@ -0,0 +1,5 @@
1
+ require "despeckle/version"
2
+
3
+ module Despeckle
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Despeckle
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: despeckle
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Graham Ashton
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :development
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ version_requirements: *id001
32
+ prerelease: false
33
+ name: rake
34
+ description: |
35
+ RSpec is fine and everything, but now that MiniTest ships with Ruby 1.9
36
+ (and comes with the MiniTest::Spec language that's similar to RSpec),
37
+ it's easy to give MiniTest a try. This gem provides a command line
38
+ script that will do a lot of the drudgery involved in converting a spec
39
+ file to MiniTest.
40
+
41
+ email:
42
+ - graham@effectif.com
43
+ executables:
44
+ - despeckle
45
+ extensions: []
46
+
47
+ extra_rdoc_files: []
48
+
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - README.md
53
+ - Rakefile
54
+ - bin/despeckle
55
+ - despeckle.gemspec
56
+ - lib/despeckle.rb
57
+ - lib/despeckle/version.rb
58
+ homepage: https://github.com/gma/despeckle
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project: despeckle
87
+ rubygems_version: 1.8.17
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Script to help migrate from RSpect to MiniTest
91
+ test_files: []
92
+