formulaic 0.0.5 → 0.0.6

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: c46c19db04768620d83729bcca395bbb0d7c0393
4
- data.tar.gz: 4ed3813d96483d9abed3ea6139ece471a9b7006f
3
+ metadata.gz: 2bddf9295abcf67c8f465f0cf868233fec7998cc
4
+ data.tar.gz: a5b5c6bf0604458bfac05486835a8a53e02547b3
5
5
  SHA512:
6
- metadata.gz: 4ba299637c54771ff12994896dad3a5811bc48c7721b538e5903028c853e05767a36f7faf8ebc1342f23d65ec38b9c834fc8ecc54f56d30463a91f827767f172
7
- data.tar.gz: ea6e0f9f31e191d92830cfbbebf67961842108d8a03bb83236ce6d0d544db6077543b3771e9c9a84f3877810ef0f12384a559e884a5b62d72ae7f0ea25b39150
6
+ metadata.gz: 1b37abbe416ec93dc90fb814ccef4df969a087d82c33baa247b92b499719cf325baf481f80aabfd11c0f06a47535c64ad64ca1e8ba3f363dfe901031cba3e587
7
+ data.tar.gz: 78d46b03a053535978e7ec32c9ce9eb437f06b4bbafeccb07bec18c01043c60c03352ba16cce0c4c6e99b5fb749bbc0f3f46655f170c71cf23a3ccb4e501e0ef
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - "2.0.0"
3
+ - "2.1.1"
4
+ - "2.1-head"
5
+ notifications:
6
+ email: false
data/NEWS.md ADDED
@@ -0,0 +1,5 @@
1
+ v0.0.6
2
+ ------
3
+
4
+ * Treat integers as String inputs (which allows them to fill
5
+ `input[type="numeric"]`. (f7a8353)
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Formulaic
2
2
 
3
+ [![Build Status](https://travis-ci.org/thoughtbot/formulaic.png?branch=master)](https://travis-ci.org/thoughtbot/formulaic)
4
+ [![Code Climate](https://codeclimate.com/github/thoughtbot/formulaic.png)](https://codeclimate.com/github/thoughtbot/formulaic)
5
+
3
6
  Remove the tedium of formulaic form filling with Capybara.
4
7
 
5
8
  Formulaic allows you to specify a hash of attributes to be input rather than
@@ -12,7 +15,7 @@ feature 'New user registration' do
12
15
  scenario 'successfull sign up' do
13
16
  visit sign_in_path
14
17
 
15
- fill_form(:user, { name: 'Caleb', email: 'caleb@thoughtbot.com', 'Terms of Service': true })
18
+ fill_form(:user, { name: 'Caleb', email: 'caleb@thoughtbot.com', 'Terms of Service' => true })
16
19
  click_on submit(:user)
17
20
 
18
21
  expect(page).to have_content t('user.create.success')
@@ -76,6 +79,17 @@ RSpec.configure do |config|
76
79
  end
77
80
  ```
78
81
 
82
+ ### Integration with Minitest or Test::Unit:
83
+
84
+ ```ruby
85
+ # test/test_helper.rb
86
+
87
+ class ActionDispatch::IntegrationTest
88
+ include Capybara::DSL
89
+ include Formulaic::Dsl
90
+ end
91
+ ```
92
+
79
93
  ### Integration with [FactoryGirl](https://github.com/thoughtbot/factory_girl)
80
94
 
81
95
  ```ruby
@@ -94,17 +108,29 @@ def sign_up_attributes
94
108
  end
95
109
  ```
96
110
 
111
+ ## Assumptions
112
+
113
+ Formulaic relies pretty heavily on the assumption that your application is using
114
+ translations for SimpleForm and input helpers, using the
115
+ `simple_form.labels.<model>.<attribute>` and `helpers.submit.<model>.<action>`
116
+ conventions.
117
+
118
+ You can still use Formulaic by using strings as keys instead of symbols, which
119
+ it knows to pass directly to `fill_in` rather than trying to find a translation.
120
+ You’ll need to find submit buttons yourself since `submit` is a thin wrapper
121
+ around `I18n.t`.
122
+
97
123
  ## Known Limitations
98
124
 
99
125
  * Formulaic currently supports the following mappings from the `#class` of the
100
126
  attribute values to Capybara method calls:
101
127
 
102
- | Classes | Formulaic’s action |
103
- | --------------------------------------|-------------------------------|
104
- | `String` | `fill_in` |
105
- | `Date`, `ActiveSupport::TimeWithZone` | `select` year, month, and day |
106
- | `TrueClass` | `check` |
107
- | `FalseClass` | `uncheck` |
128
+ | Classes | Formulaic’s action |
129
+ | --------------------------------------|----------------------------------|
130
+ | `String` | `fill_in`, `choose`, or `select` |
131
+ | `Date`, `ActiveSupport::TimeWithZone` | `select` year, month, and day |
132
+ | `TrueClass` | `check` |
133
+ | `FalseClass` | `uncheck` |
108
134
  | `Array` | `check` each array member, which should all be strings |
109
135
 
110
136
  * Formulaic is currently tied to `simple_form` translations and field structure.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -7,6 +7,7 @@ module Formulaic
7
7
  Date => Formulaic::Inputs::DateInput,
8
8
  Array => Formulaic::Inputs::ArrayInput,
9
9
  String => Formulaic::Inputs::StringInput,
10
+ Fixnum => Formulaic::Inputs::StringInput,
10
11
  TrueClass => Formulaic::Inputs::BooleanInput,
11
12
  FalseClass => Formulaic::Inputs::BooleanInput,
12
13
  }.freeze
@@ -1,3 +1,3 @@
1
1
  module Formulaic
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -78,6 +78,15 @@ describe 'Fill in user form' do
78
78
  expect(input(:user, :terms_of_service)).to be_checked
79
79
  end
80
80
 
81
+ it 'finds and fills in a number field' do
82
+ visit 'user_form'
83
+ form = Formulaic::Form.new(:user, age: 10)
84
+
85
+ form.fill
86
+
87
+ expect(input(:user, :age).value).to eq '10'
88
+ end
89
+
81
90
  it 'selects a string if there is no input' do
82
91
  visit 'user_form'
83
92
  form = Formulaic::Form.new(:user, awesome: 'Yes')
@@ -3,6 +3,7 @@
3
3
  <div class="input string required user_name"><label class="string required" for="user_name"><abbr title="required">*</abbr> Display name</label><input class="string required" id="user_name" maxlength="255" name="user[name]" size="50" type="text"></div>
4
4
  <div class="input email required user_email"><label class="email required" for="user_email"><abbr title="required">*</abbr> Email</label><input class="string email required" id="user_email" maxlength="255" name="user[email]" size="50" type="email"></div>
5
5
  <div class="input tel required user_phone"><label class="tel required" for="user_phone"><abbr title="required">*</abbr> Phone Number</label><input class="string phone required" id="user_phone" maxlength="255" name="user[phone]" size="50" type="tel"></div>
6
+ <div class="input integer required user_age"><label class="integer required" for="user_age"><abbr title="required">*</abbr> Age</label><input class="numeric integer age required" id="user_age" maxlength="255" name="user[age]" size="50" type="number"></div>
6
7
  <div class="input url required user_url"><label class="tel required" for="user_url"><abbr title="required">*</abbr> Website</label><input class="string url required" id="user_url" maxlength="255" name="user[url]" size="50" type="url"></div>
7
8
  <div class="input password optional user_password"><label class="password optional" for="user_password">Password</label><input class="password optional" id="user_password" name="user[password]" size="50" type="password"></div>
8
9
  <div class="input select required user_awesome">
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,7 @@ module SpecHelper
22
22
  simple_form:
23
23
  labels:
24
24
  user:
25
+ age: Age
25
26
  name: Display name
26
27
  email: Email
27
28
  phone: Phone Number
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.0.5
4
+ version: 0.0.6
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-02-26 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -121,9 +121,11 @@ files:
121
121
  - ".gitignore"
122
122
  - ".ruby-gemset"
123
123
  - ".ruby-version"
124
+ - ".travis.yml"
124
125
  - CONTRIBUTING.md
125
126
  - Gemfile
126
127
  - LICENSE
128
+ - NEWS.md
127
129
  - README.md
128
130
  - Rakefile
129
131
  - formulaic.gemspec