simple_bootstrap_form 0.0.4 → 0.0.5

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: 1ec18e4dcc4888081e0d602db082eedff9afced8
4
- data.tar.gz: 44da0c8960e49510e754f7b4d7f955d4ad5c3070
3
+ metadata.gz: 65f90240ab99e3a0b46b324b5df95ba49a5dee02
4
+ data.tar.gz: f7ad48aa51d56145cd4087c0aa51bfd5517a30e9
5
5
  SHA512:
6
- metadata.gz: a06e26323f3f4eb7c0e2874c804ac335454228dc209a9641b11923834ca83e7a584d2d09465cf49401253be32b0f0de993e35c49b1c819fb3bc1d065262656c3
7
- data.tar.gz: 22ab8c478c9c90450ef14bc66093b55ad67ebc25fbc7d26d68fc4dc682a98ccdd4e152b09797da2acf791073b2b1fe0193e0e230a34814dbf3de59088ce32687
6
+ metadata.gz: 491c8983cc4ce4884e3899adec4c6b11d71003e4205bfada2f5b4c2d27e0894049aa1649c9fd5c0ea564dc4d40178f7f03f8ab0b22ad144c97c726347b4c8865
7
+ data.tar.gz: 9e6474ea9135856d500457a1bd9d2239a5389b0c6d5221fdaf12021a3c44793ac3465893fb80afaabf8047683b562ac3c3c0a00e2fe9b965e20ace4b4f72658d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.1.5
data/README.md CHANGED
@@ -180,6 +180,12 @@ Generates (spaces added for clarity):
180
180
  4. Push to the branch (`git push origin my-new-feature`)
181
181
  5. Create new Pull Request
182
182
 
183
+ ## Releasing
184
+
185
+ Update lib/simple_bootstrap_form/version.rb, commit & push
186
+ rake build
187
+ rake release
188
+
183
189
  ## TODO
184
190
 
185
191
  * Vertical Form
@@ -46,7 +46,9 @@ module SimpleBootstrapForm
46
46
  end
47
47
 
48
48
  def attr_column_type(attr)
49
- @builder.object.try(:column_for_attribute, attr).try(:type) || :string
49
+ ActiveSupport::Deprecation.silence do
50
+ @builder.object.try(:column_for_attribute, attr).try(:type) || :string
51
+ end
50
52
  end
51
53
 
52
54
  def string_field_class_prefix_based_on_column_name(attr)
@@ -1,3 +1,3 @@
1
1
  module SimpleBootstrapForm
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec-rails", ">= 3.0.0.beta1"
23
+ spec.add_development_dependency "rspec-rails", ">= 3.0.0"
24
24
  spec.add_development_dependency "sqlite3"
25
25
  spec.add_development_dependency "nokogiri" # used by has_element matcher
26
26
  spec.add_runtime_dependency "rails", ">= 4"
@@ -20,7 +20,7 @@ Dummy::Application.configure do
20
20
  # config.action_dispatch.rack_cache = true
21
21
 
22
22
  # Disable Rails's static asset server (Apache or nginx will already do this).
23
- config.serve_static_assets = false
23
+ config.serve_static_files = false
24
24
 
25
25
  # Compress JavaScripts and CSS.
26
26
  config.assets.js_compressor = :uglifier
@@ -13,7 +13,7 @@ Dummy::Application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = "public, max-age=3600"
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -30,7 +30,7 @@ describe "have_element RSpec matcher" do
30
30
  it "should have an appropriate error message for should" do
31
31
  matcher = have_element("input").with_only_classes('bar')
32
32
  expect(matcher.matches? subject).to eq false
33
- expect(matcher.failure_message_for_should).to eq(
33
+ expect(matcher.failure_message).to eq(
34
34
  %Q{expected #{subject} to have classes "bar" but it has classes "bar baz"}
35
35
  )
36
36
  end
@@ -38,7 +38,7 @@ describe "have_element RSpec matcher" do
38
38
  it "should have an appropriate error message for should not" do
39
39
  matcher = have_element("input").with_only_classes('bar baz')
40
40
  expect(matcher.matches? subject).to eq true
41
- expect(matcher.failure_message_for_should_not).to eq(
41
+ expect(matcher.failure_message_when_negated).to eq(
42
42
  %Q{expected #{subject} not to have classes "bar baz" but it has classes "bar baz"}
43
43
  )
44
44
  end
@@ -62,7 +62,7 @@ describe "have_element RSpec matcher" do
62
62
  .with_placeholder('Attr One')
63
63
 
64
64
  expect(matcher.matches? subject).to eq false
65
- expect(matcher.failure_message_for_should).to eq(
65
+ expect(matcher.failure_message).to eq(
66
66
  %Q{expected #{subject} to have classes "bad class list" but it has classes "bar baz"}
67
67
  )
68
68
  end
@@ -91,7 +91,7 @@ describe "have_element RSpec matcher" do
91
91
  it "should have an appropriate error message for should" do
92
92
  matcher = have_element("div").with_id('foo').with_content('Bad Content')
93
93
  expect(matcher.matches? subject).to eq false
94
- expect(matcher.failure_message_for_should).to eq(
94
+ expect(matcher.failure_message).to eq(
95
95
  %Q{expected #{inspected_subject} to } +
96
96
  %Q{have content "Bad Content" but it has content "Some Content"}
97
97
  )
@@ -100,7 +100,7 @@ describe "have_element RSpec matcher" do
100
100
  it "should have an appropriate error message for should not" do
101
101
  matcher = have_element("div").with_id('foo').with_content('Some Content')
102
102
  expect(matcher.matches? subject).to eq true
103
- expect(matcher.failure_message_for_should_not).to eq(
103
+ expect(matcher.failure_message_when_negated).to eq(
104
104
  %Q{expected #{inspected_subject} not to } +
105
105
  %Q{have content "Some Content" but it has content "Some Content"}
106
106
  )
@@ -111,7 +111,7 @@ describe "have_element RSpec matcher" do
111
111
  .with_only_classes('bar')
112
112
  .with_content('Bad Content')
113
113
  expect(matcher.matches? subject).to eq false
114
- expect(matcher.failure_message_for_should).to eq(
114
+ expect(matcher.failure_message).to eq(
115
115
  %Q{expected #{inspected_subject} to } +
116
116
  %Q{have classes "bar" but it has classes "c1 c2"} +
117
117
  %Q{ and have content "Bad Content" but it has content "Some Content"}
@@ -51,7 +51,7 @@ describe SimpleBootstrapForm::HorizontalForm::Fields::BaseField do
51
51
  <div class="form-group custom-group-class">
52
52
  <label class="col-xs-4 control-label" for="model1_attr1">Custom Label</label>
53
53
  <div class="col-xs-6">
54
- <input class="form-control" id="model1_attr1" name="model1[attr1]" placeholder="Custom Placeholder" type="text" />
54
+ <input placeholder="Custom Placeholder" class="form-control" type="text" name="model1[attr1]" id="model1_attr1" />
55
55
  </div>
56
56
  </div>
57
57
  HTML
@@ -40,7 +40,7 @@ describe SimpleBootstrapForm::HorizontalForm::Fields::SelectField do
40
40
  <div class="form-group model1_attr1_group">
41
41
  <label class="col-sm-3 control-label" for="model1_attr1">Attr1</label>
42
42
  <div class="col-sm-6">
43
- <select class="form-control" id="model1_attr1" name="model1[attr1]">
43
+ <select class="form-control" name="model1[attr1]" id="model1_attr1">
44
44
  <option value="1">1</option>
45
45
  <option value="3">3</option>
46
46
  <option selected="selected" value="5">5</option>
@@ -351,78 +351,65 @@ describe SimpleBootstrapForm, type: :helper do
351
351
  Model3.new
352
352
  end
353
353
 
354
- let(:horizontal_form_output) {
355
- # Original copy from getbootstrap.com
356
- #<form class="form-horizontal" role="form">
357
- # <div class="form-group">
358
- # <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
359
- # <div class="col-sm-10">
360
- # <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
361
- # </div>
362
- # </div>
363
- # <div class="form-group">
364
- # <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
365
- # <div class="col-sm-10">
366
- # <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
367
- # </div>
368
- # </div>
369
- # <div class="form-group">
370
- # <div class="col-sm-offset-2 col-sm-10">
371
- # <div class="checkbox">
372
- # <label>
373
- # <input type="checkbox"> Remember me
374
- # </label>
375
- # </div>
376
- # </div>
377
- # </div>
378
- # <div class="form-group">
379
- # <div class="col-sm-offset-2 col-sm-10">
380
- # <button type="submit" class="btn btn-default">Sign in</button>
381
- # </div>
382
- # </div>
383
- #</form>
384
-
385
- # Railsified version
386
- # <form>
387
- # add accept-charset, action, id, method, model-specific class
388
- # <label>
389
- # changed for= to model_field
390
- # <input>
391
- # reorder input attributes to match Rails' order
392
- # add name=
393
- <<-HORIZONTAL_FORM
394
- <form accept-charset="UTF-8" action="/foo" class="new_model3 form-horizontal" id="new_model3" method="post" role="form">
395
- <div style=\"margin:0;padding:0;display:inline\">
396
- <input name="utf8" type="hidden" value="&#x2713;" />
397
- </div>
398
- <div class="form-group">
399
- <label class="col-sm-2 control-label" for="model3_inputEmail3">Email</label>
400
- <div class="col-sm-10">
401
- <input class="form-control" id="model3_inputEmail3" name="model3[inputEmail3]" placeholder="Email" type="email" />
402
- </div>
403
- </div>
404
- <div class="form-group">
405
- <label class="col-sm-2 control-label" for="model3_inputPassword3">Password</label>
406
- <div class="col-sm-10">
407
- <input class="form-control" id="model3_inputPassword3" name="model3[inputPassword3]" placeholder="Password" type="password" />
408
- </div>
409
- </div>
410
- <div class="form-group">
411
- <div class="col-sm-offset-2 col-sm-10">
412
- <div class="checkbox">
413
- <label>
414
- <input type="checkbox"> Remember me
415
- </label>
416
- </div>
417
- </div>
418
- </div>
419
- <div class="form-group">
420
- <div class="col-sm-offset-2 col-sm-10">
421
- <button type="submit" class="btn btn-default">Sign in</button>
422
- </div>
423
- </div>
424
- </form>
425
- HORIZONTAL_FORM
354
+ # Original copy from getbootstrap.com
355
+ #<form class="form-horizontal" role="form">
356
+ # <div class="form-group">
357
+ # <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
358
+ # <div class="col-sm-10">
359
+ # <input type="email" class="form-control" id="inputEmail3" placeholder="Email">
360
+ # </div>
361
+ # </div>
362
+ # <div class="form-group">
363
+ # <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
364
+ # <div class="col-sm-10">
365
+ # <input type="password" class="form-control" id="inputPassword3" placeholder="Password">
366
+ # </div>
367
+ # </div>
368
+ # <div class="form-group">
369
+ # <div class="col-sm-offset-2 col-sm-10">
370
+ # <div class="checkbox">
371
+ # <label>
372
+ # <input type="checkbox"> Remember me
373
+ # </label>
374
+ # </div>
375
+ # </div>
376
+ # </div>
377
+ # <div class="form-group">
378
+ # <div class="col-sm-offset-2 col-sm-10">
379
+ # <button type="submit" class="btn btn-default">Sign in</button>
380
+ # </div>
381
+ # </div>
382
+ #</form>
383
+
384
+ # The snippets below have been "Railsified" as follows:
385
+ # <form>
386
+ # add accept-charset, action, id, method, model-specific class
387
+ # <label>
388
+ # changed for= to model_field
389
+ # <input>
390
+ # reorder input attributes to match Rails' order
391
+ # add name=
392
+
393
+ let(:email_field_markup) {
394
+ outdent <<-HTML
395
+ <div class="form-group">
396
+ <label class="col-sm-2 control-label" for="model3_inputEmail3">Email</label>
397
+ <div class="col-sm-10">
398
+ <input placeholder="Email" class="form-control" type="email" name="model3[inputEmail3]" id="model3_inputEmail3" />
399
+ </div>
400
+ </div>
401
+ HTML
402
+ }
403
+
404
+ let(:password_field_markup) {
405
+ outdent <<-HTML
406
+ <div class="form-group">
407
+ <label class="col-sm-2 control-label" for="model3_inputPassword3">Password</label>
408
+ <div class="col-sm-10">
409
+ <input placeholder="Password" class="form-control" type="password" name="model3[inputPassword3]" id="model3_inputPassword3" />
410
+ </div>
411
+ </div>
412
+ HTML
426
413
  }
427
414
 
428
415
  subject {
@@ -438,8 +425,21 @@ describe SimpleBootstrapForm, type: :helper do
438
425
  end
439
426
  }
440
427
 
441
- it "should generate the correct output" do
442
- #expect(pretty_html subject).to eq horizontal_form_output
428
+ it "should generate the correct form tag" do
429
+ expect(subject.to_s).to have_element('form')
430
+ .with_id('new_model3')
431
+ .with_only_classes('form-horizontal new_model3')
432
+ .with_attr_value(:action, '/foo')
433
+ end
434
+
435
+ it "should generate the correct email field" do
436
+ markup = Nokogiri::XML(subject.to_s).css('.form-group').first
437
+ expect(pretty_html markup.to_s).to eq email_field_markup
438
+ end
439
+
440
+ it "should generate the correct password field" do
441
+ markup = Nokogiri::XML(subject.to_s).css('.form-group')[1]
442
+ expect(pretty_html markup.to_s).to eq password_field_markup
443
443
  end
444
444
  end
445
445
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
  require 'rspec/rails'
5
- require 'rspec/autorun'
6
5
 
7
6
  # Requires supporting ruby files with custom matchers and macros, etc, in
8
7
  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@@ -1,19 +1,13 @@
1
1
  require 'nokogiri'
2
2
 
3
3
  RSpec::Matchers.define :have_element do |selector|
4
- match_for_should do |markup|
4
+ match do |markup|
5
5
  @selector = selector
6
6
  @markup = markup
7
7
  element_is_present && classes_match && content_matches
8
8
  end
9
9
 
10
- #match_for_should_not do |markup|
11
- # @selector = selector
12
- # @markup = markup
13
- # !element_is_present || !classes_match || !content_matches
14
- #end
15
-
16
- failure_message_for_should do |markup|
10
+ failure_message do |markup|
17
11
  if the_element.nil?
18
12
  "expected to find an element matching #{actual_selector} in #{markup}"
19
13
  else
@@ -25,7 +19,7 @@ RSpec::Matchers.define :have_element do |selector|
25
19
  end
26
20
  end
27
21
 
28
- failure_message_for_should_not do |markup|
22
+ failure_message_when_negated do |markup|
29
23
  if checking_classes? || checking_content?
30
24
  if the_element.nil?
31
25
  # If we have post tag-retrieval checks, it is an error not to find the tag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pierson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.0.beta1
47
+ version: 3.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.0.beta1
54
+ version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.2.0
201
+ rubygems_version: 2.4.3
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Bootstrap 3 Form Helper