diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index 0c9fefa..b9f0fb2 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -1,5 +1,22 @@ require 'rails_helper' RSpec.describe Category, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + let(:user) { User.create(name: 'Lucas Erkana', email: 'invalid_email', password: 'password') } + subject do + Category.new(name: 'Food', icon: 'food.jpng', author: user) + end + + it 'should not be valid with name value set to nil' do + subject.name = nil + expect(subject).to_not be_valid + end + + it 'should not be valid with icon value set to nil' do + subject.icon = nil + expect(subject).to_not be_valid + end + + it 'should be valid ' do + expect(subject).to be_valid + end end diff --git a/spec/models/entity_spec.rb b/spec/models/entity_spec.rb index f513ed6..c1761dd 100644 --- a/spec/models/entity_spec.rb +++ b/spec/models/entity_spec.rb @@ -1,5 +1,22 @@ require 'rails_helper' RSpec.describe Entity, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + let(:user) { User.create(name: 'John Doe') } + subject do + Entity.new(name: 'Food', amount: 10, author: user) + end + + it 'should not be valid with name value is nil' do + subject.name = nil + expect(subject).to_not be_valid + end + + it 'should not be valid if amount is less than 0' do + subject.amount = -5 + expect(subject).to_not be_valid + end + + it 'Should be valid' do + expect(subject).to be_valid + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 47a31bb..810e65f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,29 @@ require 'rails_helper' RSpec.describe User, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + describe 'validations' do + it 'validates presence of name' do + user = User.new(email: 'test@example.com', password: 'password') + expect(user).not_to be_valid + expect(user.errors[:name]).to include("can't be blank") + end + + it 'validates presence of email' do + user = User.new(name: 'John Doe', password: 'password') + expect(user).not_to be_valid + expect(user.errors[:email]).to include("can't be blank") + end + + it 'validates format of name' do + user = User.new(name: '', email: 'test@example.com', password: 'password') + expect(user).not_to be_valid + expect(user.errors[:name]).to include("can't be blank") + end + + it 'validates format of email' do + user = User.new(name: 'John Doe', email: 'invalid_email', password: 'password') + expect(user).not_to be_valid + expect(user.errors[:email]).to include('is invalid') + end + end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..6584c98 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,63 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# Prevent database truncation if the environment is production +abort('The Rails environment is running in production mode!') if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://rspec.info/features/6-0/rspec-rails + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/requests/categories_spec.rb b/spec/requests/categories_spec.rb index 54b6751..c4cf2c2 100644 --- a/spec/requests/categories_spec.rb +++ b/spec/requests/categories_spec.rb @@ -1,130 +1,18 @@ require 'rails_helper' -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - RSpec.describe '/categories', type: :request do - # This should return the minimal set of attributes required to create a valid - # Category. As you add validations to Category, be sure to - # adjust the attributes here as well. - let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') - end - - let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') - end - - describe 'GET /index' do - it 'renders a successful response' do - Category.create! valid_attributes - get categories_url - expect(response).to be_successful - end - end - - describe 'GET /show' do - it 'renders a successful response' do - category = Category.create! valid_attributes - get category_url(category) - expect(response).to be_successful - end - end + include Devise::Test::IntegrationHelpers describe 'GET /new' do - it 'renders a successful response' do - get new_category_url - expect(response).to be_successful - end - end - - describe 'GET /edit' do - it 'renders a successful response' do - category = Category.create! valid_attributes - get edit_category_url(category) - expect(response).to be_successful - end - end - - describe 'POST /create' do - context 'with valid parameters' do - it 'creates a new Category' do - expect do - post categories_url, params: { category: valid_attributes } - end.to change(Category, :count).by(1) - end - - it 'redirects to the created category' do - post categories_url, params: { category: valid_attributes } - expect(response).to redirect_to(category_url(Category.last)) - end - end - - context 'with invalid parameters' do - it 'does not create a new Category' do - expect do - post categories_url, params: { category: invalid_attributes } - end.to change(Category, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post categories_url, params: { category: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'PATCH /update' do - context 'with valid parameters' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested category' do - category = Category.create! valid_attributes - patch category_url(category), params: { category: new_attributes } - category.reload - skip('Add assertions for updated state') - end - - it 'redirects to the category' do - category = Category.create! valid_attributes - patch category_url(category), params: { category: new_attributes } - category.reload - expect(response).to redirect_to(category_url(category)) - end - end - - context 'with invalid parameters' do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - category = Category.create! valid_attributes - patch category_url(category), params: { category: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'DELETE /destroy' do - it 'destroys the requested category' do - category = Category.create! valid_attributes - expect do - delete category_url(category) - end.to change(Category, :count).by(-1) + before do + @user = User.create(name: 'Lucas', email: 'lderkana21x@gmail.com', password: '123123', + password_confirmation: '123123') + sign_in @user + get authenticated_root_path end - it 'redirects to the categories list' do - category = Category.create! valid_attributes - delete category_url(category) - expect(response).to redirect_to(categories_url) + it 'response to html' do + expect(response.content_type).to include 'text/html' end end end diff --git a/spec/requests/entities_spec.rb b/spec/requests/entities_spec.rb index 0962577..578095f 100644 --- a/spec/requests/entities_spec.rb +++ b/spec/requests/entities_spec.rb @@ -1,130 +1,18 @@ require 'rails_helper' -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe '/entities', type: :request do - # This should return the minimal set of attributes required to create a valid - # Entity. As you add validations to Entity, be sure to - # adjust the attributes here as well. - let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') - end - - let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') - end - - describe 'GET /index' do - it 'renders a successful response' do - Entity.create! valid_attributes - get entities_url - expect(response).to be_successful - end - end - - describe 'GET /show' do - it 'renders a successful response' do - entity = Entity.create! valid_attributes - get entity_url(entity) - expect(response).to be_successful - end - end +RSpec.describe '/entity', type: :system do + include Devise::Test::IntegrationHelpers describe 'GET /new' do - it 'renders a successful response' do - get new_entity_url - expect(response).to be_successful - end - end - - describe 'GET /edit' do - it 'renders a successful response' do - entity = Entity.create! valid_attributes - get edit_entity_url(entity) - expect(response).to be_successful - end - end - - describe 'POST /create' do - context 'with valid parameters' do - it 'creates a new Entity' do - expect do - post entities_url, params: { entity: valid_attributes } - end.to change(Entity, :count).by(1) - end - - it 'redirects to the created entity' do - post entities_url, params: { entity: valid_attributes } - expect(response).to redirect_to(entity_url(Entity.last)) - end - end - - context 'with invalid parameters' do - it 'does not create a new Entity' do - expect do - post entities_url, params: { entity: invalid_attributes } - end.to change(Entity, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post entities_url, params: { entity: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'PATCH /update' do - context 'with valid parameters' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested entity' do - entity = Entity.create! valid_attributes - patch entity_url(entity), params: { entity: new_attributes } - entity.reload - skip('Add assertions for updated state') - end - - it 'redirects to the entity' do - entity = Entity.create! valid_attributes - patch entity_url(entity), params: { entity: new_attributes } - entity.reload - expect(response).to redirect_to(entity_url(entity)) - end - end - - context 'with invalid parameters' do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - entity = Entity.create! valid_attributes - patch entity_url(entity), params: { entity: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'DELETE /destroy' do - it 'destroys the requested entity' do - entity = Entity.create! valid_attributes - expect do - delete entity_url(entity) - end.to change(Entity, :count).by(-1) + before do + @user = User.create(name: 'Lucas', email: 'lucas@gmail.com', password: '143143', password_confirmation: '143143') + sign_in @user + @category = Category.create!(name: 'category', icon: 'img', author_id: @user.id) + get new_user_entity_path(@user, category_id: @category.id) end - it 'redirects to the entities list' do - entity = Entity.create! valid_attributes - delete entity_url(entity) - expect(response).to redirect_to(entities_url) + it 'response to html' do + expect(response.content_type).to include 'text/html' end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..9c96a9b --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,92 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed +end diff --git a/spec/views/categories/edit.html.erb_spec.rb b/spec/views/categories/edit.html.erb_spec.rb deleted file mode 100644 index ea2e0e9..0000000 --- a/spec/views/categories/edit.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'categories/edit', type: :view do - let(:category) do - Category.create!( - name: 'MyString', - icon: 'MyString' - ) - end - - before(:each) do - assign(:category, category) - end - - it 'renders the edit category form' do - render - - assert_select 'form[action=?][method=?]', category_path(category), 'post' do - assert_select 'input[name=?]', 'category[name]' - - assert_select 'input[name=?]', 'category[icon]' - end - end -end diff --git a/spec/views/categories/index.html.erb_spec.rb b/spec/views/categories/index.html.erb_spec.rb deleted file mode 100644 index 847910f..0000000 --- a/spec/views/categories/index.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'categories/index', type: :view do - before(:each) do - assign(:categories, [ - Category.create!( - name: 'Name', - icon: 'Icon' - ), - Category.create!( - name: 'Name', - icon: 'Icon' - ) - ]) - end - - it 'renders a list of categories' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - assert_select cell_selector, text: Regexp.new('Icon'.to_s), count: 2 - end -end diff --git a/spec/views/categories/new.html.erb_spec.rb b/spec/views/categories/new.html.erb_spec.rb deleted file mode 100644 index 53ee930..0000000 --- a/spec/views/categories/new.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'categories/new', type: :view do - before(:each) do - assign(:category, Category.new( - name: 'MyString', - icon: 'MyString' - )) - end - - it 'renders new category form' do - render - - assert_select 'form[action=?][method=?]', categories_path, 'post' do - assert_select 'input[name=?]', 'category[name]' - - assert_select 'input[name=?]', 'category[icon]' - end - end -end diff --git a/spec/views/categories/show.html.erb_spec.rb b/spec/views/categories/show.html.erb_spec.rb deleted file mode 100644 index 53575f9..0000000 --- a/spec/views/categories/show.html.erb_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'categories/show', type: :view do - before(:each) do - assign(:category, Category.create!( - name: 'Name', - icon: 'Icon' - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - expect(rendered).to match(/Icon/) - end -end diff --git a/spec/views/category_spec.rb b/spec/views/category_spec.rb new file mode 100644 index 0000000..3375f71 --- /dev/null +++ b/spec/views/category_spec.rb @@ -0,0 +1,56 @@ +require 'rails_helper' + +RSpec.describe 'Categoy', type: :system do + it 'allows a user to successfully sign up' do + visit unauthenticated_root_path + click_link 'SIGN UP' + + fill_in 'Name', with: 'John Doe' + fill_in 'Email', with: 'john.doe@example.com' + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + + click_button 'Next' + + expect(page).to have_content('Welcome! You have signed up successfully.') + expect(page).to have_current_path(authenticated_root_path) + end + + it 'redirects the user to the New Category page after clicking on New category link' do + visit unauthenticated_root_path + click_link 'SIGN UP' + + fill_in 'Name', with: 'John Doe' + fill_in 'Email', with: 'john.doe@example.com' + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + + click_button 'Next' + + expect(page).to have_link('New category') + + click_link 'New category' + expect(page).to have_content('NEW CATEGORY') + expect(page).to have_button('Create Category') + end + + it 'A user can create a new category' do + visit unauthenticated_root_path + click_link 'SIGN UP' + + fill_in 'Name', with: 'John Doe' + fill_in 'Email', with: 'john.doe@example.com' + fill_in 'Password', with: 'password' + fill_in 'Password confirmation', with: 'password' + + click_button 'Next' + + expect(page).to have_link('New category') + + click_link 'New category' + fill_in 'Name', with: 'Food' + fill_in 'Icon', with: 'https://tinyurl.com/jshcp3ce' + click_button 'Create Category' + expect(page).to have_content('Category was successfully created.') + end +end diff --git a/spec/views/entities/edit.html.erb_spec.rb b/spec/views/entities/edit.html.erb_spec.rb deleted file mode 100644 index 08e455f..0000000 --- a/spec/views/entities/edit.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'entities/edit', type: :view do - let(:entity) do - Entity.create!( - name: 'MyString', - amount: '9.99' - ) - end - - before(:each) do - assign(:entity, entity) - end - - it 'renders the edit entity form' do - render - - assert_select 'form[action=?][method=?]', entity_path(entity), 'post' do - assert_select 'input[name=?]', 'entity[name]' - - assert_select 'input[name=?]', 'entity[amount]' - end - end -end diff --git a/spec/views/entities/index.html.erb_spec.rb b/spec/views/entities/index.html.erb_spec.rb deleted file mode 100644 index 5591a92..0000000 --- a/spec/views/entities/index.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'entities/index', type: :view do - before(:each) do - assign(:entities, [ - Entity.create!( - name: 'Name', - amount: '9.99' - ), - Entity.create!( - name: 'Name', - amount: '9.99' - ) - ]) - end - - it 'renders a list of entities' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - assert_select cell_selector, text: Regexp.new('9.99'.to_s), count: 2 - end -end diff --git a/spec/views/entities/new.html.erb_spec.rb b/spec/views/entities/new.html.erb_spec.rb deleted file mode 100644 index 8f9d8fe..0000000 --- a/spec/views/entities/new.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'entities/new', type: :view do - before(:each) do - assign(:entity, Entity.new( - name: 'MyString', - amount: '9.99' - )) - end - - it 'renders new entity form' do - render - - assert_select 'form[action=?][method=?]', entities_path, 'post' do - assert_select 'input[name=?]', 'entity[name]' - - assert_select 'input[name=?]', 'entity[amount]' - end - end -end diff --git a/spec/views/entities/show.html.erb_spec.rb b/spec/views/entities/show.html.erb_spec.rb deleted file mode 100644 index 4ab38b1..0000000 --- a/spec/views/entities/show.html.erb_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'entities/show', type: :view do - before(:each) do - assign(:entity, Entity.create!( - name: 'Name', - amount: '9.99' - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - expect(rendered).to match(/9.99/) - end -end diff --git a/spec/views/users/edit.html.erb_spec.rb b/spec/views/users/edit.html.erb_spec.rb deleted file mode 100644 index da88d16..0000000 --- a/spec/views/users/edit.html.erb_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/edit', type: :view do - let(:user) do - User.create!( - name: 'MyString' - ) - end - - before(:each) do - assign(:user, user) - end - - it 'renders the edit user form' do - render - - assert_select 'form[action=?][method=?]', user_path(user), 'post' do - assert_select 'input[name=?]', 'user[name]' - end - end -end diff --git a/spec/views/users/index.html.erb_spec.rb b/spec/views/users/index.html.erb_spec.rb deleted file mode 100644 index 4f951b8..0000000 --- a/spec/views/users/index.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/index', type: :view do - before(:each) do - assign(:users, [ - User.create!( - name: 'Name' - ), - User.create!( - name: 'Name' - ) - ]) - end - - it 'renders a list of users' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - end -end diff --git a/spec/views/users/new.html.erb_spec.rb b/spec/views/users/new.html.erb_spec.rb deleted file mode 100644 index 79751dc..0000000 --- a/spec/views/users/new.html.erb_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/new', type: :view do - before(:each) do - assign(:user, User.new( - name: 'MyString' - )) - end - - it 'renders new user form' do - render - - assert_select 'form[action=?][method=?]', users_path, 'post' do - assert_select 'input[name=?]', 'user[name]' - end - end -end diff --git a/spec/views/users/show.html.erb_spec.rb b/spec/views/users/show.html.erb_spec.rb deleted file mode 100644 index e44cd05..0000000 --- a/spec/views/users/show.html.erb_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/show', type: :view do - before(:each) do - assign(:user, User.create!( - name: 'Name' - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - end -end