kaminari-rspec 0.14.1.b0 → 0.14.1.b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/README.md +36 -28
- data/kaminari-rspec.gemspec +1 -1
- data/lib/kaminari_rspec/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmJmNDhmY2RjOGZjZGRkODZhYWMyZmE0MjcwOGEyYmJlN2VlZTA5YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2I4YjBmNDg3YTdmMTJiODg0MzYyMzM5MGRiZjBjOTc2OTZlZmQ0Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Mzk3YjY5YjY0MjA5N2Q1MDRiODA1NDY0Zjk4YjVhNDQ4ZmVjY2JkNWNiODVj
|
10
|
+
YjVmNjg0NzJkNzU1NzYwYThkOTE1NmFmZjViYWE5YmNjODdjMTdkZjIyMWFi
|
11
|
+
ZGI0MDcyNzMwM2ZmZTk5ZDRjOTg2YWQxY2Y4ZjYxNGQxNjI4OTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjFlNDRkZWQ1ZTdiMDAyMTEyNTI0MmQ1M2NiZTI3YzBkN2VjM2U3ODE1NTQw
|
14
|
+
ZDNjYWMyYjI2MmY1MjU3OWI5MDJhOTBkY2ZlMWI2Njk3MDc4NTQzYTcxZWVk
|
15
|
+
NWE1YTExMmMyODk5MTQyNzEyZmEzMjkyYWZhODBlMDFlNzg3ZTY=
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,70 +1,78 @@
|
|
1
|
-
Kaminari Rspec Library
|
2
|
-
=========================
|
1
|
+
# Kaminari Rspec Library
|
3
2
|
|
4
3
|
|
5
4
|
|
5
|
+
[](http://badge.fury.io/rb/kaminari-rspec)
|
6
|
+
[](https://travis-ci.org/nessche/kaminari-rspec)
|
7
|
+
|
8
|
+
|
6
9
|
`kaminari-rspec` is a ruby gem that aims at simplifying writing the specs for views where Kaminari is used for pagination
|
7
10
|
|
8
|
-
Installing
|
9
|
-
|
11
|
+
## Installing
|
12
|
+
|
10
13
|
|
11
14
|
Simply install the gem to your system
|
12
15
|
|
13
|
-
|
16
|
+
gem install kaminari-rspec
|
14
17
|
|
15
18
|
or if you are using Bundler add it to your gemspec file and run `bundle install`.
|
16
19
|
|
17
|
-
Gem Versioning
|
18
|
-
--------------
|
20
|
+
## Gem Versioning
|
19
21
|
|
20
22
|
The gem version reflects the kaminari version that is supports. Please notice that this gem is maintained in my spare time
|
21
23
|
so delays occur between the release of a new Kaminari version and the release of a new version of this gem. Feel free
|
22
24
|
to fork this repo and update the version and the code as needed.
|
23
25
|
|
24
|
-
Rendering views with RSpec's render_view
|
25
|
-
----------------------------------------
|
26
|
+
## Rendering views with RSpec's render_view
|
26
27
|
|
27
28
|
If you are rendering the views from your controller spec using render_views AND you are mocking
|
28
29
|
the data returned from the db with something along the lines of
|
29
30
|
|
30
|
-
|
31
|
+
Model.stub_chain(:order, :page, :per).and_return([model_mock])
|
31
32
|
|
32
33
|
you may want to also stub the methods needed by the pagination partials, in order to do that, just
|
33
34
|
add the following to your `spec_helper`
|
34
35
|
|
35
|
-
|
36
|
+
config.include KaminariRspec::TestHelpers, :type => :controller
|
36
37
|
|
37
38
|
and then modify your controller spec to look like
|
38
39
|
|
39
|
-
|
40
|
+
Model.stub_chain(:order, :page, :per).and_return(stub_pagination([model_mock]))
|
40
41
|
|
41
42
|
the stubs will return the values needed to set the pagination as being on the first and only page.
|
42
43
|
|
43
|
-
|
44
|
+
### Pagination options
|
45
|
+
|
46
|
+
If specific pagination values are needed they can be defined using a hash. The following values are supported:
|
47
|
+
|
48
|
+
* `:total_count` : the total number of elements to be paginated. It defaults to `resource.length` if resource is a collection,
|
49
|
+
otherwise to 1
|
50
|
+
* `:per_page` : the amount of elements per page, defaults to 25
|
51
|
+
* `:current_page` : the current page of the pagination. Defaults to 1. Notice that `current_page` is anyway always
|
52
|
+
set such that it respects the values passed in `total_count` and `per_page`, i.e. if you pass a
|
53
|
+
total count of 95 and a per page value of 10, current page will be capped to 10
|
54
|
+
|
55
|
+
As an example
|
44
56
|
|
45
|
-
|
57
|
+
stub_pagination(resource, :total_count => 50, :current_page => 3, :per_page => 10)
|
46
58
|
|
47
|
-
will create the
|
48
|
-
elements per page and page 3 being the current_page.
|
49
|
-
set such that it respects the values passed in `total_count` and `per_page`, i.e. if you pass a
|
50
|
-
total count of 95 and a per page value of 10, current page will be capped to 10
|
59
|
+
will create the pagination links for a total count of 50 elements, with 10
|
60
|
+
elements per page and page 3 being the current_page.
|
51
61
|
|
52
|
-
Detecting mocking framework
|
53
|
-
---------------------------
|
62
|
+
## Detecting mocking framework
|
54
63
|
|
55
64
|
If you are using RSpec >= 2.5.2 there is no need to explicitly pass the mocking framework you
|
56
65
|
are using to the stub_pagination method, as it is automatically detected by the TestHelpers.
|
57
66
|
For earlier versions you are required to explicitly use the same string you would pass to
|
58
67
|
`RSpec.configuration.mock_with` , so the actual method call is
|
59
68
|
|
60
|
-
|
69
|
+
stub_pagination(mocked_result, :mock => :rspec, :total_count => 50, :current_page => 3, :per_page => 10)
|
61
70
|
|
62
|
-
|
63
|
-
--------------
|
71
|
+
### Supported mocking frameworks
|
64
72
|
|
65
|
-
|
66
|
-
* `:per_page` will default to 25
|
67
|
-
* `:current_page` will default to 1
|
68
|
-
* `:total_count` will default to 1 if the object passed as resource is not a collection, otherwise it will
|
69
|
-
invoke get the value from resource.length
|
73
|
+
Currently supported mocking frameworks are:
|
70
74
|
|
75
|
+
* RSpec's built-in doubles
|
76
|
+
* RR (Double Ruby)
|
77
|
+
* Mocha
|
78
|
+
* Flexmock
|
data/kaminari-rspec.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = 'https://github.com/nessche/kaminari-rspec'
|
12
12
|
s.summary = 'A Rspec Helper library for the Kaminari gem'
|
13
13
|
s.description = 'A Rspec Helper library for the Kaminari gem'
|
14
|
-
|
14
|
+
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.1.
|
4
|
+
version: 0.14.1.b1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Sandrini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kaminari
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
|
+
- .travis.yml
|
119
120
|
- Gemfile
|
120
121
|
- License.txt
|
121
122
|
- README.md
|
@@ -135,7 +136,8 @@ files:
|
|
135
136
|
- spec/lib/kaminari_rspec/test_helpers_spec.rb
|
136
137
|
- spec/spec_helper.rb
|
137
138
|
homepage: https://github.com/nessche/kaminari-rspec
|
138
|
-
licenses:
|
139
|
+
licenses:
|
140
|
+
- MIT
|
139
141
|
metadata: {}
|
140
142
|
post_install_message:
|
141
143
|
rdoc_options: []
|