This doesn’t work because you’re not registering the example groups you’re
creating with, a simpler way to do this would be:
# spec/support/generate_test_cases.rb
module RSpec
module GenerateTestCases
def generate_test_cases
TestGenerator.new(self).generate_test_cases
end
class TestGenerator < Struct.new(:rspec)
def generate_test_cases
3.times do
rspec.describe "Test Cases" do
example do
expect(1+1).to eq(2)
end
end
end
end
end
end
end
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk
On Thursday, 14 August 2014 at 19:28, siva wrote:
>
> Hi
>
> # spec/support/generate_test_cases.rb
>
> module RSpec
> module GenerateTestCases
>
> def generate_test_cases
> TestGenerator.new.generate_test_cases
> end
>
> class TestGenerator < RSpec::Core::ExampleGroup
> def generate_test_cases
> 3.times do
> TestGenerator.describe "Test Cases" do
> example do
> expect(1+1).to eq(2)
> end
> end
> end
> end
> end
> end
> end
>
> RSpec.configure do |rspec|
> rspec.extend RSpec::GenerateTestCases
> end
>
> RSpec::SharedContext.send(:include, RSpec::GenerateTestCases)
>
> # spec/models/user_spec.rb
>
> RSpec.describe "User" do
> generate_test_cases
> end
>
>
> When I run above test cases it shows 0 examples to run. What I am doing
> wrong? How can I generate multiple test cases? Could help me?
>
> Thanks in advance.
> ~
> --
> 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/cb8b6886-7f33-4dab-870d-73495262c792%40googlegroups.com
>
> (https://groups.google.com/d/msgid/rspec/cb8b6886-7f33-4dab-870d-73495262c792%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/294365122F5A4BD3B61DC0D2242A9FCA%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.