Skip to content

Commit 367280f

Browse files
committed
migrate from rspec_fixtures to rspec_approvals
1 parent 189ff7b commit 367280f

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
gem 'byebug'
44
gem 'lp'
55
gem 'rspec'
6-
gem 'rspec_fixtures'
6+
gem 'rspec_approvals'
77
gem 'runfile'
88
gem 'runfile-tasks'
99
gem 'simplecov'

spec/bashly/bin_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
subject { CLI.runner }
55

66
it "shows list of commands" do
7-
expect{ subject.run }.to output_fixture('cli/commands')
7+
expect{ subject.run }.to output_approval('cli/commands')
88
end
99

1010
context "on error" do
1111
it "displays it nicely" do
12-
expect(`bin/bashly generate 2>&1`).to match_fixture('cli/error')
12+
expect(`bin/bashly generate 2>&1`).to match_approval('cli/error')
1313
end
1414
end
1515
end

spec/bashly/commands/add_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
context "with --help" do
99
it "shows long usage" do
10-
expect{ subject.run %w[add --help] }.to output_fixture('cli/add/help')
10+
expect{ subject.run %w[add --help] }.to output_approval('cli/add/help')
1111
end
1212
end
1313

1414
context "without arguments" do
1515
it "shows long usage" do
16-
expect{ subject.run %w[add] }.to output_fixture('cli/generate/usage')
16+
expect{ subject.run %w[add] }.to output_approval('cli/generate/usage')
1717
end
1818
end
1919

@@ -25,7 +25,7 @@
2525
end
2626

2727
it "copies the strings configuration to the user space" do
28-
expect { subject.run %w[add strings] }.to output_fixture('cli/add/strings')
28+
expect { subject.run %w[add strings] }.to output_approval('cli/add/strings')
2929
expect(File).to exist(strings_file)
3030
end
3131

@@ -41,8 +41,8 @@
4141

4242
context "when the file exists" do
4343
it "skips copying it" do
44-
expect { subject.run %w[add strings] }.to output_fixture('cli/add/strings')
45-
expect { subject.run %w[add strings] }.to output_fixture('cli/add/strings-exist')
44+
expect { subject.run %w[add strings] }.to output_approval('cli/add/strings')
45+
expect { subject.run %w[add strings] }.to output_approval('cli/add/strings-exist')
4646
end
4747
end
4848
end
@@ -55,7 +55,7 @@
5555
end
5656

5757
it "copies a sample function to the user space under lib directory" do
58-
expect { subject.run %w[add lib] }.to output_fixture('cli/add/lib')
58+
expect { subject.run %w[add lib] }.to output_approval('cli/add/lib')
5959
expect(File).to exist(lib_file)
6060
end
6161
end
@@ -68,7 +68,7 @@
6868
end
6969

7070
it "copies the config.sh lib file to the user space" do
71-
expect { subject.run %w[add config] }.to output_fixture('cli/add/config')
71+
expect { subject.run %w[add config] }.to output_approval('cli/add/config')
7272
expect(File).to exist(lib_file)
7373
end
7474
end
@@ -81,7 +81,7 @@
8181
end
8282

8383
it "copies the yaml.sh lib file to the user space" do
84-
expect { subject.run %w[add yaml] }.to output_fixture('cli/add/yaml')
84+
expect { subject.run %w[add yaml] }.to output_approval('cli/add/yaml')
8585
expect(File).to exist(lib_file)
8686
end
8787
end
@@ -94,7 +94,7 @@
9494
end
9595

9696
it "copies the colors.sh lib file to the user space" do
97-
expect { subject.run %w[add colors] }.to output_fixture('cli/add/colors')
97+
expect { subject.run %w[add colors] }.to output_approval('cli/add/colors')
9898
expect(File).to exist(lib_file)
9999
end
100100
end

spec/bashly/commands/generate_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
context "with --help" do
99
it "shows long usage" do
10-
expect{ subject.run %w[generate --help] }.to output_fixture('cli/generate/help')
10+
expect{ subject.run %w[generate --help] }.to output_approval('cli/generate/help')
1111
end
1212
end
1313

@@ -21,18 +21,18 @@
2121
end
2222

2323
it "generates the cli script" do
24-
expect { subject.run %w[generate] }.to output_fixture('cli/generate/no-args')
24+
expect { subject.run %w[generate] }.to output_approval('cli/generate/no-args')
2525
expect(File).to exist(cli_script)
2626
end
2727

2828
context "when source files already exist" do
2929
before do
30-
expect { subject.run %w[generate] }.to output_fixture('cli/generate/no-args')
30+
expect { subject.run %w[generate] }.to output_approval('cli/generate/no-args')
3131
File.write "#{source_dir}/cli_get_command.sh", "some new user content"
3232
end
3333

3434
it "does not overwrite them" do
35-
expect { subject.run %w[generate] }.to output_fixture('cli/generate/no-args-skip')
35+
expect { subject.run %w[generate] }.to output_approval('cli/generate/no-args-skip')
3636
expect(File.read "#{source_dir}/cli_get_command.sh").to eq "some new user content"
3737
end
3838
end
@@ -45,7 +45,7 @@
4545
end
4646

4747
it "generates the cli script" do
48-
expect { subject.run %w[generate] }.to output_fixture('cli/generate/minimal')
48+
expect { subject.run %w[generate] }.to output_approval('cli/generate/minimal')
4949
expect(File).to exist(cli_script)
5050
end
5151
end

spec/bashly/commands/init_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
context "with --help" do
88
it "shows long usage" do
9-
expect{ subject.run %w[init --help] }.to output_fixture('cli/init/help')
9+
expect{ subject.run %w[init --help] }.to output_approval('cli/init/help')
1010
end
1111
end
1212

@@ -17,7 +17,7 @@
1717
let(:template) { File.read template_file }
1818

1919
it "creates a new workspace" do
20-
expect{ subject.run %w[init] }.to output_fixture('cli/init/no-args')
20+
expect{ subject.run %w[init] }.to output_approval('cli/init/no-args')
2121
expect(File).to exist(config_file)
2222
expect(File.read config_file).to eq template
2323
end
@@ -38,7 +38,7 @@
3838
let(:template) { File.read template_file }
3939

4040
it "creates a new workspace using the minimal config" do
41-
expect{ subject.run %w[init --minimal] }.to output_fixture('cli/init/minimal')
41+
expect{ subject.run %w[init --minimal] }.to output_approval('cli/init/minimal')
4242
expect(File).to exist(config_file)
4343
expect(File.read config_file).to eq template
4444
end

spec/bashly/commands/preview_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
context "with --help" do
88
it "shows long usage" do
9-
expect{ subject.run %w[preview --help] }.to output_fixture('cli/preview/help')
9+
expect{ subject.run %w[preview --help] }.to output_approval('cli/preview/help')
1010
end
1111
end
1212

@@ -18,7 +18,7 @@
1818
end
1919

2020
it "prints the generated cli script" do
21-
expect { subject.run %w[preview] }.to output_fixture('cli/preview/no-args')
21+
expect { subject.run %w[preview] }.to output_approval('cli/preview/no-args')
2222
.except(/env bash\n.*\nrun "\$@"/m, "env bash\n...\nrun \"\$@\"")
2323
end
2424
end

spec/bashly/integration/examples_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# This was observed in at least these two cases:
3131
# - The "+ ..." shell messages driven by `set -x` have no space
3232
# - The order of our `inspect_args` sometimes differs
33-
expect(output).to match_fixture(approval_name).diff(leeway)
33+
expect(output).to match_approval(approval_name).diff(leeway)
3434
end
3535
end
3636
end

spec/spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@
2323

2424
RSpec.configure do |c|
2525
c.include SpecMixin
26-
c.fixtures_path = "spec/approvals"
2726
c.strip_ansi_escape = true
2827
end

0 commit comments

Comments
 (0)