-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
112 additions
and
13 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
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
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
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
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
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
2 changes: 1 addition & 1 deletion
2
spec/dummy/db/migrate/20241022111111_create_authors_and_posts.rb
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
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
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
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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe "Hotsheet::Configuration" do | ||
let(:config) do | ||
Hotsheet.configure do |config| | ||
config.model :User do |model| | ||
model.included_attributes = %i[name birthdate] | ||
model.excluded_attributes = %i[created_at] | ||
end | ||
end | ||
end | ||
|
||
it "has included and excluded attributes" do | ||
expect(config).to be_a Hotsheet::Configuration::ModelConfig | ||
expect(config.included_attributes).to eq %i[name birthdate] | ||
expect(config.excluded_attributes).to eq %i[created_at] | ||
end | ||
|
||
it "doesn't have any other model configs" do # rubocop:disable RSpec/ExampleLength | ||
expect do | ||
Hotsheet.configure do |config| | ||
config.model :User do |model| | ||
model.attributes = %i[name birthdate] | ||
end | ||
end | ||
end.to raise_error NoMethodError | ||
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
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,19 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
ENV["RAILS_ENV"] = "test" | ||
DRIVER = ENV.fetch("SELENIUM_DRIVER", "firefox_headless").to_sym | ||
|
||
require_relative "../config/environment" | ||
require "database_cleaner-active_record" | ||
require "rspec/rails" | ||
require_relative "config/environment" | ||
require "selenium-webdriver" | ||
|
||
%i[firefox firefox_headless].each do |driver| | ||
Capybara.register_driver driver do |app| | ||
args = ["--headless"] if driver == :firefox_headless | ||
options = Selenium::WebDriver::Firefox::Options.new args: args | ||
Capybara::Selenium::Driver.new app, browser: :firefox, options: options | ||
end | ||
end | ||
|
||
Capybara.default_driver = :rack_test | ||
Capybara.javascript_driver = DRIVER | ||
ActiveRecord::Migration.maintain_test_schema! | ||
|
||
RSpec.configure do |config| | ||
Kernel.srand config.seed | ||
|
||
config.include Capybara::DSL | ||
|
||
config.disable_monkey_patching! | ||
config.filter_rails_from_backtrace! | ||
config.infer_spec_type_from_file_location! | ||
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true } | ||
config.order = :random | ||
config.run_all_when_everything_filtered = true | ||
|
||
config.before :all, type: :system do | ||
FileUtils.rm_rf Rails.root.join "tmp/capybara" | ||
driven_by DRIVER, screen_size: [1280, 800] | ||
end | ||
|
||
config.before :each, type: :system do | ||
DatabaseCleaner.clean_with :truncation | ||
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe "Hotsheet::PagesController", :js do | ||
let!(:author) { Author.create! name: "Stephen", birthdate: "1947-09-21", gender: "male" } | ||
|
||
describe "update strings" do | ||
before do | ||
visit "/hotsheet" | ||
click_link "Author" | ||
end | ||
|
||
it "can edit attributes" do | ||
find(".readonly-attribute", text: "Stephen").click | ||
fill_in "author_name", with: "King" | ||
find_by_id("author_name").native.send_keys :return | ||
|
||
expect(page).to have_content("King") | ||
expect(author.reload.name).to eq("King") | ||
end | ||
end | ||
end |