formulaic 0.1.2 → 0.1.3
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 +4 -4
- data/.ruby-version +1 -1
- data/README.md +4 -4
- data/lib/formulaic/label.rb +1 -1
- data/lib/formulaic/version.rb +1 -1
- data/spec/formulaic/label_spec.rb +18 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f3bb41653f105138a4e6b8000926309388b3fc1
|
4
|
+
data.tar.gz: a6186759dd0fa86fe0b3c728ee9a9b90fa2d4192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38fbdee254c72c6ea83472da44b41a2fb205d9f7433cb6c4df712362c12789ca82ea2c8326c0114499ad500c7474f84e9ceffcafa0a8150bd8ec35f3870bef5e
|
7
|
+
data.tar.gz: a27ae91dba89c3e785e8fdbc335702278dd7504b66e9761587eb56435c437646d5a70f6c086220326026a6d75837c8821e984e33c1e23e51520fced82b42eeac
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ end
|
|
27
27
|
### `fill_form`
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
fill_form(model_name,
|
30
|
+
fill_form(model_name, :new, attributes)
|
31
31
|
```
|
32
32
|
|
33
33
|
`fill_form` provides an interface to completely filling out a form. Provide the
|
@@ -51,7 +51,7 @@ as it could be useful.
|
|
51
51
|
### `submit`
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
submit(model_name,
|
54
|
+
submit(model_name, :create)
|
55
55
|
```
|
56
56
|
|
57
57
|
`submit` functions like [`input`](#input), but finds the translation for the
|
@@ -60,7 +60,7 @@ to [`fill_form`](#fill\_form). Typically, the return value of `submit` will be
|
|
60
60
|
passed directly to Capybara’s `click_on` method.
|
61
61
|
|
62
62
|
If you are submitting a form that is not for the `create` action, you may need
|
63
|
-
to pass the
|
63
|
+
to pass the action:
|
64
64
|
|
65
65
|
```ruby
|
66
66
|
submit(:user, :update)
|
@@ -72,7 +72,7 @@ The `model_name` and `action` should match up to the
|
|
72
72
|
### `fill_form_and_submit`
|
73
73
|
|
74
74
|
```ruby
|
75
|
-
fill_form_and_submit(:user,
|
75
|
+
fill_form_and_submit(:user, :new, attributes)
|
76
76
|
```
|
77
77
|
|
78
78
|
Effectively a `fill_form` followed by `click_on submit`, but smart enough to
|
data/lib/formulaic/label.rb
CHANGED
data/lib/formulaic/version.rb
CHANGED
@@ -1,27 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Formulaic::Label do
|
4
|
-
|
5
|
-
|
6
|
-
allow(User).to receive(:human_attribute_name).and_return("Human Attribute Name")
|
4
|
+
it "returns the string if there are no translations and it can not human_attribute_name the class" do
|
5
|
+
expect(label(nil, "My label")).to eq "My label"
|
7
6
|
end
|
8
7
|
|
9
|
-
it
|
10
|
-
expect(label(
|
8
|
+
it "returns human_attribute_name if available" do
|
9
|
+
expect(label(:user, :first_name)).to eq "First name"
|
11
10
|
end
|
12
11
|
|
13
|
-
it
|
14
|
-
|
12
|
+
it "uses a translation if available" do
|
13
|
+
I18n.backend.store_translations(:en, { simple_form: { labels: { user: { name: "Translated" } } } } )
|
14
|
+
|
15
|
+
expect(label(:user, :name)).to eq("Translated")
|
15
16
|
end
|
16
17
|
|
17
|
-
it
|
18
|
-
|
18
|
+
it "should leave cases alone" do
|
19
|
+
expect(label(:user, "Work URL")).to eq "Work URL"
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
it "uses the attribute when the model is not found" do
|
23
|
+
expect(label(:student, "Course selection")).to eq "Course selection"
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
26
|
+
class User
|
27
|
+
def self.human_attribute_name(attribute)
|
28
|
+
attribute.to_s.humanize
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def label(model_name, attribute, action = :new)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formulaic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.4.3
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Simplify form filling with Capybara
|