Skip to content

Commit 9030b01

Browse files
committed
Add tests to verify install work correctly
1 parent 0410cc6 commit 9030b01

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

lib/hanami/cucumber/support/capybara.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
require "capybara"
44
require "capybara/cucumber"
5+
require "capybara/session"
56

67
Capybara.app = Hanami.app

spec/hanami/commands/install_spec.rb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# frozen_string_literal: true
2+
3+
require "tmpdir"
4+
5+
RSpec.describe Hanami::Cucumber::Commands::Install do
6+
subject(:install) { described_class.new(fs: fs) }
7+
8+
let(:fs) { Dry::Files.new }
9+
let(:dir) { Dir.mktmpdir }
10+
let(:app) { "synth" }
11+
let(:app_name) { "Synth" }
12+
13+
let(:arbitrary_argument) { {} }
14+
15+
before { install.call(arbitrary_argument) }
16+
17+
around do |example|
18+
Dir.chdir(dir) { example.run }
19+
ensure
20+
fs.delete_directory(dir)
21+
end
22+
23+
describe "append to Gemfile" do
24+
subject { fs.read("Gemfile") }
25+
26+
it "is expected to add depend gems" do
27+
is_expected.to include <<~RUBY
28+
group :test do
29+
gem "rack-test"
30+
31+
gem "capybara"
32+
gem "selenium-webdriver"
33+
end
34+
RUBY
35+
end
36+
end
37+
38+
describe "copy config/cucumber.yml" do
39+
subject { fs.read("config/cucumber.yml") }
40+
41+
it "is expected to contains cucumber profile" do
42+
is_expected.to include <<~'YAML'
43+
<%
44+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
45+
rerun = rerun.strip.gsub /\s/, ' '
46+
rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
47+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'"
48+
%>
49+
default: <%= std_opts %> features
50+
wip: --tags @wip:3 --wip features
51+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip'
52+
YAML
53+
end
54+
end
55+
56+
describe "copy features/support/env.rb" do
57+
subject { fs.read("features/support/env.rb") }
58+
59+
it "is expected to require Hanami::Cucumber" do
60+
is_expected.to include <<~RUBY
61+
require "hanami/cucumber"
62+
RUBY
63+
end
64+
end
65+
end

spec/hanami/cucumber_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
RSpec.describe Hanami::Cucumber do
4-
it "has a version number" do
5-
expect(Hanami::Cucumber::VERSION).not_to be nil
4+
it "returns version" do
5+
expect(Hanami::Cucumber::VERSION).to eq("0.1.0")
66
end
77
end

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require "hanami/cucumber"
44

5+
TMP = File.join(Dir.pwd, "tmp")
6+
57
RSpec.configure do |config|
68
# Enable flags like --only-failures and --next-failure
79
config.example_status_persistence_file_path = ".rspec_status"
@@ -12,4 +14,8 @@
1214
config.expect_with :rspec do |c|
1315
c.syntax = :expect
1416
end
17+
18+
config.after do
19+
FileUtils.rm_rf(TMP) if File.directory?(TMP)
20+
end
1521
end

0 commit comments

Comments
 (0)