speci 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Pavel Evstigneev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Speci
2
+
3
+ It's a continuously turbo-fast rspec runner with IRB-like console.
4
+
5
+ ## Install
6
+
7
+ gem install speci
8
+
9
+ ## Usage
10
+
11
+ Inside your rails folder
12
+
13
+ speci
14
+
15
+
16
+ #### Command-line options
17
+
18
+ "*" or "spec all" # => run all spec from ./spec frolder
19
+ "spec" or "spec again" # => run specs again
20
+ "spec/intergration/*" # => run all integration specs
21
+
22
+ "exit" or "quit" # => exit
23
+ "restart" # => restart itself
24
+ "reload!" # => reload rails environment (same as "reload!" in rails console)
25
+
26
+
27
+ License
28
+ -----------------
29
+
30
+ Please see [LICENSE](https://github.com/Paxa/speci/blob/master/LICENSE) for licensing details.
31
+
32
+
33
+ Author
34
+ -----------------
35
+
36
+ Pavel Evstigneev
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/speci'
4
+
5
+ Speci.start
@@ -0,0 +1,49 @@
1
+ require "listen"
2
+ require "rb-fsevent"
3
+ #require 'readline'
4
+ require "ripl"
5
+ require "looksee"
6
+
7
+ require "pathname"
8
+ require "benchmark"
9
+
10
+ unless $LOAD_PATH.include?(File.dirname(__FILE__))
11
+ $LOAD_PATH << File.dirname(__FILE__)
12
+ end
13
+
14
+ require "speci/listener"
15
+ require "speci/console"
16
+ require "speci/spec_runner"
17
+ require "speci/version"
18
+
19
+ module Speci
20
+ extend self
21
+
22
+ @specs_to_run = []
23
+ @last_specs
24
+ @root_path = ""
25
+ attr_reader :root_path
26
+ attr_accessor :specs_to_run
27
+ attr_accessor :last_specs
28
+
29
+ def start
30
+ @root_path = Dir.pwd
31
+
32
+ Listener.start
33
+ require 'rspec/core'
34
+
35
+ Console.readline
36
+ end
37
+
38
+ def restart!
39
+ exec "ruby #{$PROGRAM_NAME}"
40
+ end
41
+
42
+ def reload_rails!
43
+ if defined?(ActionDispatch)
44
+ ActionDispatch::Reloader.cleanup!
45
+ ActionDispatch::Reloader.prepare!
46
+ puts "Reloading..."
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,126 @@
1
+ module Ripl::Shell::API
2
+ alias_method :eval_input_super, :eval_input
3
+ def eval_input(input)
4
+ halt = Speci::Console.process_line(input)
5
+ eval_input_super(input) unless halt
6
+ end
7
+ end
8
+
9
+ module Speci
10
+ module Console
11
+ extend self
12
+
13
+ def readline
14
+ Ripl.config[:irbrc] = false
15
+ Ripl::Commands.include(Speci::Console::Commands)
16
+ Ripl.start
17
+ return
18
+ loop do
19
+ line = Readline::readline('> ')
20
+ break if line.nil? || line == 'quit' || line == 'exit'
21
+ Readline::HISTORY.push(line) unless line == ""
22
+ process_line(line)
23
+ run_specs
24
+ end
25
+ end
26
+
27
+ def process_line(line)
28
+ do_run_specs = false
29
+ case line
30
+ when "*" then
31
+ mark_all_specs_to_run
32
+ do_run_specs = true
33
+ when "quit", "exit" then exit
34
+ end
35
+
36
+ # empty line
37
+ if line =~ /^\s*$/
38
+ do_run_specs = true
39
+ end
40
+
41
+ # spec/*
42
+ if line.start_with?('spec/')
43
+ if line.end_with?('*')
44
+ line = line + '*/*_spec.rb'
45
+ end
46
+ Speci.specs_to_run.push(*Dir[root_path.join(line).to_s])
47
+ do_run_specs = true
48
+ end
49
+
50
+ # spec all
51
+ # spec again
52
+ # spec
53
+ if line.start_with?('spec')
54
+ parts = line.split(' ')
55
+ case parts[1]
56
+ when 'all' then mark_all_specs_to_run
57
+ when 'again', nil then Speci.specs_to_run.push(*Speci.last_specs)
58
+ else
59
+ puts "unknown command '#{parts[1]}'"
60
+ end
61
+
62
+ do_run_specs = true
63
+ end
64
+
65
+ if do_run_specs
66
+ run_specs
67
+ return true
68
+ else
69
+ return false
70
+ end
71
+ end
72
+
73
+ def mark_all_specs_to_run
74
+ Speci.specs_to_run.push *Dir[root_path.join('spec/**/*_spec.rb').to_s]
75
+ end
76
+
77
+ def run_specs
78
+ if Speci.specs_to_run.size > 0
79
+ specs_tmp = Speci.specs_to_run.dup
80
+ Speci.last_specs = Speci.specs_to_run.dup
81
+ Speci.specs_to_run.clear
82
+
83
+ print "running specs "
84
+ p specs_tmp.map {|f| f.sub(Speci.root_path + '/', '') }
85
+
86
+ puts Benchmark.measure {
87
+ begin
88
+ SpecRunner.run_specs(specs_tmp)
89
+ rescue => e
90
+ puts e.message
91
+ puts e.backtrace
92
+ end
93
+ }
94
+ else
95
+ puts "no specs to run"
96
+ end
97
+ end
98
+
99
+ def eval_line(line)
100
+ begin
101
+ res instance_eval(line)
102
+ p res
103
+ rescue Object => e
104
+ p e.message
105
+ end
106
+ end
107
+
108
+ def root_path
109
+ @root_path ||= Pathname.new(Speci.root_path)
110
+ end
111
+ end
112
+ end
113
+
114
+ module Speci::Console::Commands
115
+ def reload!
116
+ Speci.reload_rails!
117
+ end
118
+
119
+ def restart
120
+ Speci.restart!
121
+ end
122
+
123
+ def spec
124
+ # just autocomplete
125
+ end
126
+ end
@@ -0,0 +1,42 @@
1
+ module Speci
2
+ module Listener
3
+ extend self
4
+
5
+ def start
6
+ @listener = Listen.to(Speci.root_path)
7
+ @listener = @listener.ignore(%r{^.git})
8
+ @listener = @listener.filter(/\.rb$/)
9
+ @listener = @listener.latency(0.5)
10
+
11
+ @listener = @listener.polling_fallback_message(false)
12
+
13
+ @listener = @listener.change do |files|
14
+ begin
15
+ files.delete_if {|file| file == __FILE__ }
16
+ files.each do |file|
17
+ file = file.sub(Speci.root_path, '')
18
+ if file == "spec/spec_helper.rb"
19
+ puts "Force reload #{file}"
20
+ Speci.restart!
21
+ elsif file.start_with?('spec/')
22
+ Speci.specs_to_run << file unless Speci.specs_to_run.include?(file)
23
+ end
24
+ end
25
+
26
+ puts "Files changed #{files.inspect}"
27
+
28
+ Speci.reload_rails
29
+ if files.select {|f| !f.start_with?('spec/') }.size > 0
30
+ Speci.reload_rails!
31
+ end
32
+ rescue => e
33
+ puts e.message
34
+ puts e.backtrace
35
+ end
36
+ end
37
+
38
+ puts 'start listener'
39
+ @listener.start
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,27 @@
1
+ module Speci
2
+ module SpecRunner
3
+ extend self
4
+
5
+ def run_specs(files)
6
+ options = RSpec::Core::ConfigurationOptions.new(files)
7
+ options.parse_options
8
+ RSpec::Core::CommandLine.new(options, RSpec::configuration.dup).run($stderr, $stdout)
9
+ ensure
10
+ reset
11
+ end
12
+
13
+ def preload_spec_helper
14
+ spec_helper_location = File.join(Speci.root_path, 'spec/spec_helper.rb')
15
+ unless $LOADED_FEATURES.include?(spec_helper_location)
16
+ require spec_helper_location
17
+ end
18
+ end
19
+
20
+ def reset
21
+ conf = RSpec::configuration
22
+ conf.reset
23
+ RSpec.reset
24
+ RSpec::configuration = conf
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module Speci
2
+ VERSION = '0.1'
3
+
4
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../lib/speci/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Pavel Evstigneev"]
5
+ gem.email = ["pavel.evst@gmail.com"]
6
+ gem.description = gem.summary = "Continiusly rspec runner"
7
+ #gem.homepage = "http://"
8
+ gem.license = "MIT"
9
+
10
+ gem.executables = ['speci']
11
+ gem.files = `git ls-files | grep -Ev '^(myapp|examples)'`.split("\n")
12
+ #gem.test_files = `git ls-files -- test/*`.split("\n")
13
+ gem.name = "speci"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Speci::VERSION
16
+
17
+ gem.add_dependency 'listen', "~> 1.3.0"
18
+ gem.add_dependency 'rb-fsevent', "~> 0.9.3"
19
+ gem.add_dependency 'ripl', "~> 0.7"
20
+ gem.add_dependency 'looksee', "~> 1.1.0"
21
+ #gem.add_dependency 'rb-readline', "~> 0.5.0"
22
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: speci
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pavel Evstigneev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: listen
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rb-fsevent
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: ripl
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.7'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: looksee
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.0
78
+ description: Continiusly rspec runner
79
+ email:
80
+ - pavel.evst@gmail.com
81
+ executables:
82
+ - speci
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - LICENSE
87
+ - README.md
88
+ - bin/speci
89
+ - lib/speci.rb
90
+ - lib/speci/console.rb
91
+ - lib/speci/listener.rb
92
+ - lib/speci/spec_runner.rb
93
+ - lib/speci/version.rb
94
+ - speci.gemspec
95
+ homepage:
96
+ licenses:
97
+ - MIT
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.25
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Continiusly rspec runner
120
+ test_files: []