jimweirich / rspec-given

Given/When/Then keywords for RSpec Specifications
https://github.com/jimweirich/rspec-given
MIT License
653 stars 61 forks source link

Sorcerer error when an array is split over multiple lines #36

Closed adamlogic closed 10 years ago

adamlogic commented 10 years ago
require 'rspec-given'

describe "arrays split over multiple lines" do
  When(:result) { 'anything' }
  Then { result == ['a',
                    'a'] }
end

Running this spec produces the following error:

➔ rspec --color given_spec.rb
F

Failures:

  1) arrays split over multiple lines
     Failure/Error: Then { result == ['a',
     Sorcerer::Resource::NotSexpError:
       Not an S-EXPER: nil
     # ./given_spec.rb:5:in `block in Then'

Finished in 0.00046 seconds
1 example, 1 failure

Running ruby 2.0.0p195, rspec-given 3.4.0

jimweirich commented 10 years ago

RSpec/Given uses simple heuristics to determine the end of a Then clause.

I've changed the code to actually parse the Then line and continue adding lines until we can get an entire parsable expression. Version 3.5.0 (pushed and released) has those changes.

jimweirich commented 10 years ago

Thanks for finding this issue.

adamlogic commented 10 years ago

Thanks, Jim!