rspec_restful 0.1.0 → 0.1.1

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: eb1ea0dce5a1c6cde7c68e6eb1ef0fc34159febe
4
- data.tar.gz: 08b5c56d6ee71a999aabda62259052954147a610
3
+ metadata.gz: fef645ae88bdac730685e9e61f6c13b9640f9185
4
+ data.tar.gz: 5b45b135d9c0c2dd4aeb34b8820ad177f79e0255
5
5
  SHA512:
6
- metadata.gz: cc74470693516cbacd7db795ce6e57ecd5a2c8c09f303f1c036d3b521a5d9ea67092f3b5adfac3ba8dce0e0708be99002dcb9f0b4c04aac3af0bec5c5b66dbca
7
- data.tar.gz: 42c910e87a5a4c16f21dd5765f5b8111d2ba2273ff3fbd3254fe08de8f558b0ee1940d14f02b54cb3fc97ba68abc30e60ac22a277b48c73daf161c5d160bd995
6
+ metadata.gz: 0d713272d34456154125c51994dc59f8b81ca5107781801592986f1b7ce492de51c5b984a6544abfb5337b33fe633ed68eda329bc77bd66be0f62ff7c07660a6
7
+ data.tar.gz: 124111d15df124759977f40d4a5038507b6b53c9ee85edf6bea118e5a3acd9f331426faec77bfbe287d9c3e50b481a77595029e887c41461ab4bfac41ae50282
data/README.md CHANGED
@@ -44,13 +44,14 @@ RSpec.describe WidgetsController, type: :controller do
44
44
  describe_restful_new_action
45
45
  describe_restful_create_action(Widget, url_method: :widgets_path)
46
46
  describe_restful_edit_action(:widget)
47
- describe_restful_update_action(Widget, url_method: :widgets_path)
47
+ describe_restful_update_action(Widget, url_method: :widgets_path, object_method: :widget)
48
48
  describe_restful_destroy_action(Widget, url_method: :widgets_path)
49
49
  end
50
50
  ```
51
51
 
52
52
  This expects that a FactoryGirl factory named `:widget` is available to create
53
- objects.
53
+ objects, however if an `:object_method` option is passed, this will be called
54
+ instead.
54
55
 
55
56
  ## Development
56
57
 
@@ -89,9 +89,13 @@ module RspecRestful
89
89
  end
90
90
  end
91
91
 
92
- def describe_restful_edit_action(resource)
92
+ def describe_restful_edit_action(resource, options = {})
93
93
  describe 'GET :edit' do
94
- let(:item) { create(resource) }
94
+ if options[:object_method].present?
95
+ let(:item) { self.send(options[:object_method]) }
96
+ else
97
+ let(:item) { create(resource) }
98
+ end
95
99
 
96
100
  before do
97
101
  get :edit, id: item.id
@@ -111,7 +115,11 @@ module RspecRestful
111
115
  name = name.to_sym
112
116
 
113
117
  describe 'on PUT to :update' do
114
- before { @item = create(name) }
118
+ if options[:object_method].present?
119
+ before { @item = self.send(options[:object_method]) }
120
+ else
121
+ before { @item = create(name) }
122
+ end
115
123
 
116
124
  context 'with valid data' do
117
125
  before do
@@ -145,18 +153,19 @@ module RspecRestful
145
153
  name = name.to_sym
146
154
 
147
155
  describe 'on DELETE to :destroy' do
148
- before do
149
- @item = create(name)
150
- delete :destroy, id: @item.id
156
+ if options[:object_method].present?
157
+ before { @item = self.send(options[:object_method]) }
158
+ else
159
+ before { @item = create(name) }
151
160
  end
152
161
 
153
162
  it "redirects to #{url_method}" do
163
+ delete :destroy, id: @item.id
154
164
  expect(response).to be_redirect
155
165
  expect(response).to redirect_to(send(url_method))
156
166
  end
157
167
 
158
168
  it "destroys a #{klass.name}" do
159
- @item = create(name)
160
169
  expect do
161
170
  delete :destroy, id: @item.id
162
171
  end.to change(klass, :count).by(-1)
@@ -1,3 +1,3 @@
1
1
  module RspecRestful
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_restful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Langenauer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,9 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.4.6
82
+ rubygems_version: 2.4.7
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: RSpec helpers to easily test RESTful controllers
86
86
  test_files: []
87
- has_rdoc: