fsr 0.1.6 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47ae417bf5a363655b2f31478d055e40e9c0ba5b74f6ced67b125c6104ca1400
4
- data.tar.gz: 79bb260e4510283cda5b5a9c76e815cccf42cc35d722818e932e778d8d793c88
3
+ metadata.gz: 1007a1152ea79f91d7a34ae1ae49c0ca727f09249853e2c780345a44e9214f4e
4
+ data.tar.gz: 946ca1428e3d97e367b7f01b8f0bcff27849ae474b251f60c67437a9a7befee0
5
5
  SHA512:
6
- metadata.gz: 73e9b6ab1ccede691b6a376e6f4ace4c672f179329776789843ce45a60ed233b49271860045ef9835a016990764a1cd2d5b255dc7f2d4112b7546a368171e699
7
- data.tar.gz: d885c18291751204ffd5c2136aebe7e026d7f0e7fe1e5f2199e22e098eac5e265f641d3984546f4d1b674b2f6310bc897e50cc2353f565e2b491604cbf2405c8
6
+ metadata.gz: 96abacca6384358efdef8853019a10af4e15de3a3166d572ed4658feac5d406caf9322c39915020e7b7697889a350d2f5d69975d8b1e66c6b32b0ec564d39d11
7
+ data.tar.gz: b784142527032e170b5894a1a3052d4a9a5865aeb9ae72e2134d95758024d32fd29a2f10e2fa1374cf102f719bd3c74270f2e8072bd2eadee547fc5417c5a1fe
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.2
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fsr (0.1.6)
4
+ fsr (0.1.7)
5
5
  listen
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- ffi (1.17.0-arm64-darwin)
11
+ ffi (1.17.0)
12
12
  json (2.7.2)
13
13
  language_server-protocol (3.17.0.3)
14
14
  listen (3.9.0)
@@ -46,6 +46,7 @@ GEM
46
46
 
47
47
  PLATFORMS
48
48
  arm64-darwin-22
49
+ x86_64-darwin-23
49
50
 
50
51
  DEPENDENCIES
51
52
  fsr!
data/README.md CHANGED
@@ -1,34 +1,67 @@
1
- # Fsr
1
+ # *fsr - fast spec runner*
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fsr`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ `fsr` listens for file change events and runs RSpecs automatically in rails console avoiding the rails boot process and provides instant feedback which is crucial for Test Driven Development (TDD).
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
7
+ 1. Add `fsr` to your app’s `Gemfile` in `test`:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ ```ruby
10
+ group :test do
11
+ gem 'fsr'
12
+ end
13
+ ```
14
14
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
15
+ 2. Then, in your project directory:
16
16
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
17
+ ```sh
18
+ $ bundle install
19
+ ```
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ Open rails console in test environment.
24
+
25
+ ```rb
26
+ RAILS_ENV=test bundle exec rails c
27
+ ```
28
+
29
+ All following examples should be run in this console.
30
+
31
+ ```rb
32
+ listener = Fsr.listen(['spec/models/user_spec.rb'])
33
+ listener.start
34
+ ```
35
+
36
+ This will listen to any file change events, automatically load the changed file and run the given spec.
37
+
38
+ To stop the listener,
39
+
40
+ ```rb
41
+ listener.stop
42
+ ```
43
+
44
+ By default, it listens for file change events on `app/`, `lib/`, `spec/` directories. This can be overriden with `listen` option.
45
+
46
+ ```rb
47
+ Fsr.listen(['spec/models/user_spec.rb'], listen: ['dir/'])
48
+ ```
49
+
50
+ You can pass any RSpec command line arguments. For example, to run based on line number.
22
51
 
23
- ## Development
52
+ ```rb
53
+ Fsr.listen(['spec/models/user_spec.rb:12'])
54
+ ```
24
55
 
25
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
+ To run based on line number.
26
57
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
+ ```rb
59
+ Fsr.listen(['spec/models/user_spec.rb', 'spec/models/admin_spec.rb'])
60
+ ```
28
61
 
29
62
  ## Contributing
30
63
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fsr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fsr/blob/master/CODE_OF_CONDUCT.md).
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/elamaranae/fsr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/elamaranae/fsr/blob/master/CODE_OF_CONDUCT.md).
32
65
 
33
66
  ## License
34
67
 
@@ -36,4 +69,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
69
 
37
70
  ## Code of Conduct
38
71
 
39
- Everyone interacting in the Fsr project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fsr/blob/master/CODE_OF_CONDUCT.md).
72
+ Everyone interacting in the Fsr project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elamaranae/fsr/blob/master/CODE_OF_CONDUCT.md).
data/lib/fsr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fsr
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
data/lib/fsr.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative 'fsr/version'
4
4
  require 'listen'
5
- require 'rspec/core'
6
5
 
7
6
  $LOAD_PATH.push('spec')
8
7
 
@@ -18,22 +17,42 @@ $LOAD_PATH.push('spec')
18
17
  # listener.stop
19
18
  # ```
20
19
  module Fsr
21
- def self.listen(
22
- run,
23
- load: [],
24
- listen:
25
- [
26
- "#{`pwd`.strip}/app",
27
- "#{`pwd`.strip}/lib",
28
- "#{`pwd`.strip}/spec"
29
- ].select { |dir| Dir.exist?(dir) }
30
- )
31
- Listen.to(*listen) do |modified, added|
32
- files = [modified, added].compact.flatten if load.empty?
33
- Fsr::Runner.new(run, load: files).run
20
+ @listener = nil
21
+
22
+ LISTEN_DIRS = [
23
+ "#{`pwd`.strip}/app",
24
+ "#{`pwd`.strip}/api",
25
+ "#{`pwd`.strip}/components",
26
+ "#{`pwd`.strip}/lib",
27
+ "#{`pwd`.strip}/spec",
28
+ "#{`pwd`.strip}/db"
29
+ ].select { |dir| Dir.exist?(dir) }
30
+
31
+ def self.listen(run, load: [], listen: [])
32
+ require 'rspec/core'
33
+ ActiveRecord::Base.connection.reconnect!
34
+ @listener.stop rescue 'error'
35
+ @listener = build_listener(run, load: load, listen: listen)
36
+ @listener.start
37
+ end
38
+
39
+ def self.build_listener(run, load: [], listen: [])
40
+ listen = (listen.empty? ? LISTEN_DIRS : listen).select { |dir| Dir.exist?(dir) }
41
+ @listener = Listen.to(*listen) do |modified, added|
42
+ begin
43
+ files = [modified, added, load].compact.flatten
44
+ Fsr::Runner.new(run, load: files).run
45
+ rescue => e
46
+ puts "Something went wrong while loading the files or running the spec, #{e.message}, #{e.backtrace}"
47
+ end
34
48
  end
35
49
  end
36
50
 
51
+ def self.run(run, load: [])
52
+ ActiveRecord::Base.connection.reconnect!
53
+ Fsr::Runner.new(run, load: load).run
54
+ end
55
+
37
56
  def self.sandboxed
38
57
  orig_world = RSpec.world
39
58
  orig_example = RSpec.current_example
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fsr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elamaran Angusamy Elango
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-06-08 00:00:00.000000000 Z
10
+ date: 2025-09-10 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: listen
@@ -24,7 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- description:
28
26
  email:
29
27
  - maran@maran.dev
30
28
  executables: []
@@ -32,6 +30,7 @@ extensions: []
32
30
  extra_rdoc_files: []
33
31
  files:
34
32
  - ".rubocop.yml"
33
+ - ".ruby-version"
35
34
  - CHANGELOG.md
36
35
  - CODE_OF_CONDUCT.md
37
36
  - Gemfile
@@ -50,7 +49,6 @@ metadata:
50
49
  homepage_uri: https://maran.dev
51
50
  source_code_uri: https://github.com/elamaranae/fsr
52
51
  changelog_uri: https://github.com/elamaranae/fsr/CHANGELOG.md
53
- post_install_message:
54
52
  rdoc_options: []
55
53
  require_paths:
56
54
  - lib
@@ -65,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
63
  - !ruby/object:Gem::Version
66
64
  version: '0'
67
65
  requirements: []
68
- rubygems_version: 3.4.10
69
- signing_key:
66
+ rubygems_version: 3.6.2
70
67
  specification_version: 4
71
68
  summary: Run RSpec fast by avoiding full app boot
72
69
  test_files: []