Jkingdon/transpec #48

Merged
merged 2 commits into from Feb 4, 2014

Conversation

Projects
None yet
3 participants
@jkingdon
Contributor

jkingdon commented Feb 2, 2014

This converts kochiku to rspec's expect syntax instead of its should syntax. The rationale for doing so is at http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax and can be summarized as "rspec shouldn't be monkey-patching almost every class on the system".

I also turned off should syntax so that future contributors to kochiku will not accidentally use it.

There are two commits; one just contains changes made automatically by the (awesome) tool transpec; the other contains the things I had to manually fix up.

@robolson

jkingdon added some commits Feb 2, 2014

Convert specs to RSpec 2.14.7 syntax with Transpec
This conversion is done by Transpec 1.7.0 with the following command:
    transpec

* 371 conversions
    from: obj.should
      to: expect(obj).to

* 211 conversions
    from: == expected
      to: eq(expected)

* 69 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 34 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 29 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 11 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 3 conversions
    from: =~ [1, 2]
      to: match_array([1, 2])

* 2 conversions
    from: =~ /pattern/
      to: match(/pattern/)
Cleanup after transpec.
Fix some code with .should && <condition> which translated poorly.

Disable should syntax.

Hand-convert a stub in CommandStubber which transpec couldn't do.
@jkingdon

This comment has been minimized.

Show comment
Hide comment
@jkingdon

jkingdon Feb 2, 2014

Contributor

Adding @square/kochiku-contributors because whether to do this might be a matter of opinion.

Contributor

jkingdon commented Feb 2, 2014

Adding @square/kochiku-contributors because whether to do this might be a matter of opinion.

@robolson

This comment has been minimized.

Show comment
Hide comment
@robolson

robolson Feb 3, 2014

Collaborator

I am on-board with this. As long as this doesn't get rejected, we should Transpec kochiku-worker too.

Collaborator

robolson commented Feb 3, 2014

I am on-board with this. As long as this doesn't get rejected, we should Transpec kochiku-worker too.

@yujinakayama

This comment has been minimized.

Show comment
Hide comment
@yujinakayama

yujinakayama Feb 3, 2014

The with taking block without normal arguments is deprecated in RSpec 2.99 and removed in 3.0. In this case you need to remove the .with and use expect in the block.
rspec/rspec-mocks#377

The with taking block without normal arguments is deprecated in RSpec 2.99 and removed in 3.0. In this case you need to remove the .with and use expect in the block.
rspec/rspec-mocks#377

@yujinakayama

This comment has been minimized.

Show comment
Hide comment
@yujinakayama

yujinakayama Feb 3, 2014

You may want to add the following configuration also to disable stub and should_receive:

config.mock_with :rspec do |c|
  c.syntax = :expect
end

You may want to add the following configuration also to disable stub and should_receive:

config.mock_with :rspec do |c|
  c.syntax = :expect
end
@yujinakayama

This comment has been minimized.

Show comment
Hide comment
@yujinakayama

yujinakayama Feb 3, 2014

And thank you for using Transpec. :)

And thank you for using Transpec. :)

@jkingdon

This comment has been minimized.

Show comment
Hide comment
@jkingdon

jkingdon Feb 4, 2014

Contributor

Merging because feedback is positive and it is the Right Thing.

Will address the thing about .with in a separate pull request.

Contributor

jkingdon commented Feb 4, 2014

Merging because feedback is positive and it is the Right Thing.

Will address the thing about .with in a separate pull request.

jkingdon added a commit that referenced this pull request Feb 4, 2014

@jkingdon jkingdon merged commit 3b7e044 into master Feb 4, 2014

@jkingdon jkingdon deleted the jkingdon/transpec branch Feb 4, 2014

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