-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from Code-the-Dream-School/automate-rspec-testing
Add github action to run rspec on PRs
- Loading branch information
Showing
8 changed files
with
136 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow uses actions that are not certified by GitHub. They are | ||
# provided by a third-party and are governed by separate terms of service, | ||
# privacy policy, and support documentation. | ||
# | ||
# This workflow will install a prebuilt Ruby version, install dependencies, and | ||
# run tests and linters. | ||
name: "Ruby on Rails CI" | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
DB_CONNECTION: sqlite3 | ||
DB_DATABASE: test.sqlite3 | ||
steps: | ||
- name: Create Database | ||
run: touch test.sqlite3 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
# Add or replace dependency steps here | ||
- name: Install Ruby and gems | ||
uses: ruby/setup-ruby@78c01b705fd9d5ad960d432d3a0cfa341d50e410 # v1.179.1 | ||
with: | ||
bundler-cache: true | ||
# Add or replace database setup steps here | ||
- name: Set up database schema | ||
run: bin/rails db:schema:load | ||
# Add or replace test runners here | ||
- name: Run tests | ||
run: bin/rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,4 +75,4 @@ gem "devise", "~> 4.9" | |
|
||
gem "bootstrap", "~> 5.3" | ||
|
||
gem 'sassc-rails' | ||
gem 'sassc-rails' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "comments/edit.html.erb", type: :view do | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let(:comment) { FactoryBot.create(:comment, entry: entry, user: user, text: "Test comment") } | ||
|
||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let!(:comment) { FactoryBot.create(:comment, entry: entry, user: user, text: "Test comment") } | ||
|
||
context "web page text" do | ||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
end | ||
|
||
it "displays the heading" do | ||
expect(rendered).to have_selector("h1", text: "Edit comment") | ||
end | ||
|
||
it "renders the form to edit comment" do | ||
expect(rendered).to have_selector("form[action='#{entry_comment_path(entry, comment)}'][method='post']") | ||
end | ||
|
||
it "pre-fills the text area with the current comment" do | ||
expect(rendered).to have_selector("textarea[name='comment[text]']", text: comment.text) | ||
end | ||
|
||
it "displays the submit button" do | ||
expect(rendered).to have_selector("input[type='submit'][value='Update']") | ||
end | ||
|
||
it "has a link to show the comment" do | ||
expect(rendered).to have_link('Show this comment', href: entry_comments_path(entry, comment)) | ||
end | ||
|
||
it "has a link to go back to the comments index" do | ||
expect(rendered).to have_link('Back to comment', href: entry_comments_path(entry)) | ||
end | ||
end | ||
|
||
it "displays the heading" do | ||
expect(rendered).to have_selector("h1", text: "Edit comment") | ||
end | ||
|
||
it "renders the form to edit comment" do | ||
expect(rendered).to have_selector("form[action='#{entry_comment_path(entry, comment)}'][method='post']") | ||
end | ||
|
||
it "pre-fills the text area with the current comment" do | ||
expect(rendered).to have_selector("textarea[name='comment[text]']", text: comment.text) | ||
end | ||
|
||
it "displays the submit button" do | ||
expect(rendered).to have_selector("input[type='submit'][value='Update']") | ||
end | ||
|
||
it "has a link to show the comment" do | ||
expect(rendered).to have_link('Show this comment', href: entry_comments_path(entry, comment)) | ||
end | ||
|
||
it "has a link to go back to the comments index" do | ||
expect(rendered).to have_link('Back to comment', href: entry_comments_path(entry)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "comments/index.html.erb", type: :view do | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let!(:comments) { FactoryBot.create_list(:comment, 2, entry: entry, user: user) } | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let!(:comments) { FactoryBot.create_list(:comment, 2, entry: entry, user: user) } | ||
|
||
before do | ||
assign(:entry, entry) | ||
assign(:comments, comments) | ||
render | ||
end | ||
context "web page text" do | ||
before do | ||
assign(:entry, entry) | ||
assign(:comments, comments) | ||
render | ||
end | ||
|
||
it "displays the entry" do | ||
expect(rendered).to include(entry.text) | ||
end | ||
it "displays the entry" do | ||
expect(rendered).to include(entry.text) | ||
end | ||
|
||
it "displays all comments for that entry" do | ||
comments.each do |comment| | ||
expect(rendered).to include(comment.user.email) | ||
expect(rendered).to include(comment.text) | ||
it "displays all comments for that entry" do | ||
comments.each do |comment| | ||
expect(rendered).to include(comment.user.email) | ||
expect(rendered).to include(comment.text) | ||
end | ||
end | ||
end | ||
|
||
it "displays a link back to the entry" do | ||
expect(rendered).to have_link("Back to entry", href: entry_path(entry)) | ||
it "displays a link back to the entry" do | ||
expect(rendered).to have_link("Back to entry", href: entry_path(entry)) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "comments/new.html.erb", type: :view do | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let(:comment) { FactoryBot.create(:comment, entry: entry) } | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: user) } | ||
let!(:comment) { FactoryBot.create(:comment, entry: entry) } | ||
|
||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
end | ||
context "web page text" do | ||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
end | ||
|
||
it "displays the new comment form" do | ||
expect(rendered).to have_selector("h1", text: "New comment") | ||
expect(rendered).to render_template(partial: "_form") | ||
end | ||
it "displays the new comment form" do | ||
expect(rendered).to have_selector("h1", text: "New comment") | ||
expect(rendered).to render_template(partial: "_form") | ||
end | ||
|
||
it "renders a link back to comments index" do | ||
expect(rendered).to have_link("Back to comments", href: comments_index_path) | ||
it "renders a link back to comments index" do | ||
expect(rendered).to have_link("Back to comments", href: comments_index_path) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "comments/show.html.erb", type: :view do | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:friend) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: friend) } | ||
let(:comment) { FactoryBot.create(:comment, entry: entry, user: user, text: "Test comment") } | ||
|
||
|
||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
end | ||
|
||
it "displays the comment" do | ||
expect(rendered).to include("Test comment") | ||
end | ||
|
||
it "renders the partial for the comment" do | ||
expect(rendered).to include(comment.text) | ||
end | ||
|
||
it "displays the edit link" do | ||
expect(rendered).to have_link("Edit", href: edit_entry_comment_path(entry, comment)) | ||
end | ||
|
||
it "displays the back to entry link" do | ||
expect(rendered).to have_link("My Entries", href: entries_path) | ||
end | ||
|
||
it "displays my friends entries" do | ||
expect(rendered).to have_link("Friends Entries", href: friend_entries_path) | ||
let(:user) { FactoryBot.create(:user) } | ||
let!(:friend) { FactoryBot.create(:user) } | ||
let(:entry) { FactoryBot.create(:entry, user: friend) } | ||
let!(:comment) { FactoryBot.create(:comment, entry: entry, user: user, text: "Test comment") } | ||
|
||
context "web page text" do | ||
before do | ||
assign(:entry, entry) | ||
assign(:comment, comment) | ||
render | ||
end | ||
|
||
it "displays the comment" do | ||
expect(rendered).to include("Test comment") | ||
end | ||
|
||
it "renders the partial for the comment" do | ||
expect(rendered).to include(comment.text) | ||
end | ||
|
||
it "displays the edit link" do | ||
expect(rendered).to have_link("Edit", href: edit_entry_comment_path(entry, comment)) | ||
end | ||
|
||
it "displays the back to entry link" do | ||
expect(rendered).to have_link("My Entries", href: entries_path) | ||
end | ||
|
||
it "displays my friends entries" do | ||
expect(rendered).to have_link("Friends Entries", href: friend_entries_path) | ||
end | ||
end | ||
end |