The inside of describe / context block are the insides of classes so you have
to use class level methods / module functions. You could easily write code to
load this from a file. e.g.
module Support
def self.load_sentence_cycle
JSON.parse File.read(‘spec/support/sentence.json’)
end
end
RSpec.describe ‘test’ do
Support.load_sentence_cycle.each do |key, value|
...
end
end
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk
On Thursday, 16 March 2017 at 09:00, Alexey Zenovich wrote:
> Hi all!
>
> I want to test my parse sentence module using a lot of examples. I know that
> I can create cycle in rspec as
>
> describe ".test" do
> {"a" => "a", "b" => "b", "c" => "c"}.each do |m, e|
> it "#{m} to be equal #{a}" do
> expect(m).to eq(e)
> end
> end
> end
>
> Does exist any method to load test cases ({"a" => "a", "b" => "b", "c" =>
> "c"}) from file or from method? Helper metods are unavailable in
> describe/context blocks.
> I don't want to do it in one `it` block as one test.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> (mailto:[email protected]).
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/21381216-c419-47b5-8fe9-7cfe6a07ffea%40googlegroups.com
>
> (https://groups.google.com/d/msgid/rspec/21381216-c419-47b5-8fe9-7cfe6a07ffea%40googlegroups.com?utm_medium=email&utm_source=footer).
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/AD248DE82A954257A29A6BE3391867DA%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.