Skip to content

Commit

Permalink
Cucumber tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
kewinshi committed Jan 24, 2025
1 parent b8506ee commit 42e09d3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 88 deletions.
2 changes: 1 addition & 1 deletion app/views/pages/problem_type_1.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- app/views/pages/problems.html.erb -->
<h1>Problem-type 1</h1>

<%= button_to "Back home", student_home_path, method: :get %>
<%= button_to "Home", student_home_path, method: :get %>

2 changes: 2 additions & 0 deletions app/views/pages/student_home.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<!-- app/views/pages/student_home.html.erb -->
<h1>Student Home</h1>

<%= button_to "Problem-type 1", problem_type_1_path, method: :get %>
6 changes: 6 additions & 0 deletions features/return_home.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Return Home

Scenario: Return Home from the Problem's page
Given I am on the Problem's page
When I click on the "Home" button
Then I should be redirected to the Student Home view
11 changes: 11 additions & 0 deletions features/step_definitions/return_home_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Given('I am on the Problem\'s page') do
visit problem_type_1_path
end

When('I click on the "Home" button') do
click_button('Home')
end

Then('I should be redirected to the Student Home view') do
expect(current_path).to eq(student_home_path)
end
4 changes: 2 additions & 2 deletions spec/features/problems_page_type_1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

expect(page).to have_selector("h1", text: "Problem-type 1")

expect(page).to have_button("Back home")
click_button "Back home"
expect(page).to have_button("Home")
click_button "Home"
expect(current_path).to eq(student_home_path)
end
end
4 changes: 4 additions & 0 deletions spec/features/student_home_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
visit student_home_path

expect(page).to have_selector("h1", text: "Student Home")

click_button "Problem-type 1"
expect(current_path).to eq(problem_type_1_path)

end
end
35 changes: 0 additions & 35 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
<<<<<<< HEAD
abort("The Rails environment is running in production mode!") if Rails.env.production?
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
# that will avoid rails generators crashing because migrations haven't been run yet
# return unless Rails.env.test?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
=======
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!
require 'simplecov'
>>>>>>> bd6bae44ee879d87ccaa170d16ccff8a9ddfebea

# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
Expand Down Expand Up @@ -53,12 +44,6 @@
# You can uncomment this line to turn off ActiveRecord support entirely.
# config.use_active_record = false

<<<<<<< HEAD
# RSpec Rails uses metadata to mix in different behaviours to your tests,
# for example enabling you to call `get` and `post` in request specs. e.g.:
#
# RSpec.describe UsersController, type: :request do
=======
# 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`.
Expand All @@ -67,42 +52,22 @@
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, type: :controller do
>>>>>>> bd6bae44ee879d87ccaa170d16ccff8a9ddfebea
# # ...
# end
#
# The different available types are documented in the features, such as in
<<<<<<< HEAD
# https://rspec.info/features/7-0/rspec-rails
#
# You can also this infer these behaviours automatically by location, e.g.
# /spec/models would pull in the same behaviour as `type: :model` but this
# behaviour is considered legacy and will be removed in a future version.
#
# To enable this behaviour uncomment the line below.
# config.infer_spec_type_from_file_location!
=======
# https://rspec.info/features/6-0/rspec-rails
config.infer_spec_type_from_file_location!
>>>>>>> bd6bae44ee879d87ccaa170d16ccff8a9ddfebea

# 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")
<<<<<<< HEAD
<<<<<<< HEAD
=======
#
=======
#
>>>>>>> 0e821a3a3ed421d7c0118910a07caff90e6cc2d1
SimpleCov.start 'rails' do
add_filter '/spec/'
end

SimpleCov.command_name 'RSpec'
SimpleCov.coverage_dir 'coverage'
SimpleCov.merge_timeout 3600
>>>>>>> bd6bae44ee879d87ccaa170d16ccff8a9ddfebea
end
50 changes: 0 additions & 50 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,55 +50,6 @@
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

<<<<<<< HEAD
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# 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
=======
# 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
Expand Down Expand Up @@ -144,5 +95,4 @@
# # test failures related to randomization by passing the same `--seed` value
# # as the one that triggered the failure.
# Kernel.srand config.seed
>>>>>>> bd6bae44ee879d87ccaa170d16ccff8a9ddfebea
end

0 comments on commit 42e09d3

Please sign in to comment.