Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 64 additions & 62 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionpack (8.0.2)
actionview (= 8.0.2)
activesupport (= 8.0.2)
actionpack (8.0.2.1)
actionview (= 8.0.2.1)
activesupport (= 8.0.2.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actionview (8.0.2)
activesupport (= 8.0.2)
actionview (8.0.2.1)
activesupport (= 8.0.2.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.0.2)
activesupport (= 8.0.2)
activejob (8.0.2.1)
activesupport (= 8.0.2.1)
globalid (>= 0.3.6)
activemodel (8.0.2)
activesupport (= 8.0.2)
activerecord (8.0.2)
activemodel (= 8.0.2)
activesupport (= 8.0.2)
activemodel (8.0.2.1)
activesupport (= 8.0.2.1)
activerecord (8.0.2.1)
activemodel (= 8.0.2.1)
activesupport (= 8.0.2.1)
timeout (>= 0.4.0)
activestorage (8.0.2)
actionpack (= 8.0.2)
activejob (= 8.0.2)
activerecord (= 8.0.2)
activesupport (= 8.0.2)
activestorage (8.0.2.1)
actionpack (= 8.0.2.1)
activejob (= 8.0.2.1)
activerecord (= 8.0.2.1)
activesupport (= 8.0.2.1)
marcel (~> 1.0)
activesupport (8.0.2)
activesupport (8.0.2.1)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -56,90 +56,91 @@ GEM
bundler
rake
thor (>= 0.14.0)
aruba (2.3.0)
aruba (2.3.1)
bundler (>= 1.17, < 3.0)
contracts (>= 0.16.0, < 0.18.0)
cucumber (>= 8.0, < 10.0)
cucumber (>= 8.0, < 11.0)
rspec-expectations (~> 3.4)
thor (~> 1.0)
ast (2.4.3)
base64 (0.3.0)
benchmark (0.4.1)
bigdecimal (3.2.2)
bigdecimal (3.2.2-java)
bigdecimal (3.2.3)
bigdecimal (3.2.3-java)
builder (3.3.0)
concurrent-ruby (1.3.5)
connection_pool (2.5.3)
connection_pool (2.5.4)
contracts (0.17.2)
crass (1.0.6)
cucumber (9.2.1)
cucumber (10.1.0)
base64 (~> 0.2)
builder (~> 3.2)
cucumber-ci-environment (> 9, < 11)
cucumber-core (> 13, < 14)
cucumber-cucumber-expressions (~> 17.0)
cucumber-gherkin (> 24, < 28)
cucumber-core (> 15, < 17)
cucumber-cucumber-expressions (> 17, < 19)
cucumber-html-formatter (> 20.3, < 22)
cucumber-messages (> 19, < 25)
diff-lcs (~> 1.5)
logger (~> 1.6)
mini_mime (~> 1.1)
multi_test (~> 1.1)
sys-uname (~> 1.2)
sys-uname (~> 1.3)
cucumber-ci-environment (10.0.1)
cucumber-core (13.0.3)
cucumber-gherkin (>= 27, < 28)
cucumber-messages (>= 20, < 23)
cucumber-core (15.2.1)
cucumber-gherkin (> 27, < 33)
cucumber-messages (> 26, < 30)
cucumber-tag-expressions (> 5, < 7)
cucumber-cucumber-expressions (17.1.0)
cucumber-cucumber-expressions (18.0.1)
bigdecimal
cucumber-gherkin (27.0.0)
cucumber-messages (>= 19.1.4, < 23)
cucumber-html-formatter (21.10.1)
cucumber-gherkin (32.2.0)
cucumber-messages (> 25, < 28)
cucumber-html-formatter (21.14.0)
cucumber-messages (> 19, < 28)
cucumber-messages (22.0.0)
cucumber-messages (27.2.0)
cucumber-tag-expressions (6.1.2)
date (3.4.1)
date (3.4.1-java)
diff-lcs (1.6.2)
drb (2.2.3)
erb (5.0.1)
erb (5.0.1-java)
erb (5.0.2)
erb (5.0.2-java)
erubi (1.13.1)
factory_bot (6.5.4)
factory_bot (6.5.5)
activesupport (>= 6.1.0)
ffi (1.17.2)
ffi (1.17.2-java)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
io-console (0.8.0)
io-console (0.8.0-java)
io-console (0.8.1)
io-console (0.8.1-java)
irb (1.15.2)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jar-dependencies (0.5.5)
json (2.12.2)
json (2.12.2-java)
json (2.13.2)
json (2.13.2-java)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.24.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
marcel (1.0.4)
memoist3 (1.0.0)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.25.5)
multi_test (1.1.0)
mutex_m (0.3.0)
nokogiri (1.18.8)
nokogiri (1.18.9)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.8-java)
nokogiri (1.18.9-java)
racc (~> 1.4)
parallel (1.27.0)
parser (3.3.8.0)
parser (3.3.9.0)
ast (~> 2.4.1)
racc
pp (0.6.2)
Expand All @@ -154,7 +155,7 @@ GEM
jar-dependencies (>= 0.1.7)
racc (1.8.1)
racc (1.8.1-java)
rack (3.1.16)
rack (3.2.1)
rack-session (2.1.1)
base64 (>= 0.1.0)
rack (>= 3.0.0)
Expand All @@ -169,39 +170,39 @@ GEM
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.0.2)
actionpack (= 8.0.2)
activesupport (= 8.0.2)
railties (8.0.2.1)
actionpack (= 8.0.2.1)
activesupport (= 8.0.2.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.0)
rdoc (6.14.0)
rdoc (6.14.2)
erb
psych (>= 4.0.0)
regexp_parser (2.10.0)
reline (0.6.1)
regexp_parser (2.11.2)
reline (0.6.2)
io-console (~> 0.5)
rspec-core (3.13.4)
rspec-core (3.13.5)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (8.0.0)
rspec-rails (8.0.2)
actionpack (>= 7.2)
activesupport (>= 7.2)
railties (>= 7.2)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.4)
rspec-support (3.13.5)
rubocop (1.75.8)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
Expand All @@ -213,7 +214,7 @@ GEM
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.45.1)
rubocop-ast (1.46.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-performance (1.25.0)
Expand All @@ -222,7 +223,7 @@ GEM
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (1.13.0)
securerandom (0.4.1)
sqlite3 (2.7.0)
sqlite3 (2.7.3)
mini_portile2 (~> 2.8.0)
standard (1.50.0)
language_server-protocol (~> 3.17.0.2)
Expand All @@ -237,13 +238,14 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.25.0)
stringio (3.1.7)
sys-uname (1.3.1)
sys-uname (1.4.1)
ffi (~> 1.1)
thor (1.3.2)
memoist3 (~> 1.0.0)
thor (1.4.0)
timeout (0.4.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
unicode-display_width (3.1.5)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.3)
Expand Down
18 changes: 18 additions & 0 deletions features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,21 @@ Feature:
And I run `bundle exec rails generate model User name:string age:integer` with a clean environment
Then the output should not contain "test/factories/users.rb"
And the output should contain "test/fixtures/users.yml"


@rails_8
Scenario: The factory_bot_rails authentication generator, coupled with rspec-rails, creates a user factory file
When I add "rspec-rails" as a dependency
And I run `bundle install --verbose` with a clean environment
Then the output should contain "rspec-rails"
And I run `bundle exec rails generate authentication` with a clean environment
Then the output should contain "spec/factories/users.rb"
And the file "spec/factories/users.rb" should contain exactly:
"""
FactoryBot.define do
factory :user do
email_address { "[email protected]" }
password { "password" }
end
end
"""
11 changes: 11 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
setup_aruba
end

Before("@rails_8") do
rails_version = Gem::Version.new(
Bundler.load.specs.find { |spec| spec.name == "rails" }&.version.to_s
)
required_version = Gem::Version.new("8.0.0")

if rails_version < required_version
skip_this_scenario("Requires Rails 8.0 or higher (current: #{rails_version})")
end
end

if RUBY_PLATFORM == "java"
Aruba.configure do |config|
config.before_cmd do
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "appraisal"
gem "aruba"
gem "bcrypt", "~> 3.1.7"
gem "brakeman"
gem "byebug"
gem "cucumber"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "generators/factory_bot"
require "generators/factory_bot/model/model_generator"
require "factory_bot_rails"

module FactoryBot
module Generators
FixedAttribute = Struct.new(:name, :default)

class AuthenticationGenerator < ModelGenerator
source_paths << File.join(File.dirname(__FILE__), "../model/templates")

private

def attributes
[
FixedAttribute.new(:email_address, "[email protected]"),
FixedAttribute.new(:password, "password")
]
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

FactoryBot.define do
factory :user do
password { "password123" }
password_confirmation { "password123" }
email_address { "user#{SecureRandom.hex(3)}@example.com" }
end
end
Copy link

@jeromedalbert jeromedalbert Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this file is never used. I made PR #544 to remove it.