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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7aaaab1b63bd8f5fca9a41b3a4dc201f03c1f3c
4
- data.tar.gz: 7e3bc98ffd9e798daf77dc39e1b7183fdebeb99b
3
+ metadata.gz: 11f700928861f020121522ef2d06c19a4838ea48
4
+ data.tar.gz: c70a8ac731bbc6d3a34c0adcda2251bed1ee1c3e
5
5
  SHA512:
6
- metadata.gz: 196a096f17176604691ccaa399effa79660862389e184a3d91a40081fe7ae97aa37c14ec16bd13330d6ccd364c81f29385bb4ce954dfb8211f0dc4db673e79ca
7
- data.tar.gz: 6bd858e876647236928e084f6018469035e624f4c5a7d4f88dbf9e5bccd169125b5191a2fedc71d67ed479a7e1a3e2f6107656adccc28ffb1438ba347aca1a78
6
+ metadata.gz: 115c7ebb055c9aa4b065f36cb9f0a5dcdd8e908919ad785d47b317d7ce521cfea306e939099028486c5899351596bb51de7f191f5c6918d4b2d2399ecf226ad7
7
+ data.tar.gz: d3079a61ca59b1e2c3ab9cdff215fef91570736fff2526fdd46e4df342a5eb34a1d41dbee5fddab2c7f76209d764273db663d6e6290277bf41ae9016e2af4a91
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ script: bundle exec rspec spec
8
+ sudo: false
9
+ cache: bundler
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-the (0.0.2)
4
+ rspec-the (1.0.0)
5
5
  rspec-core (>= 3.0.0)
6
6
  rspec-expectations (>= 3.0.0)
7
7
 
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
- $ bundle
18
+ ```
19
+ bundle install
20
+ ```
16
21
 
17
22
  Or install it yourself as:
18
23
 
19
- $ gem install rspec-the
24
+ ```
25
+ gem install rspec-the
26
+ ```
20
27
 
21
28
  ## Usage
22
29
 
23
- ```ruby
24
- describe 'something' do
25
- let(:value) { 42 }
26
- the(:value) { is_expected.to eq 42 }
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 my-new-feature`)
34
- 3. Commit your changes (`git commit -am 'Add some feature'`)
35
- 4. Push to the branch (`git push origin my-new-feature`)
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.2'
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'
@@ -1,5 +1,5 @@
1
1
  require 'rspec/the'
2
- require 'counter'
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([]) { |acc| acc << counter.next } }
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
@@ -0,0 +1,5 @@
1
+ Dir.chdir 'spec' do
2
+ Dir.glob('support/**/*.rb').each do |file|
3
+ require file
4
+ end
5
+ end
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.2
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-16 00:00:00.000000000 Z
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