minispec-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -22
- data/lib/minispec/rails.rb +2 -1
- data/lib/minispec/rails/system_test.rb +1 -1
- data/lib/minispec/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bddc2b8c861fc92f800d54f42f9eeeb99af55e5
|
4
|
+
data.tar.gz: ba50defe08cfa578e94e2c6d7cd54c8bfda11da0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 500dd921bdffec8a3e4d9efb0e69f93db7c1cc51bcf7473c6bb93ee736bba6ff894987632478b286b4c420d6bce0bc0599a4331fd2093c122257edc130ce1c06
|
7
|
+
data.tar.gz: 8d5f6ccdb8a145db948e552fa265feee962ece3c9f7ad0be4ee4db40ee77cde3fd880688cdd0412a6cc3dc11ca94b021390bda740403543a8a9a4ebecbc9d5d2
|
data/README.md
CHANGED
@@ -6,19 +6,25 @@ Use Minitest::Spec in Rails.
|
|
6
6
|
|
7
7
|
There are plenty out there, and I'm sure they all work just fine.
|
8
8
|
I have personally never used any of them because it was never a big deal to insert Minitest::Spec into any Rails project manually with just a few lines of code.
|
9
|
-
|
10
|
-
But
|
9
|
+
Fewer gems/lines of code your project = better.
|
10
|
+
But I still want the convenience of a gem to get projects started quickly.
|
11
|
+
|
12
|
+
This gem gets you PURE minitest spec in a whopping 50 lines of code, and that's counting blank lines, comments, requires, and a (hopefully temporary) workaround for system tests.
|
13
|
+
There's no fancy tricks going on here.
|
14
|
+
This is plain jane minitest.
|
15
|
+
What you get is PURE spec awesomeness.
|
16
|
+
And by "PURE" I mean just `describe`s. No more defining classes on your own.
|
11
17
|
|
12
18
|
## Goals
|
13
19
|
|
14
|
-
* Get running in Rails with Minitest::Spec with minimal lines of code.
|
20
|
+
* Get running in Rails with Minitest::Spec with minimal lines of code both in installation and the gem itself.
|
15
21
|
|
16
|
-
##
|
22
|
+
## NOT Goals
|
17
23
|
|
18
|
-
* Help with migrating from "Rails style" to Spec style
|
19
|
-
* Support multiple styles. You're probably here to use Spec style, so use Spec style. Why would you want to mix and match?
|
20
|
-
* Support old Rails versions
|
21
|
-
* (for now at least) Rails generators
|
24
|
+
* **Help with migrating from "Rails style" to Spec style.** I don't recommend anyone convert any test suite to spec style for the sake of converting. You really don't gain all that much by converting.
|
25
|
+
* **Support multiple styles (i.e. unit and spec).** You're probably here to use Spec style, so use Spec style. Why would you want to mix and match? Don't define test classes. Use `describe`.
|
26
|
+
* **Support old Rails versions.** Since I don't recommend converting, it doesn't seem worth it to support older Rails versions. I'm not going to explicitly define a minimum Rails version requirement, but for development I'm going to start with 5.1.1 (see the example app).
|
27
|
+
* **(for now at least) Rails generators.** I personally don't find them all that useful. If there is enough demand for it and/or someone contributes it, I might do it, but in the interest of keeping this gem small, I'm going to skip them.
|
22
28
|
|
23
29
|
## Installation
|
24
30
|
|
@@ -39,33 +45,43 @@ Or install it yourself as:
|
|
39
45
|
## Usage
|
40
46
|
|
41
47
|
Once this gem is required, you can immediately start using it to `describe` your tests.
|
42
|
-
There is 1 exception:
|
43
|
-
|
48
|
+
There is 1 exception: system tests (see below).
|
49
|
+
|
50
|
+
### Spec Types
|
51
|
+
|
52
|
+
The key to getting the right type of test is to describe the right thing.
|
53
|
+
|
54
|
+
| Test subclass | describe example |
|
55
|
+
| ------------------------------- | --------------------------------- |
|
56
|
+
| ActionDispatch::IntegrationTest | `describe MyController` |
|
57
|
+
| ActiveJob::TestCase | `describe MyJob` |
|
58
|
+
| ActionMailer::TestCase | `describe MyMailer` |
|
59
|
+
| ActionDispatch::SystemTestCase | `describe 'Admin system'` |
|
60
|
+
| ActionDispatch::IntegrationTest | `describe 'Customer integration'` |
|
61
|
+
| ActiveSupport::TestCase | `describe 'AnythingElse'` |
|
62
|
+
|
63
|
+
### Example app
|
64
|
+
|
65
|
+
See the [example rails app](https://github.com/ordinaryzelig/minispec-rails-example).
|
66
|
+
|
67
|
+
### System tests
|
68
|
+
|
69
|
+
Require this before defining `ApplicationSystemTestCase` (see lib/minispec/rails/system_test.rb):
|
44
70
|
|
45
71
|
```ruby
|
46
72
|
# test/application_system_test_case.rb.
|
47
73
|
require "test_helper"
|
48
|
-
require 'minispec/rails/system_test' # Add this line here.
|
74
|
+
require 'minispec/rails/system_test' # <- Add this line here.
|
49
75
|
|
50
76
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
51
77
|
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
52
78
|
end
|
53
79
|
```
|
54
80
|
|
55
|
-
### Spec Types
|
56
|
-
|
57
|
-
* `describe` any AbstractController::Base subclass, the test will be a subclass of ActionDispatch::IntegrationTest.
|
58
|
-
* `describe` any ActiveJob::Base subclass, the test will be a subclass of ActiveJob::TestCase.
|
59
|
-
* `describe` any ActionMailer::Base subclass, the test will be a subclass of ActiveJob::TestCase.
|
60
|
-
* `describe` any String, the test will be a subclass of ActionDispatch::SystemTestCase.
|
61
|
-
* `describe` anything else, the test will be a subclass of ActiveSupport::TestCase.
|
62
|
-
|
63
|
-
See the [example rails app](https://github.com/ordinaryzelig/minispec-rails-example).
|
64
|
-
|
65
81
|
## TODO
|
66
82
|
|
67
83
|
* Ask Rails to add `run_load_hooks` for ActionDispatch::SystemTestCase so we can lazy load like the others.
|
68
|
-
* Custom file types? I like file types like `spec/models/my_model.spec.rb`.
|
84
|
+
* Custom file types? I like file types with extensions like `spec/models/my_model.spec.rb`.
|
69
85
|
|
70
86
|
## License
|
71
87
|
|
data/lib/minispec/rails.rb
CHANGED
@@ -14,7 +14,8 @@ module Minispec
|
|
14
14
|
|
15
15
|
ActiveSupport.on_load(:action_dispatch_integration_test) do
|
16
16
|
Minitest::Spec.register_spec_type(ActionDispatch::IntegrationTest) do |desc|
|
17
|
-
desc.is_a?(Class) && desc < AbstractController::Base
|
17
|
+
(desc.is_a?(Class) && desc < AbstractController::Base) ||
|
18
|
+
(desc.to_s =~ /integration$/i)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -7,7 +7,7 @@ ActionDispatch::SystemTestCase.extend(
|
|
7
7
|
super
|
8
8
|
unless Minitest::Spec::TYPES.find { |matcher, type| type == ApplicationSystemTestCase }
|
9
9
|
Minitest::Spec.register_spec_type(ApplicationSystemTestCase) do |desc|
|
10
|
-
desc.
|
10
|
+
desc.to_s =~ /system$/i
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minispec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Ning
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|