Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created December 27, 2012 14:55
Show Gist options
  • Save jimweirich/4388888 to your computer and use it in GitHub Desktop.
Save jimweirich/4388888 to your computer and use it in GitHub Desktop.
Experimental version of RSpec/Given that handles should-less assertions (i.e. plain Ruby conditions).
1) Natural Assertions
Failure/Error: Then { foo + bar == 2 }
Then expression failed at /Users/jim/working/git/rspec-given/examples/failing/sample_spec.rb:6
expected: 3
to equal: 2
false <- foo + bar == 2
3 <- foo + bar
1 <- foo
2 <- bar
# ./lib/rspec/given/extensions.rb:64:in `_rg_evaluate'
# ./lib/rspec/given/extensions.rb:56:in `_rg_then'
# ./examples/failing/sample_spec.rb:6:in `block in Then'
require 'rspec/given'
describe "Natural Assertions" do
Given(:foo) { 1 }
Given(:bar) { 2 }
Then { foo + bar == 2 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment