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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46041f49475675c4e48824b44f5a4825f1e0a2c6
4
- data.tar.gz: 5ff5c7da932bbad514632342cf19f84a45778b38
3
+ metadata.gz: 2f3bb41653f105138a4e6b8000926309388b3fc1
4
+ data.tar.gz: a6186759dd0fa86fe0b3c728ee9a9b90fa2d4192
5
5
  SHA512:
6
- metadata.gz: 07e7b143f6ef68deedac88596f213d42dee31ce1b84079dc1855ee33c8eb554babae2742ee3fc65be8f85996c9a8b310bcc628a3385b529ef4fbdc09d53f44d3
7
- data.tar.gz: f0efb3b62c2580f2fcad9618b1d59e77fd2872ce22f7884d0fbd7b283b9e9732f3f4b2ab43d27cfcf934aef0e42133f3c129bf190262124df582144833aa1451
6
+ metadata.gz: 38fbdee254c72c6ea83472da44b41a2fb205d9f7433cb6c4df712362c12789ca82ea2c8326c0114499ad500c7474f84e9ceffcafa0a8150bd8ec35f3870bef5e
7
+ data.tar.gz: a27ae91dba89c3e785e8fdbc335702278dd7504b66e9761587eb56435c437646d5a70f6c086220326026a6d75837c8821e984e33c1e23e51520fced82b42eeac
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
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, action = :new, attributes)
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, action = :create)
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 `action`:
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, action = :new, attributes)
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
@@ -43,7 +43,7 @@ module Formulaic
43
43
  end
44
44
 
45
45
  def class_exists?(class_name)
46
- Object.const_defined?(model_name.to_s.classify)
46
+ Object.const_defined?(class_name.to_s.classify)
47
47
  rescue NameError
48
48
  false
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module Formulaic
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -1,27 +1,32 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Formulaic::Label do
4
- before(:each) do
5
- class_double("User").as_stubbed_const
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 'returns the string if there are no translations and it can not human_attribute_name the class' do
10
- expect(label(nil, 'My label')).to eq 'My 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 'returns human_attribute_name if available' do
14
- expect(label(:user, :attribute)).to eq 'Human Attribute Name'
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 'uses a translation if available' do
18
- I18n.backend.store_translations(:en, { simple_form: { labels: { user: { name: 'Translated' } } } } )
18
+ it "should leave cases alone" do
19
+ expect(label(:user, "Work URL")).to eq "Work URL"
20
+ end
19
21
 
20
- expect(label(:user, :name)).to eq('Translated')
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
- it 'should leave cases alone' do
24
- expect(label(:user, 'Work URL')).to eq 'Work URL'
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.2
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-09-26 00:00:00.000000000 Z
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.2.2
175
+ rubygems_version: 2.4.3
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Simplify form filling with Capybara