New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chain from() and to() to contain mathcer #32

Merged
merged 1 commit into from Apr 3, 2013

Conversation

Projects
None yet
2 participants
@gongo
Contributor

gongo commented Apr 3, 2013

Support checking contain() matcher within the range specified in the file

e.g.

$ cat Gemfile 

group :test do
  gem 'rspec'
end

group :doc do
  gem 'rdoc'
end
describe 'Gemfile' do
  it { should be_file }

  # check contain this file
  it { should contain 'rspec' }
  it { should contain 'rdoc' }

  # check contain ahead of 'group :test do ; end'
  it { should_not contain('rspec').to(/^group :test do/) }
  it { should_not contain('rdoc').to(/^group :test do/) }

  # check contain behind 'group :test do ; end'
  it { should contain('rspec').from(/^group :test do/) }
  it { should contain('rdoc').from(/^group :test do/) }

  # check contain within 'group :test do ; end'
  it { should contain('rspec').from(/^group :test do/).to(/^end/) }
  it { should_not contain('rdoc').from(/^group :test do/).to(/^end/) }

  # check contain within 'group :doc do ; end'
  it { should_not contain('rspec').from(/^group :doc do/).to(/^end/) }
  it { should contain('rdoc').from(/^group :doc do/).to(/^end/) }
end
@mizzy

This comment has been minimized.

Show comment
Hide comment
@mizzy

mizzy Apr 3, 2013

Owner

This is nice idea.

I think that 'after' and 'before' are more explicit than 'from' and 'to' .

How do you think about it?

Owner

mizzy commented Apr 3, 2013

This is nice idea.

I think that 'after' and 'before' are more explicit than 'from' and 'to' .

How do you think about it?

@gongo

This comment has been minimized.

Show comment
Hide comment
@gongo

gongo Apr 3, 2013

Contributor

I think 'after' and 'before' is good If use separate is the main pattern.
If use at same time is the main pattern, 'from' and 'to'

  it { should contain('hoge').from(/A/).to(/B/) }

  it { should contain('hoge').after(/A/) }
  it { should contain('hoge').before(/B/) }

I think use at the same time will be the main pattern. (e.g. httpd.conf <VirtualHost *:80> .. </Virtualhost> )

Contributor

gongo commented Apr 3, 2013

I think 'after' and 'before' is good If use separate is the main pattern.
If use at same time is the main pattern, 'from' and 'to'

  it { should contain('hoge').from(/A/).to(/B/) }

  it { should contain('hoge').after(/A/) }
  it { should contain('hoge').before(/B/) }

I think use at the same time will be the main pattern. (e.g. httpd.conf <VirtualHost *:80> .. </Virtualhost> )

@mizzy

This comment has been minimized.

Show comment
Hide comment
@mizzy

mizzy Apr 3, 2013

Owner

I think 'after' and 'before' is good If use separate is the main pattern.

Agree.

All patterns are not exclusive, so I will add 'after' and 'before' after merging your code.

Thanks a lot.

Owner

mizzy commented Apr 3, 2013

I think 'after' and 'before' is good If use separate is the main pattern.

Agree.

All patterns are not exclusive, so I will add 'after' and 'before' after merging your code.

Thanks a lot.

mizzy added a commit that referenced this pull request Apr 3, 2013

Merge pull request #32 from gongo/contain_from_to
Add chain from() and to() to contain mathcer

@mizzy mizzy merged commit 6a218b2 into mizzy:master Apr 3, 2013

1 check passed

default The Travis build passed
Details
@gongo

This comment has been minimized.

Show comment
Hide comment
@gongo

gongo Apr 3, 2013

Contributor

thanks!

All patterns are not exclusive, so I will add 'after' and 'before' after merging your code.

yoroshiku onegaishimasu.

Contributor

gongo commented Apr 3, 2013

thanks!

All patterns are not exclusive, so I will add 'after' and 'before' after merging your code.

yoroshiku onegaishimasu.

@gongo gongo deleted the gongo:contain_from_to branch Apr 3, 2013

@mizzy

This comment has been minimized.

Show comment
Hide comment
@mizzy

mizzy Apr 3, 2013

Owner

I've released as v0.1.5.

Thanks a lot! 😄

Owner

mizzy commented Apr 3, 2013

I've released as v0.1.5.

Thanks a lot! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment