Last active
December 22, 2023 06:17
-
-
Save y0t4/5d8b4ef4462dba7db98e0d6d9c7c2da0 to your computer and use it in GitHub Desktop.
rspec-parameterized使っていてletされた変数へのアクセスで不思議な挙動があったので、その挙動を再現したコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'rspec' | |
gem 'rspec-parameterized' | |
end | |
require 'rspec' | |
require 'rspec-parameterized' | |
# super: no superclass method `foo' for #<RSpec::ExampleGroups::FailureCase::Context1::Context2 (no description provided)> | |
describe "Failure case" do | |
let(:foo) { 'foo' } | |
context 'context1' do | |
let(:bar) { 'bar' } | |
context 'context2' do | |
where(:expected_string) do | |
[ | |
[foo], # ここは ref(:foo) を使わないといけない | |
] | |
end | |
with_them do | |
it "return foo" do | |
expect(foo).to eq expected_string | |
end | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'rspec' | |
gem 'rspec-parameterized' | |
end | |
require 'rspec' | |
require 'rspec-parameterized' | |
describe "Success case" do | |
let(:foo) { 'foo' } | |
context 'context1' do | |
context 'context2' do | |
let(:bar) { 'bar' } | |
where(:expected_string) do | |
[ | |
[foo], # ここは ref(:foo) を使わないといけないはずだが、これでも動く | |
] | |
end | |
with_them do | |
it "return foo" do | |
expect(foo).to eq expected_string | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment