rspec-capybara-simple_form-rails 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b267b756a1c69d62f078678b45984269586c8202
|
4
|
+
data.tar.gz: 195edfffe023544d1f3dbe8c40840c7bc2b1c068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef260fb3c8f36b34fa4549b63523e8093708973b6fe4289229e3596bf66115741dffd39046c32bd4f4239fcb34b80f9b79e844eaeaa05427c119d5a1239fa840
|
7
|
+
data.tar.gz: 427f9b72fb205f3fba9afcb7c1fb1cd60e1478caae2dff1547fe3784371fd9b342032378e48ea175a05196cf1c9e38a481a7d769830fd909200d4bf2d305f91d
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A small rspec extension to verify simple form elements with the help of capybara.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/rspec-capybara-simple_form-rails.png)](http://badge.fury.io/rb/rspec-capybara-simple_form-rails)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -14,24 +16,19 @@ And then execute:
|
|
14
16
|
|
15
17
|
Add the following lines to your spec_helper.rb
|
16
18
|
|
17
|
-
```ruby
|
18
19
|
# load capybara
|
19
20
|
require 'capybara/rspec'
|
20
21
|
require 'rspec/capybara/simple_form'
|
21
|
-
```
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
25
|
In a view spec just use the following matchers
|
26
26
|
|
27
|
-
```ruby
|
28
27
|
have_input_field(model, attribute, options)
|
29
28
|
have_textarea_field(model, attribute, options)
|
30
|
-
```
|
31
29
|
|
32
30
|
The following example illustrates a full example:
|
33
31
|
|
34
|
-
```ruby
|
35
32
|
it "renders the form correct" do
|
36
33
|
|
37
34
|
# assign model
|
@@ -44,7 +41,6 @@ The following example illustrates a full example:
|
|
44
41
|
rendered.should have_input_field(@app, :name, :required => true)
|
45
42
|
rendered.should have_textarea_field(@app, :description, :required => true)
|
46
43
|
end
|
47
|
-
```
|
48
44
|
|
49
45
|
## Contributing
|
50
46
|
|
@@ -1,7 +1,8 @@
|
|
1
1
|
RSpec::Matchers.define :have_field do |model, name, ftype, dtype, options = {}|
|
2
2
|
match do |rendered|
|
3
3
|
# define the field key
|
4
|
-
field_key = "#{model.class.to_s.
|
4
|
+
field_key = "#{model.class.to_s.underscore}_#{name.to_s.underscore}"
|
5
|
+
field_key = field_key.gsub(/\//, '_')
|
5
6
|
|
6
7
|
# build the check string
|
7
8
|
checkstring = "#{dtype}"
|