restspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.gitignore +23 -0
- data/.rspec +4 -0
- data/Gemfile +4 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +188 -0
- data/ROADMAP.md +11 -0
- data/Rakefile +20 -0
- data/bin/restspec +54 -0
- data/bin/templates/Gemfile +3 -0
- data/bin/templates/custom_macros.rb +3 -0
- data/bin/templates/restspec_config.rb +10 -0
- data/bin/templates/spec_helper.rb +19 -0
- data/docs/endpoints.md +200 -0
- data/docs/helpers.md +40 -0
- data/docs/macros.md +140 -0
- data/docs/matchers.md +38 -0
- data/docs/schemas.md +28 -0
- data/docs/tutorial.md +477 -0
- data/docs/types.md +134 -0
- data/examples/store-api-tests/.rspec +3 -0
- data/examples/store-api-tests/Gemfile +4 -0
- data/examples/store-api-tests/Gemfile.lock +70 -0
- data/examples/store-api-tests/spec/api/category_spec.rb +23 -0
- data/examples/store-api-tests/spec/api/product_spec.rb +55 -0
- data/examples/store-api-tests/spec/api/restspec/endpoints.rb +39 -0
- data/examples/store-api-tests/spec/api/restspec/requirements.rb +0 -0
- data/examples/store-api-tests/spec/api/restspec/restspec_config.rb +6 -0
- data/examples/store-api-tests/spec/api/restspec/schemas.rb +11 -0
- data/examples/store-api-tests/spec/spec_helper.rb +19 -0
- data/examples/store-api-tests/spec/support/custom_macros.rb +3 -0
- data/examples/store-api-tests/spec/support/custom_matchers.rb +0 -0
- data/examples/store-api/.editorconfig +24 -0
- data/examples/store-api/.rbenv-vars.example +3 -0
- data/examples/store-api/.rspec +4 -0
- data/examples/store-api/.ruby-version +1 -0
- data/examples/store-api/Gemfile +58 -0
- data/examples/store-api/Gemfile.lock +216 -0
- data/examples/store-api/Guardfile +39 -0
- data/examples/store-api/README.md +1 -0
- data/examples/store-api/Rakefile +6 -0
- data/examples/store-api/app/assets/images/.keep +0 -0
- data/examples/store-api/app/assets/javascripts/application.js +16 -0
- data/examples/store-api/app/assets/javascripts/categories.js.coffee +3 -0
- data/examples/store-api/app/assets/javascripts/products.js.coffee +3 -0
- data/examples/store-api/app/assets/stylesheets/application.css +15 -0
- data/examples/store-api/app/assets/stylesheets/categories.css.scss +3 -0
- data/examples/store-api/app/assets/stylesheets/products.css.scss +3 -0
- data/examples/store-api/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/examples/store-api/app/controllers/application_controller.rb +5 -0
- data/examples/store-api/app/controllers/categories_controller.rb +74 -0
- data/examples/store-api/app/controllers/concerns/.keep +0 -0
- data/examples/store-api/app/controllers/products_controller.rb +74 -0
- data/examples/store-api/app/helpers/application_helper.rb +2 -0
- data/examples/store-api/app/helpers/categories_helper.rb +2 -0
- data/examples/store-api/app/helpers/products_helper.rb +2 -0
- data/examples/store-api/app/mailers/.keep +0 -0
- data/examples/store-api/app/models/.keep +0 -0
- data/examples/store-api/app/models/category.rb +2 -0
- data/examples/store-api/app/models/concerns/.keep +0 -0
- data/examples/store-api/app/models/product.rb +3 -0
- data/examples/store-api/app/views/categories/_form.html.erb +21 -0
- data/examples/store-api/app/views/categories/edit.html.erb +6 -0
- data/examples/store-api/app/views/categories/index.html.erb +25 -0
- data/examples/store-api/app/views/categories/index.json.jbuilder +4 -0
- data/examples/store-api/app/views/categories/new.html.erb +5 -0
- data/examples/store-api/app/views/categories/show.html.erb +9 -0
- data/examples/store-api/app/views/categories/show.json.jbuilder +1 -0
- data/examples/store-api/app/views/layouts/application.html.erb +14 -0
- data/examples/store-api/app/views/products/_form.html.erb +29 -0
- data/examples/store-api/app/views/products/edit.html.erb +6 -0
- data/examples/store-api/app/views/products/index.html.erb +29 -0
- data/examples/store-api/app/views/products/index.json.jbuilder +4 -0
- data/examples/store-api/app/views/products/new.html.erb +5 -0
- data/examples/store-api/app/views/products/show.html.erb +19 -0
- data/examples/store-api/app/views/products/show.json.jbuilder +6 -0
- data/examples/store-api/bin/bundle +3 -0
- data/examples/store-api/bin/guard +16 -0
- data/examples/store-api/bin/rails +8 -0
- data/examples/store-api/bin/rake +8 -0
- data/examples/store-api/bin/spring +18 -0
- data/examples/store-api/config.ru +4 -0
- data/examples/store-api/config/application.rb +30 -0
- data/examples/store-api/config/boot.rb +4 -0
- data/examples/store-api/config/database.yml +25 -0
- data/examples/store-api/config/environment.rb +5 -0
- data/examples/store-api/config/environments/development.rb +37 -0
- data/examples/store-api/config/environments/production.rb +78 -0
- data/examples/store-api/config/environments/test.rb +39 -0
- data/examples/store-api/config/initializers/assets.rb +8 -0
- data/examples/store-api/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/store-api/config/initializers/cookies_serializer.rb +3 -0
- data/examples/store-api/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/store-api/config/initializers/inflections.rb +16 -0
- data/examples/store-api/config/initializers/mime_types.rb +4 -0
- data/examples/store-api/config/initializers/session_store.rb +3 -0
- data/examples/store-api/config/initializers/wrap_parameters.rb +14 -0
- data/examples/store-api/config/locales/en.yml +23 -0
- data/examples/store-api/config/routes.rb +59 -0
- data/examples/store-api/config/secrets.yml +22 -0
- data/examples/store-api/db/migrate/20141205154816_create_products.rb +11 -0
- data/examples/store-api/db/migrate/20141205171104_create_categories.rb +9 -0
- data/examples/store-api/db/migrate/20141205171140_add_category_id_to_products.rb +5 -0
- data/examples/store-api/db/schema.rb +31 -0
- data/examples/store-api/db/seeds.rb +7 -0
- data/examples/store-api/lib/assets/.keep +0 -0
- data/examples/store-api/lib/tasks/.keep +0 -0
- data/examples/store-api/log/.keep +0 -0
- data/examples/store-api/public/404.html +67 -0
- data/examples/store-api/public/422.html +67 -0
- data/examples/store-api/public/500.html +66 -0
- data/examples/store-api/public/favicon.ico +0 -0
- data/examples/store-api/public/robots.txt +5 -0
- data/examples/store-api/spec/controllers/categories_controller_spec.rb +159 -0
- data/examples/store-api/spec/controllers/products_controller_spec.rb +159 -0
- data/examples/store-api/spec/factories/categories.rb +6 -0
- data/examples/store-api/spec/factories/products.rb +8 -0
- data/examples/store-api/spec/helpers/categories_helper_spec.rb +15 -0
- data/examples/store-api/spec/helpers/products_helper_spec.rb +15 -0
- data/examples/store-api/spec/models/category_spec.rb +5 -0
- data/examples/store-api/spec/models/product_spec.rb +5 -0
- data/examples/store-api/spec/rails_helper.rb +50 -0
- data/examples/store-api/spec/requests/categories_spec.rb +10 -0
- data/examples/store-api/spec/requests/products_spec.rb +10 -0
- data/examples/store-api/spec/routing/categories_routing_spec.rb +35 -0
- data/examples/store-api/spec/routing/products_routing_spec.rb +35 -0
- data/examples/store-api/spec/spec_helper.rb +85 -0
- data/examples/store-api/spec/views/categories/edit.html.erb_spec.rb +18 -0
- data/examples/store-api/spec/views/categories/index.html.erb_spec.rb +19 -0
- data/examples/store-api/spec/views/categories/new.html.erb_spec.rb +18 -0
- data/examples/store-api/spec/views/categories/show.html.erb_spec.rb +14 -0
- data/examples/store-api/spec/views/products/edit.html.erb_spec.rb +24 -0
- data/examples/store-api/spec/views/products/index.html.erb_spec.rb +25 -0
- data/examples/store-api/spec/views/products/new.html.erb_spec.rb +24 -0
- data/examples/store-api/spec/views/products/show.html.erb_spec.rb +18 -0
- data/examples/store-api/vendor/assets/javascripts/.keep +0 -0
- data/examples/store-api/vendor/assets/stylesheets/.keep +0 -0
- data/lib/restspec.rb +38 -0
- data/lib/restspec/configuration.rb +43 -0
- data/lib/restspec/endpoints/dsl.rb +142 -0
- data/lib/restspec/endpoints/endpoint.rb +135 -0
- data/lib/restspec/endpoints/namespace.rb +89 -0
- data/lib/restspec/endpoints/network.rb +39 -0
- data/lib/restspec/endpoints/request.rb +11 -0
- data/lib/restspec/endpoints/response.rb +53 -0
- data/lib/restspec/requirements/dsl.rb +10 -0
- data/lib/restspec/requirements/requirement.rb +59 -0
- data/lib/restspec/rspec/api_helpers.rb +64 -0
- data/lib/restspec/rspec/api_macros.rb +126 -0
- data/lib/restspec/rspec/extras.rb +2 -0
- data/lib/restspec/rspec/matchers/api_matchers.rb +6 -0
- data/lib/restspec/rspec/matchers/be_like_schema.rb +18 -0
- data/lib/restspec/rspec/matchers/be_like_schema_array.rb +18 -0
- data/lib/restspec/rspec/matchers/have_header.rb +47 -0
- data/lib/restspec/rspec/matchers/have_status.rb +17 -0
- data/lib/restspec/rspec/matchers/include_where.rb +14 -0
- data/lib/restspec/rspec/shared_examples.rb +12 -0
- data/lib/restspec/schema/attribute.rb +31 -0
- data/lib/restspec/schema/attribute_example.rb +21 -0
- data/lib/restspec/schema/checker.rb +73 -0
- data/lib/restspec/schema/dsl.rb +36 -0
- data/lib/restspec/schema/schema.rb +21 -0
- data/lib/restspec/schema/schema_example.rb +28 -0
- data/lib/restspec/schema/types.rb +35 -0
- data/lib/restspec/schema/types/array_type.rb +34 -0
- data/lib/restspec/schema/types/basic_type.rb +35 -0
- data/lib/restspec/schema/types/boolean_type.rb +11 -0
- data/lib/restspec/schema/types/decimal_string_type.rb +32 -0
- data/lib/restspec/schema/types/decimal_type.rb +14 -0
- data/lib/restspec/schema/types/embedded_schema_type.rb +28 -0
- data/lib/restspec/schema/types/hash_type.rb +25 -0
- data/lib/restspec/schema/types/integer_type.rb +11 -0
- data/lib/restspec/schema/types/null_type.rb +11 -0
- data/lib/restspec/schema/types/one_of_type.rb +21 -0
- data/lib/restspec/schema/types/schema_id_type.rb +88 -0
- data/lib/restspec/schema/types/string_type.rb +11 -0
- data/lib/restspec/shortcuts.rb +8 -0
- data/lib/restspec/stores/endpoint_store.rb +25 -0
- data/lib/restspec/stores/namespace_store.rb +20 -0
- data/lib/restspec/stores/schema_store.rb +19 -0
- data/lib/restspec/values/status_code.rb +13 -0
- data/lib/restspec/values/super_hash.rb +12 -0
- data/lib/restspec/version.rb +3 -0
- data/restspec.gemspec +37 -0
- data/spec/restspec/endpoints/dsl_spec.rb +269 -0
- data/spec/restspec/endpoints/endpoint_spec.rb +146 -0
- data/spec/restspec/endpoints/namespace_spec.rb +143 -0
- data/spec/restspec/endpoints/response_spec.rb +49 -0
- data/spec/restspec/schema/attribute_example_spec.rb +35 -0
- data/spec/restspec/schema/dsl_spec.rb +78 -0
- data/spec/restspec/schema/schema_example_spec.rb +40 -0
- data/spec/restspec/schema/schema_spec.rb +11 -0
- data/spec/restspec/schema/types/array_type_spec.rb +56 -0
- data/spec/restspec/schema/types/basic_type_spec.rb +62 -0
- data/spec/restspec/schema/types/boolean_type_spec.rb +26 -0
- data/spec/restspec/schema/types/null_type_spec.rb +25 -0
- data/spec/restspec/schema/types/string_type_spec.rb +26 -0
- data/spec/restspec/values/status_code_spec.rb +13 -0
- data/spec/spec_helper.rb +23 -0
- metadata +484 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the CategoriesHelper. For example:
|
5
|
+
#
|
6
|
+
# describe CategoriesHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
RSpec.describe CategoriesHelper, :type => :helper do
|
14
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the ProductsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe ProductsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
RSpec.describe ProductsHelper, :type => :helper do
|
14
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
15
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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 File.expand_path("../../config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
7
|
+
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
9
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
10
|
+
# run as spec files by default. This means that files in spec/support that end
|
11
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
12
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
13
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
14
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
15
|
+
#
|
16
|
+
# The following line is provided for convenience purposes. It has the downside
|
17
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
18
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
19
|
+
# require only the support files necessary.
|
20
|
+
#
|
21
|
+
# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
22
|
+
|
23
|
+
# Checks for pending migrations before tests are run.
|
24
|
+
# If you are not using ActiveRecord, you can remove this line.
|
25
|
+
ActiveRecord::Migration.maintain_test_schema!
|
26
|
+
|
27
|
+
RSpec.configure do |config|
|
28
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
29
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
30
|
+
|
31
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
32
|
+
# examples within a transaction, remove the following line or assign false
|
33
|
+
# instead of true.
|
34
|
+
config.use_transactional_fixtures = true
|
35
|
+
|
36
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
37
|
+
# based on their file location, for example enabling you to call `get` and
|
38
|
+
# `post` in specs under `spec/controllers`.
|
39
|
+
#
|
40
|
+
# You can disable this behaviour by removing the line below, and instead
|
41
|
+
# explicitly tag your specs with their type, e.g.:
|
42
|
+
#
|
43
|
+
# RSpec.describe UsersController, :type => :controller do
|
44
|
+
# # ...
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# The different available types are documented in the features, such as in
|
48
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
49
|
+
config.infer_spec_type_from_file_location!
|
50
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe CategoriesController, :type => :routing do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #index" do
|
7
|
+
expect(:get => "/categories").to route_to("categories#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #new" do
|
11
|
+
expect(:get => "/categories/new").to route_to("categories#new")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to #show" do
|
15
|
+
expect(:get => "/categories/1").to route_to("categories#show", :id => "1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "routes to #edit" do
|
19
|
+
expect(:get => "/categories/1/edit").to route_to("categories#edit", :id => "1")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to #create" do
|
23
|
+
expect(:post => "/categories").to route_to("categories#create")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "routes to #update" do
|
27
|
+
expect(:put => "/categories/1").to route_to("categories#update", :id => "1")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "routes to #destroy" do
|
31
|
+
expect(:delete => "/categories/1").to route_to("categories#destroy", :id => "1")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe ProductsController, :type => :routing do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #index" do
|
7
|
+
expect(:get => "/products").to route_to("products#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #new" do
|
11
|
+
expect(:get => "/products/new").to route_to("products#new")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to #show" do
|
15
|
+
expect(:get => "/products/1").to route_to("products#show", :id => "1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "routes to #edit" do
|
19
|
+
expect(:get => "/products/1/edit").to route_to("products#edit", :id => "1")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to #create" do
|
23
|
+
expect(:post => "/products").to route_to("products#create")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "routes to #update" do
|
27
|
+
expect(:put => "/products/1").to route_to("products#update", :id => "1")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "routes to #destroy" do
|
31
|
+
expect(:delete => "/products/1").to route_to("products#destroy", :id => "1")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# The settings below are suggested to provide a good initial experience
|
42
|
+
# with RSpec, but feel free to customize to your heart's content.
|
43
|
+
=begin
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
59
|
+
# file, and it's useful to allow more verbose output when running an
|
60
|
+
# individual spec file.
|
61
|
+
if config.files_to_run.one?
|
62
|
+
# Use the documentation formatter for detailed output,
|
63
|
+
# unless a formatter has already been configured
|
64
|
+
# (e.g. via a command-line flag).
|
65
|
+
config.default_formatter = 'doc'
|
66
|
+
end
|
67
|
+
|
68
|
+
# Print the 10 slowest examples and example groups at the
|
69
|
+
# end of the spec run, to help surface which specs are running
|
70
|
+
# particularly slow.
|
71
|
+
config.profile_examples = 10
|
72
|
+
|
73
|
+
# Run specs in random order to surface order dependencies. If you find an
|
74
|
+
# order dependency and want to debug it, you can fix the order by providing
|
75
|
+
# the seed, which is printed after each run.
|
76
|
+
# --seed 1234
|
77
|
+
config.order = :random
|
78
|
+
|
79
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
80
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
81
|
+
# test failures related to randomization by passing the same `--seed` value
|
82
|
+
# as the one that triggered the failure.
|
83
|
+
Kernel.srand config.seed
|
84
|
+
=end
|
85
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "categories/edit", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
@category = assign(:category, Category.create!(
|
6
|
+
:name => "MyString"
|
7
|
+
))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "renders the edit category form" do
|
11
|
+
render
|
12
|
+
|
13
|
+
assert_select "form[action=?][method=?]", category_path(@category), "post" do
|
14
|
+
|
15
|
+
assert_select "input#category_name[name=?]", "category[name]"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "categories/index", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
assign(:categories, [
|
6
|
+
Category.create!(
|
7
|
+
:name => "Name"
|
8
|
+
),
|
9
|
+
Category.create!(
|
10
|
+
:name => "Name"
|
11
|
+
)
|
12
|
+
])
|
13
|
+
end
|
14
|
+
|
15
|
+
it "renders a list of categories" do
|
16
|
+
render
|
17
|
+
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "categories/new", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
assign(:category, Category.new(
|
6
|
+
:name => "MyString"
|
7
|
+
))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "renders new category form" do
|
11
|
+
render
|
12
|
+
|
13
|
+
assert_select "form[action=?][method=?]", categories_path, "post" do
|
14
|
+
|
15
|
+
assert_select "input#category_name[name=?]", "category[name]"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "categories/show", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
@category = assign(:category, Category.create!(
|
6
|
+
:name => "Name"
|
7
|
+
))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "renders attributes in <p>" do
|
11
|
+
render
|
12
|
+
expect(rendered).to match(/Name/)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "products/edit", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
@product = assign(:product, Product.create!(
|
6
|
+
:name => "MyString",
|
7
|
+
:code => "MyString",
|
8
|
+
:price => "9.99"
|
9
|
+
))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders the edit product form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
assert_select "form[action=?][method=?]", product_path(@product), "post" do
|
16
|
+
|
17
|
+
assert_select "input#product_name[name=?]", "product[name]"
|
18
|
+
|
19
|
+
assert_select "input#product_code[name=?]", "product[code]"
|
20
|
+
|
21
|
+
assert_select "input#product_price[name=?]", "product[price]"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "products/index", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
assign(:products, [
|
6
|
+
Product.create!(
|
7
|
+
:name => "Name",
|
8
|
+
:code => "Code",
|
9
|
+
:price => "9.99"
|
10
|
+
),
|
11
|
+
Product.create!(
|
12
|
+
:name => "Name",
|
13
|
+
:code => "Code",
|
14
|
+
:price => "9.99"
|
15
|
+
)
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders a list of products" do
|
20
|
+
render
|
21
|
+
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
22
|
+
assert_select "tr>td", :text => "Code".to_s, :count => 2
|
23
|
+
assert_select "tr>td", :text => "9.99".to_s, :count => 2
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "products/new", :type => :view do
|
4
|
+
before(:each) do
|
5
|
+
assign(:product, Product.new(
|
6
|
+
:name => "MyString",
|
7
|
+
:code => "MyString",
|
8
|
+
:price => "9.99"
|
9
|
+
))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders new product form" do
|
13
|
+
render
|
14
|
+
|
15
|
+
assert_select "form[action=?][method=?]", products_path, "post" do
|
16
|
+
|
17
|
+
assert_select "input#product_name[name=?]", "product[name]"
|
18
|
+
|
19
|
+
assert_select "input#product_code[name=?]", "product[code]"
|
20
|
+
|
21
|
+
assert_select "input#product_price[name=?]", "product[price]"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|