Skip to content

Instantly share code, notes, and snippets.

@ktusznio
Created January 25, 2013 03:26
Show Gist options
  • Save ktusznio/4631488 to your computer and use it in GitHub Desktop.
Save ktusznio/4631488 to your computer and use it in GitHub Desktop.
Break a big object up into smaller dependencies that are defined per context. This avoids redefining the big object for each context.
describe Foo do
let(:big_params) do
{
foo: foo,
name: "name",
...
}
end
let(:foo) { nil }
context "case a" do
let(:foo) { :a }
it "test 1" do
big_params[:foo] # => :a
end
it "test 2" do
big_params[:foo] # => :a
end
end
context "case b" do
let(:foo) { :b }
it "test 1" do
big_params[:foo] # => :b
end
it "test 2" do
big_params[:foo] # => :b
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment