simple_form-bootstrap 1.2.0 → 1.3.0

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.
@@ -1,4 +1,4 @@
1
1
  module SimpleForm; end
2
2
  module SimpleForm::Bootstrap
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
@@ -1,63 +1,63 @@
1
- require 'simplecov'
2
-
3
- module CoverageHelper
4
- class << self
5
- # Helper to include Coveralls/Code Climate coverage, but not require developers to install the
6
- # gem.
7
- #
8
- # @param name [String] The name of the module to require.
9
- # @param initializer [Proc] The block to execute when the module is required successfully.
10
- def load(name, &initializer)
11
- old_formatter = SimpleCov.formatter
12
- require name
13
- initializer.call
14
-
15
- merge_formatters(old_formatter, SimpleCov.formatter)
16
- rescue LoadError => e
17
- if e.path == name
18
- puts format('Cannot find \'%s\', ignoring', name) if ENV['CI']
19
- else
20
- raise e
21
- end
22
- end
23
-
24
- private
25
-
26
- # Merge two SimpleCov formatters into a single MultiFormatter.
27
- #
28
- # This method is idempotent if the old and new formatters are the same.
29
- def merge_formatters(old_formatter, new_formatter)
30
- return if old_formatter == new_formatter
31
-
32
- old_formatter = [*expand_formatter(old_formatter)]
33
- new_formatter = [*expand_formatter(new_formatter)]
34
- formatters = old_formatter + new_formatter
35
-
36
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters]
37
- end
38
-
39
- # Extracts the formatters from a MultiFormatter so we do not nest them.
40
- def expand_formatter(formatter)
41
- return formatter unless formatter.is_a?(SimpleCov::Formatter::MultiFormatter)
42
- formatter.formatters
43
- end
44
- end
45
- end
46
-
47
- if ENV['CI']
48
- # Coveralls
49
- CoverageHelper.load('coveralls') do
50
- Coveralls.wear!('rails')
51
- end
52
-
53
- # Code Climate
54
- CoverageHelper.load('codeclimate-test-reporter') do
55
- CodeClimate::TestReporter.start
56
- end
57
- end
58
-
59
- # Code coverage exclusions
60
- SimpleCov.start do
61
- # Helpers for schema migrations. We don't test schema migrations, so these would never run.
62
- add_filter '/lib/extensions/active_record/connection_adapters/table_definition.rb'
63
- end
1
+ require 'simplecov'
2
+
3
+ module CoverageHelper
4
+ class << self
5
+ # Helper to include Coveralls/Code Climate coverage, but not require developers to install the
6
+ # gem.
7
+ #
8
+ # @param name [String] The name of the module to require.
9
+ # @param initializer [Proc] The block to execute when the module is required successfully.
10
+ def load(name, &initializer)
11
+ old_formatter = SimpleCov.formatter
12
+ require name
13
+ initializer.call
14
+
15
+ merge_formatters(old_formatter, SimpleCov.formatter)
16
+ rescue LoadError => e
17
+ if e.path == name
18
+ puts format('Cannot find \'%s\', ignoring', name) if ENV['CI']
19
+ else
20
+ raise e
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ # Merge two SimpleCov formatters into a single MultiFormatter.
27
+ #
28
+ # This method is idempotent if the old and new formatters are the same.
29
+ def merge_formatters(old_formatter, new_formatter)
30
+ return if old_formatter == new_formatter
31
+
32
+ old_formatter = [*expand_formatter(old_formatter)]
33
+ new_formatter = [*expand_formatter(new_formatter)]
34
+ formatters = old_formatter + new_formatter
35
+
36
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters]
37
+ end
38
+
39
+ # Extracts the formatters from a MultiFormatter so we do not nest them.
40
+ def expand_formatter(formatter)
41
+ return formatter unless formatter.is_a?(SimpleCov::Formatter::MultiFormatter)
42
+ formatter.formatters
43
+ end
44
+ end
45
+ end
46
+
47
+ if ENV['CI']
48
+ # Coveralls
49
+ CoverageHelper.load('coveralls') do
50
+ Coveralls.wear!('rails')
51
+ end
52
+
53
+ # Code Climate
54
+ CoverageHelper.load('codeclimate-test-reporter') do
55
+ CodeClimate::TestReporter.start
56
+ end
57
+ end
58
+
59
+ # Code coverage exclusions
60
+ SimpleCov.start do
61
+ # Helpers for schema migrations. We don't test schema migrations, so these would never run.
62
+ add_filter '/lib/extensions/active_record/connection_adapters/table_definition.rb'
63
+ end
@@ -1,45 +1,45 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV['RAILS_ENV'] ||= 'test'
3
- require 'spec_helper'
4
- require 'rails'
5
- require 'action_view'
6
- require 'action_controller'
7
- require 'active_model'
8
- require 'rspec/rails'
9
- # Add additional requires below this line. Rails is not loaded until this point!
10
-
11
- require 'simple_form'
12
- require 'simple_form/bootstrap'
13
- SimpleForm.setup do; end
14
-
15
- # Requires supporting ruby files with custom matchers and macros, etc, in
16
- # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
17
- # run as spec files by default. This means that files in spec/support that end
18
- # in _spec.rb will both be required and run as specs, causing the specs to be
19
- # run twice. It is recommended that you do not name files matching this glob to
20
- # end with _spec.rb. You can configure this pattern with the --pattern
21
- # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
22
- #
23
- # The following line is provided for convenience purposes. It has the downside
24
- # of increasing the boot-up time by auto-requiring all files in the support
25
- # directory. Alternatively, in the individual `*_spec.rb` files, manually
26
- # require only the support files necessary.
27
- #
28
- Dir[__dir__ + '/support/**/*.rb'].each { |f| require f }
29
-
30
- RSpec.configure do |config|
31
- # RSpec Rails can automatically mix in different behaviours to your tests
32
- # based on their file location, for example enabling you to call `get` and
33
- # `post` in specs under `spec/controllers`.
34
- #
35
- # You can disable this behaviour by removing the line below, and instead
36
- # explicitly tag your specs with their type, e.g.:
37
- #
38
- # RSpec.describe UsersController, :type => :controller do
39
- # # ...
40
- # end
41
- #
42
- # The different available types are documented in the features, such as in
43
- # https://relishapp.com/rspec/rspec-rails/docs
44
- config.infer_spec_type_from_file_location!
45
- end
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require 'spec_helper'
4
+ require 'rails'
5
+ require 'action_view'
6
+ require 'action_controller'
7
+ require 'active_model'
8
+ require 'rspec/rails'
9
+ # Add additional requires below this line. Rails is not loaded until this point!
10
+
11
+ require 'simple_form'
12
+ require 'simple_form/bootstrap'
13
+ SimpleForm.setup do; end
14
+
15
+ # Requires supporting ruby files with custom matchers and macros, etc, in
16
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
17
+ # run as spec files by default. This means that files in spec/support that end
18
+ # in _spec.rb will both be required and run as specs, causing the specs to be
19
+ # run twice. It is recommended that you do not name files matching this glob to
20
+ # end with _spec.rb. You can configure this pattern with the --pattern
21
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
22
+ #
23
+ # The following line is provided for convenience purposes. It has the downside
24
+ # of increasing the boot-up time by auto-requiring all files in the support
25
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
26
+ # require only the support files necessary.
27
+ #
28
+ Dir[__dir__ + '/support/**/*.rb'].each { |f| require f }
29
+
30
+ RSpec.configure do |config|
31
+ # RSpec Rails can automatically mix in different behaviours to your tests
32
+ # based on their file location, for example enabling you to call `get` and
33
+ # `post` in specs under `spec/controllers`.
34
+ #
35
+ # You can disable this behaviour by removing the line below, and instead
36
+ # explicitly tag your specs with their type, e.g.:
37
+ #
38
+ # RSpec.describe UsersController, :type => :controller do
39
+ # # ...
40
+ # end
41
+ #
42
+ # The different available types are documented in the features, such as in
43
+ # https://relishapp.com/rspec/rspec-rails/docs
44
+ config.infer_spec_type_from_file_location!
45
+ end
@@ -0,0 +1,39 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe 'token', type: :view do
4
+ class Token
5
+ extend ActiveModel::Naming
6
+ include ActiveModel::Conversion
7
+
8
+ def self.reflect_on_association(_)
9
+ OpenStruct.new(macro: :has_many, name: :tokens)
10
+ end
11
+
12
+ def token_ids
13
+ end
14
+
15
+ def token_ids=(_)
16
+ end
17
+
18
+ def persisted?
19
+ true
20
+ end
21
+ end
22
+
23
+ let(:token_collection) { [OpenStruct.new(text: 'Text', value: 3)] }
24
+ subject! do
25
+ object = Token.new
26
+ simple_form_for object, url: 'test' do |f|
27
+ f.association :tokens, as: :token, collection: token_collection,
28
+ label_method: :text, value_method: :value
29
+ end
30
+ render text: output_buffer
31
+ end
32
+
33
+ it 'displays the select' do
34
+ expect(rendered).to have_tag('select')
35
+ token_collection.each do |token|
36
+ expect(rendered).to have_tag('option', text: token[:text], value: token[:value])
37
+ end
38
+ end
39
+ end
@@ -1,14 +1,14 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe SimpleForm do
4
- describe '.setup' do
5
- it 'yields self' do
6
- result = nil
7
- subject.setup do |config|
8
- result = config
9
- end
10
-
11
- expect(result).to equal(subject)
12
- end
13
- end
14
- end
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe SimpleForm do
4
+ describe '.setup' do
5
+ it 'yields self' do
6
+ result = nil
7
+ subject.setup do |config|
8
+ result = config
9
+ end
10
+
11
+ expect(result).to equal(subject)
12
+ end
13
+ end
14
+ end
@@ -1,90 +1,90 @@
1
- require 'rspec-html-matchers'
2
- require 'coverage_helper'
3
-
4
- # This file was generated by the `rspec --init` command. Conventionally, all
5
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
- # The generated `.rspec` file contains `--require spec_helper` which will cause
7
- # this file to always be loaded, without a need to explicitly require it in any
8
- # files.
9
- #
10
- # Given that it is always loaded, you are encouraged to keep this file as
11
- # light-weight as possible. Requiring heavyweight dependencies from this file
12
- # will add to the boot time of your test suite on EVERY test run, even for an
13
- # individual file that may not need all of that loaded. Instead, consider making
14
- # a separate helper file that requires the additional dependencies and performs
15
- # the additional setup, and require it from the spec files that actually need
16
- # it.
17
- #
18
- # The `.rspec` file also contains a few flags that are not defaults but that
19
- # users commonly want.
20
- #
21
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
- RSpec.configure do |config|
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # These two settings work together to allow you to limit a spec run
47
- # to individual examples or groups you care about by tagging them with
48
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
- # get run.
50
- config.filter_run :focus
51
- config.run_all_when_everything_filtered = true
52
-
53
- # Limits the available syntax to the non-monkey patched syntax that is
54
- # recommended. For more details, see:
55
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
- config.disable_monkey_patching!
59
-
60
- # This setting enables warnings. It's recommended, but in some cases may
61
- # be too noisy due to issues in dependencies.
62
- config.warnings = true
63
-
64
- # Many RSpec users commonly either run the entire suite or an individual
65
- # file, and it's useful to allow more verbose output when running an
66
- # individual spec file.
67
- if config.files_to_run.one?
68
- # Use the documentation formatter for detailed output,
69
- # unless a formatter has already been configured
70
- # (e.g. via a command-line flag).
71
- config.default_formatter = 'doc'
72
- end
73
-
74
- # Print the 10 slowest examples and example groups at the
75
- # end of the spec run, to help surface which specs are running
76
- # particularly slow.
77
- config.profile_examples = 10
78
-
79
- # Run specs in random order to surface order dependencies. If you find an
80
- # order dependency and want to debug it, you can fix the order by providing
81
- # the seed, which is printed after each run.
82
- # --seed 1234
83
- config.order = :random
84
-
85
- # Seed global randomization in this process using the `--seed` CLI option.
86
- # Setting this allows you to use `--seed` to deterministically reproduce
87
- # test failures related to randomization by passing the same `--seed` value
88
- # as the one that triggered the failure.
89
- Kernel.srand config.seed
90
- end
1
+ require 'rspec-html-matchers'
2
+ require 'coverage_helper'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
7
+ # this file to always be loaded, without a need to explicitly require it in any
8
+ # files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need
16
+ # it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is
54
+ # recommended. For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ end