rspec-the 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +51 -10
- data/rspec-the.gemspec +1 -1
- data/spec/rspec/the_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -0
- data/spec/{counter.rb → support/counter.rb} +0 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11f700928861f020121522ef2d06c19a4838ea48
|
4
|
+
data.tar.gz: c70a8ac731bbc6d3a34c0adcda2251bed1ee1c3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115c7ebb055c9aa4b065f36cb9f0a5dcdd8e908919ad785d47b317d7ce521cfea306e939099028486c5899351596bb51de7f191f5c6918d4b2d2399ecf226ad7
|
7
|
+
data.tar.gz: d3079a61ca59b1e2c3ab9cdff215fef91570736fff2526fdd46e4df342a5eb34a1d41dbee5fddab2c7f76209d764273db663d6e6290277bf41ae9016e2af4a91
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Easily make assertions about the contents of your `let` blocks
|
4
4
|
|
5
|
+
[![Travis Status](https://img.shields.io/travis/jamesottaway/rspec-the.svg)](https://travis-ci.org/jamesottaway/rspec-the)
|
6
|
+
[![RubyGems Version](https://img.shields.io/gem/v/rspec-the.svg)](https://rubygems.org/gems/rspec-the)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -12,25 +15,63 @@ gem 'rspec-the'
|
|
12
15
|
|
13
16
|
And then execute:
|
14
17
|
|
15
|
-
|
18
|
+
```
|
19
|
+
bundle install
|
20
|
+
```
|
16
21
|
|
17
22
|
Or install it yourself as:
|
18
23
|
|
19
|
-
|
24
|
+
```
|
25
|
+
gem install rspec-the
|
26
|
+
```
|
20
27
|
|
21
28
|
## Usage
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
Using `rspec-its` to test your given `subject` works for simple method invocations, but requires excessive nesting in more complex scenarios.
|
31
|
+
|
32
|
+
``` ruby
|
33
|
+
describe Array do
|
34
|
+
let(:array) { [1, 2, 3, 4, 5] }
|
35
|
+
subject { array }
|
36
|
+
|
37
|
+
its(:count) { is_expected.to eq 5 }
|
38
|
+
its(:first) { is_expected.to eq 1 }
|
39
|
+
|
40
|
+
describe 'select #even?' do
|
41
|
+
subject { array.select(&:even?) }
|
42
|
+
it { is_expected.to eq [2, 4] }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'select #odd?' do
|
46
|
+
subject { array.select(&:odd?) }
|
47
|
+
it { is_expected.to eq [1, 3, 5] }
|
48
|
+
end
|
27
49
|
end
|
28
50
|
```
|
29
51
|
|
52
|
+
Instead, `rspec-the` allows us use `let` to define many pseudo-`subject` blocks which can easily be tested.
|
53
|
+
|
54
|
+
``` ruby
|
55
|
+
describe Array do
|
56
|
+
subject { [1, 2, 3, 4, 5] }
|
57
|
+
|
58
|
+
its(:count) { is_expected.to eq 5 }
|
59
|
+
its(:first) { is_expected.to eq 1 }
|
60
|
+
|
61
|
+
let(:evens) { subject.select(&:even?) }
|
62
|
+
the(:evens) { is_expected.to eq [2, 4] }
|
63
|
+
|
64
|
+
let(:odds) { subject.select(&:odd?) }
|
65
|
+
the(:odds) { is_expected.to eq [1, 3, 5] }
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
See, isn't that easier?!?
|
70
|
+
|
30
71
|
## Contributing
|
31
72
|
|
32
73
|
1. Fork it ( https://github.com/jamesottaway/rspec-the/fork )
|
33
|
-
2. Create your feature branch (`git checkout -b
|
34
|
-
3. Commit your changes (`git commit
|
35
|
-
4. Push to the branch (`git push
|
36
|
-
5. Create a new Pull Request
|
74
|
+
2. Create your feature branch (`git checkout -b $BRANCH_NAME`)
|
75
|
+
3. Commit your changes (`git commit --all --message $COMMIT_MESSAGE`)
|
76
|
+
4. Push to the branch (`git push $REMOTE $BRANCH_NAME`)
|
77
|
+
5. Create a new Pull Request ( https://github.com/jamesottaway/rspec-the/compare )
|
data/rspec-the.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'rspec-the'
|
7
|
-
spec.version = '0.0
|
7
|
+
spec.version = '1.0.0'
|
8
8
|
spec.authors = ['James Ottaway']
|
9
9
|
spec.email = ['hello@james.ottaway.io']
|
10
10
|
spec.summary = 'Easily make assertions about the contents of your `let` blocks'
|
data/spec/rspec/the_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rspec/the'
|
2
|
-
require '
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
describe RSpec::The do
|
5
5
|
describe '#the' do
|
@@ -14,7 +14,7 @@ describe RSpec::The do
|
|
14
14
|
context '#are_expected' do
|
15
15
|
let(:counter) { Counter.new }
|
16
16
|
before { expect(counter.next).to eq 1 }
|
17
|
-
let(:nexts) { 5.times.inject
|
17
|
+
let(:nexts) { 5.times.inject [] { |acc| acc << counter.next } }
|
18
18
|
the(:nexts) { are_expected.to eq [2, 3, 4, 5, 6] }
|
19
19
|
after { expect(counter.next).to eq 7 }
|
20
20
|
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-the
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Ottaway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".ruby-version"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
79
80
|
- Gemfile.lock
|
80
81
|
- LICENSE.txt
|
@@ -82,8 +83,9 @@ files:
|
|
82
83
|
- Rakefile
|
83
84
|
- lib/rspec/the.rb
|
84
85
|
- rspec-the.gemspec
|
85
|
-
- spec/counter.rb
|
86
86
|
- spec/rspec/the_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/support/counter.rb
|
87
89
|
homepage: https://github.com/jamesottaway/rspec-the
|
88
90
|
licenses:
|
89
91
|
- MIT
|
@@ -109,5 +111,6 @@ signing_key:
|
|
109
111
|
specification_version: 4
|
110
112
|
summary: Easily make assertions about the contents of your `let` blocks
|
111
113
|
test_files:
|
112
|
-
- spec/counter.rb
|
113
114
|
- spec/rspec/the_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/support/counter.rb
|