rspec-advanced_subject 0.0.2.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e98db86f51ac4f784eef4d14e18fd0452adeeee2
4
- data.tar.gz: c658fb02bc1b28a986b7d25d20bcb64dcd286d28
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjZjNDMyZmRjMWFhZjU3YmIwODVlZDNkZmViMDg5ZGJjZDQyNDcxMg==
5
+ data.tar.gz: !binary |-
6
+ ZWViNDZhNGQ2YTM0ZDY1ZDJiYzMxYjA0MGQxNmMyYWNhOTdiMzUzNA==
5
7
  SHA512:
6
- metadata.gz: b859a3376f312d18f9fc5f2cc5477b64cbad00a7e9210f36233928080af8f2b40e8acfb7cf2b130cae20059d1c961b1cf720606ee878e391715496eb039eaef2
7
- data.tar.gz: 90681ff5a62c75f81ee61d6f82c1dca575193b4a984d821e8690ab5addcd5e592401b9d0e0fe65a7217e1e4202a0a2d1e3ef7abef0a06469b3ee7a387702f6d0
8
+ metadata.gz: !binary |-
9
+ OWJjYjMzZTE1NDAzN2ZkZjNlY2JjY2NmNDFlYTNjMjc0MzQwMmEwZWM1Yjc2
10
+ MmNhMTAyMjViZDkyZWU1NTA0YTI1YmZjZDFmNzlkZTI4ODViNWI5NWU5YTlk
11
+ ODVkZjJkYTQ3NDc3ZjJlYzYyNjkyNDVhNjQ4N2YxZGU2ODI1MTU=
12
+ data.tar.gz: !binary |-
13
+ NGQ3MzNhYTExMjUxNTZkMmUyYmVmMDc1MzdmMDc2MDhhZmU3M2FlNGRkNDIw
14
+ MmE4YWY4ZGFmYzk3MTllNmQ4ZWY3ZGExZjE1YzJiMjk5MmFiN2YxYjdjMzY0
15
+ YjE4ZjNmNjkwNWNiYTJlNDU3MDgyZWI0YmI1OTdjYjNlZTUyYTY=
@@ -29,12 +29,8 @@ module RSpec::AdvancedSubject::ClassMethodExampleGroup
29
29
  end
30
30
 
31
31
  def self.set_subject_method_name(metadata)
32
- case d = metadata[:example_group][:description_args].first
33
- when is_a?(Class)
34
- metadata[:subject_method_name] = d
35
- when class_regex
36
- metadata[:subject_method_name] = d.gsub class_regex, ""
37
- end
32
+ d = metadata[:description_args].first
33
+ metadata[:subject_method_name] = d.gsub class_regex, ""
38
34
  end
39
35
 
40
36
  def self.class_regex
@@ -15,8 +15,11 @@ module RSpec::AdvancedSubject::InstanceMethodExampleGroup
15
15
  set_subject_method_name(base.metadata)
16
16
 
17
17
  base.subject do
18
- raise NotImplementedError if metadata[:with_args].nil?
19
- callee
18
+ if metadata[:with_args].nil?
19
+ super()
20
+ else
21
+ callee
22
+ end
20
23
  end
21
24
  end
22
25
 
@@ -29,12 +32,8 @@ module RSpec::AdvancedSubject::InstanceMethodExampleGroup
29
32
  end
30
33
 
31
34
  def self.set_subject_method_name(metadata)
32
- case d = metadata[:example_group][:description_args].first
33
- when is_a?(Class)
34
- metadata[:subject_method_name] = d
35
- when instance_regex
36
- metadata[:subject_method_name] = d.gsub instance_regex, ""
37
- end
35
+ d = metadata[:description_args].first
36
+ metadata[:subject_method_name] = d.gsub instance_regex, ""
38
37
  end
39
38
 
40
39
  def self.instance_regex
@@ -8,6 +8,7 @@ class RSpec::Core::ExampleGroup
8
8
  end
9
9
 
10
10
  define_example_group_method :describe, advanced_subject: true
11
+ define_example_group_method :calling, advanced_subject: true, with_args: []
11
12
  end
12
13
 
13
14
  module RSpec::AdvancedSubject::Core
@@ -11,7 +11,7 @@ class InstanceMock
11
11
  end
12
12
 
13
13
  describe InstanceMock do
14
- describe "#single_argument" do
14
+ describe "#single_argument", "derp" do
15
15
  when_passed 5 do
16
16
  it { is_expected.to eq(5) }
17
17
  end
@@ -26,13 +26,13 @@ describe InstanceMock do
26
26
  end
27
27
 
28
28
  context "when using default subject without passing arguments" do
29
- it "raises NotImplementedError" do
30
- expect{subject.single_argument(5)}.to raise_error(NotImplementedError)
29
+ it "returns the default rspec subject" do
30
+ expect(subject.single_argument(5)).to eq(5)
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
- describe "#multiple_arguments" do
35
+ shared_examples "for #multiple_arguments" do
36
36
  when_passed do
37
37
  it { is_expected.to eq([]) }
38
38
  end
@@ -50,4 +50,13 @@ describe InstanceMock do
50
50
  it { is_expected.to eq([5]) }
51
51
  end
52
52
  end
53
+
54
+ describe "#multiple_arguments" do
55
+ include_examples "for #multiple_arguments"
56
+ end
57
+
58
+ calling "#multiple_arguments" do
59
+ it { is_expected.to eq([]) }
60
+ include_examples "for #multiple_arguments"
61
+ end
53
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-advanced_subject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Stannard
@@ -9,52 +9,41 @@ authors:
9
9
  - Kelly Stannard
10
10
  - Kelly Stannard
11
11
  - Kelly Stannard
12
+ - Kelly Stannard
13
+ - Kelly Stannard
14
+ - Kelly Stannard
15
+ - Kelly Stannard
16
+ - Kelly Stannard
17
+ - Kelly Stannard
12
18
  autorequire:
13
19
  bindir: bin
14
20
  cert_chain: []
15
- date: 2014-07-28 00:00:00.000000000 Z
21
+ date: 2014-12-11 00:00:00.000000000 Z
16
22
  dependencies:
17
23
  - !ruby/object:Gem::Dependency
18
24
  name: rspec
19
25
  requirement: !ruby/object:Gem::Requirement
20
26
  requirements:
21
- - - "~>"
27
+ - - ~>
22
28
  - !ruby/object:Gem::Version
23
29
  version: '3.0'
24
30
  type: :runtime
25
31
  prerelease: false
26
32
  version_requirements: !ruby/object:Gem::Requirement
27
33
  requirements:
28
- - - "~>"
34
+ - - ~>
29
35
  - !ruby/object:Gem::Version
30
36
  version: '3.0'
31
- description: |
32
- advanced_subject attempts to cut out having to explicitly write the subject of your example group when trying to call methods or add arguments to methods. It works by reading the conventional description syntax to determine what the method you are calling is and later you state what you are passing to it.
33
-
34
- Given you have a file advanced_subject_spec.rb.
35
- ```ruby
36
- describe Hash do
37
- when_initialized_with [:a, :b] do
38
- it { should eq({a: :b}) }
39
-
40
- describe '#fetch' do
41
- when_passed :a do
42
- it { should eq(:b) }
43
- end
44
- end
45
- end
46
- end
47
- ```
48
-
49
- When you run `rspec -f d advanced_subject_spec.rb` it will output:
50
- ```
51
- Hash
52
- when initialized with [:a, :b]
53
- should eq {:a => :b}
54
- #fetch
55
- when passed :a
56
- should eq :b
57
- ```
37
+ description: ! "advanced_subject attempts to cut out having to explicitly write the
38
+ subject of your example group when trying to call methods or add arguments to methods.
39
+ It works by reading the conventional description syntax to determine what the method
40
+ you are calling is and later you state what you are passing to it.\n\nGiven you
41
+ have a file advanced_subject_spec.rb.\n```ruby\ndescribe Hash do\n when_initialized_with
42
+ [:a, :b] do\n it { should eq({a: :b}) }\n\n describe '#fetch' do\n when_passed
43
+ :a do\n it { should eq(:b) }\n end\n end\n end\nend\n```\n\nWhen
44
+ you run `rspec -f d advanced_subject_spec.rb` it will output:\n```\nHash\n when
45
+ initialized with [:a, :b]\n should eq {:a => :b}\n #fetch\n when passed :a\n
46
+ \ should eq :b\n```\n"
58
47
  email: kwstannard@gmail.com
59
48
  executables: []
60
49
  extensions: []
@@ -79,17 +68,17 @@ require_paths:
79
68
  - lib
80
69
  required_ruby_version: !ruby/object:Gem::Requirement
81
70
  requirements:
82
- - - ">="
71
+ - - ! '>='
83
72
  - !ruby/object:Gem::Version
84
73
  version: '0'
85
74
  required_rubygems_version: !ruby/object:Gem::Requirement
86
75
  requirements:
87
- - - ">="
76
+ - - ! '>='
88
77
  - !ruby/object:Gem::Version
89
78
  version: '0'
90
79
  requirements: []
91
80
  rubyforge_project:
92
- rubygems_version: 2.2.2
81
+ rubygems_version: 2.4.4
93
82
  signing_key:
94
83
  specification_version: 4
95
84
  summary: adding arguments to the subject