Skip to content

Commit

Permalink
Add tentative test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromedalbert committed Feb 8, 2025
1 parent 2a27128 commit ed8b4cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ 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"

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 "test/factories/users.rb"
And the file "test/factories/users.rb" should contain exactly:
"""
FactoryBot.define do
factory :user do
email_address { "[email protected]" }
password_digest { "MyString" }
end
end
"""
4 changes: 4 additions & 0 deletions features/step_definitions/rails_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
append_to_file("Gemfile", %(gem "#{gem_name}"\n))
end

When(/^I add "([^"]+)" with options `(.+)` as a dependency$/) do |gem_name, options|
append_to_file("Gemfile", %(gem "#{gem_name}", #{options}\n))
end

When(/^I print out "([^"]*)"$/) do |path|
in_current_dir do
File.open(path, "r") do |f|
Expand Down

0 comments on commit ed8b4cf

Please sign in to comment.