Skip to content

Commit

Permalink
Install capybara
Browse files Browse the repository at this point in the history
This helps make feature specs usable right from the very beginning, and will allow us to remove a bunch of manual setup instructions from our getting started guide for 2.1.
  • Loading branch information
timriley committed Nov 4, 2023
1 parent 06ddfb0 commit 03d8af2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/hanami/rspec/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def call(*, **)
copy_dotrspec
copy_spec_helper
copy_support_rspec
copy_support_features
copy_support_requests

generate_request_spec
Expand Down Expand Up @@ -54,6 +55,13 @@ def copy_support_rspec
)
end

def copy_support_features
fs.cp(
fs.expand_path(fs.join("generators", "support_features.rb"), __dir__),
fs.expand_path(fs.join("spec", "support", "features.rb"))
)
end

def copy_support_requests
fs.cp(
fs.expand_path(fs.join("generators", "support_requests.rb"), __dir__),
Expand Down
1 change: 1 addition & 0 deletions lib/hanami/rspec/generators/gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

group :test do
gem "capybara"
gem "rack-test"
end
1 change: 1 addition & 0 deletions lib/hanami/rspec/generators/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
require "hanami/prepare"

require_relative "support/rspec"
require_relative "support/features"
require_relative "support/requests"
5 changes: 5 additions & 0 deletions lib/hanami/rspec/generators/support_features.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require "capybara/rspec"

Capybara.app = Hanami.app
12 changes: 12 additions & 0 deletions spec/unit/hanami/rspec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# Gemfile
gemfile = <<~EOF
group :test do
gem "capybara"
gem "rack-test"
end
EOF
Expand All @@ -47,6 +48,7 @@
require "hanami/prepare"
require_relative "support/rspec"
require_relative "support/features"
require_relative "support/requests"
EOF
expect(fs.read("spec/spec_helper.rb")).to eq(spec_helper)
Expand Down Expand Up @@ -83,6 +85,16 @@
EOF
expect(fs.read("spec/support/rspec.rb")).to eq(support_rspec)

# spec/support/features.rb
support_features = <<~EOF
# frozen_string_literal: true
require "capybara/rspec"
Capybara.app = Hanami.app
EOF
expect(fs.read("spec/support/features.rb")).to eq(support_features)

# spec/support/requests.rb
support_requests = <<~EOF
# frozen_string_literal: true
Expand Down

0 comments on commit 03d8af2

Please sign in to comment.