Skip to content

Commit

Permalink
[t1] separate dir for rspec and cucumber coverage; 100% cucumber cove…
Browse files Browse the repository at this point in the history
…rage (#47)

Co-authored-by: Ken Xiong <[email protected]>
  • Loading branch information
KenXiong123 and Ken Xiong authored Nov 2, 2022
1 parent 06f45b7 commit 5bdfae3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions features/create_event.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ Background: events in database
| title | host | rating | event_time | status | joined |
| Enjoy Lunch at Junzi | Daemon Targaryen | 4.9/5.0 | 2022-10-30 00:00:00 UTC | open | 1 |

Scenario: the user logout
Given I logged in as "TestUser"
When I go to the logout page
Then I should be on the welcome page

Scenario: the user doesn't exist
Given I hacked in as "FakeUser"
When I go to the login page
And I press "Login"
Then I should be on the login page
And I should see "User does not exist"

Scenario: the user successfully posts a new event
Given I logged in as "TestUser"
When I go to the post event page
Expand Down
16 changes: 16 additions & 0 deletions features/create_user.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# POC: @jenniferduan45

Feature: Create event
As a user
So that I can create and post a new event

Background: events in database
Given the following events exist:
| title | host | rating | event_time | status | joined |
| Enjoy Lunch at Junzi | Daemon Targaryen | 4.9/5.0 | 2022-10-30 00:00:00 UTC | open | 1 |

Scenario: a new use creates user info
When I go to the new user page
And I press "Create User"
Then I should be on the welcome page

8 changes: 8 additions & 0 deletions features/step_definitions/events_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
click_button "Login"
end

Given /I hacked in as "([^"]*)"$/ do |username|
@user = User.create!({:username => username, :password => 'test'})
visit '/login'
fill_in "username", :with => "foo"
fill_in "password", :with => "foo"
click_button "Login"
end

Given /I hosted the event "([^"]*)"$/ do |title|
Event.create!({:title => title, :host => @user.username, :joined => 0})
end
Expand Down
1 change: 1 addition & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'simplecov'
SimpleCov.start 'rails'
SimpleCov.coverage_dir 'coverage/cucumber'

# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
Expand Down
3 changes: 3 additions & 0 deletions features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def path_to(page_name)
# when /^the (RottenPotatoes )?home\s?page$/ then '/movies'
when /^the home page$/ then '/events'
when /^the search page$/ then '/search'
when /^the login page$/ then '/login'
when /^the logout page$/ then '/logout'
when /^the new user page$/ then '/users/new'
when /^the search result page$/ then '/search_result'
when /^the myEvents page$/ then '/myEvents'
when /^the event detail page of '(.*)'$/ then event_path(Event.find_by(title: $1))
Expand Down
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'simplecov'
require 'support/factory_girl'
SimpleCov.start 'rails'
SimpleCov.coverage_dir 'coverage/rspec'

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
Expand Down

0 comments on commit 5bdfae3

Please sign in to comment.