Transpec unit #3215

Merged
merged 2 commits into from Mar 14, 2014

Conversation

Projects
None yet
3 participants
@fgrehm
Collaborator

fgrehm commented Mar 14, 2014

So... I was kinda bored today and decided that this would be a nice thing to have in place and ended up converting all of the unit tests syntax to rspec 3, it took me a while but here it is!

Of course that is not true, I just found out about https://github.com/yujinakayama/transpec and was very happy about the results on one of my projects and since I remember seeing some discussion around doing this over here I thought it would be nice to share 馃槂

/cc @phinze @yujinakayama

fgrehm added some commits Mar 14, 2014

Convert specs to RSpec 2.14.8 syntax with Transpec
This conversion is done by Transpec 1.10.2 with the following command:
    transpec test/unit/

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

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

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

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

* 25 conversions
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

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

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

* 3 conversions
    from: Klass.any_instance.should_receive(:message)
      to: expect_any_instance_of(Klass).to receive(:message)
@@ -32,11 +32,11 @@
let(:argv) { ["foo"] }
it "executes the runner with the proper actions" do
- action_runner.should_receive(:run).with do |action, **opts|
+ expect(action_runner).to receive(:run).with { |action, **opts|

This comment has been minimized.

@yujinakayama

yujinakayama Mar 14, 2014

The with taking block without normal arguments has an issue with block forms (that's why Transpec converted the do end to { }), and it's deprecated in RSpec 2.99 then removed in 3.0. In this case you need to remove the .with and the last true in the block.

For more details: rspec/rspec-mocks#377

@yujinakayama

yujinakayama Mar 14, 2014

The with taking block without normal arguments has an issue with block forms (that's why Transpec converted the do end to { }), and it's deprecated in RSpec 2.99 then removed in 3.0. In this case you need to remove the .with and the last true in the block.

For more details: rspec/rspec-mocks#377

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Mar 14, 2014

Member

Whoa. Well that's just crazy and awesome. Yep. Thanks!

Member

mitchellh commented Mar 14, 2014

Whoa. Well that's just crazy and awesome. Yep. Thanks!

mitchellh added a commit that referenced this pull request Mar 14, 2014

@mitchellh mitchellh merged commit 0c805de into hashicorp:master Mar 14, 2014

1 check passed

default The Travis CI build passed
Details
@yujinakayama

This comment has been minimized.

Show comment
Hide comment
@yujinakayama

yujinakayama Mar 14, 2014

Thanks for using Transpec. :)

Thanks for using Transpec. :)

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