Skip to content

Commit c3da610

Browse files
committed
updated to latest parser gem
1 parent 5e90583 commit c3da610

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

docs/development-workflow/hyper-spec/03-methods-and-features.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ See the [Client Initialization Options](#client-initialization-options) section
7575

7676
By default the client environment will be reinitialized at the beginning of every spec. If this is not needed you can speed things up by adding the `no_reset` flag to a block of specs.
7777

78-
> Note if you are using `visit` to directly load a page and still want to use methods like `on_client` and the expectation helpers, see the last section on
79-
using visit at the end of this document.
78+
### Known Issues
79+
80+
See the last section below for known issues.
8081

8182
# Details
8283

@@ -442,10 +443,29 @@ The method is typically not needed assuming you are using a multithreaded server
442443

443444
You can resolve this by using the `pause` method in the debug session which will put the server debug session into a non-blocking loop. You can then experiment in the JS console, and when done release the pause by executing `go()` in the *javascript* debug console.
444445

445-
### Using `visit` and the Application Layout
446+
### Known Issues
447+
448+
####Using `visit` and the Application Layout
446449
Currently this is not well integrated (see [issue 398](https://github.com/hyperstack-org/hyperstack/issues/398)). If you want to visit a page on the website
447450
using `visit`, the following will not work: Timecop integration, and the `insert_html` and `before_mount` methods. You will also have to execute this line in your spec:
448451
```ruby
449452
page.instance_variable_set("@hyper_spec_mounted", true)
450453
```
451454
Upvote issue 398 if this presents a big problem for you.
455+
456+
#### Some Complex Expressions Do Not Work
457+
[Issue 127](https://github.com/hyperstack-org/hyperstack/issues/127)
458+
459+
You may get an error like this when running a spec:
460+
461+
```text
462+
(string):1:20: error: unexpected token tOP_ASGN
463+
(string):1: hash.[]("foo") += 1
464+
(string):1:
465+
```
466+
467+
The problem is the unparser incorrectly generates `hash.[]("foo") += 1` instead of `hash['foo'] += 1`.
468+
469+
The good news its pretty easy to find such expressions and replace them with something like
470+
471+
`hash["foo"] = hash["foo"] + 1`

ruby/hyper-spec/hyper-spec.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
3131
# spec.add_dependency 'libv8', '~> 7.3.492.27.1'
3232
spec.add_dependency 'method_source'
3333
spec.add_dependency 'opal', ENV['OPAL_VERSION'] || '>= 0.11.0', '< 2.0'
34-
spec.add_dependency 'parser', '>= 2.3.3.1' # on rails-6 this is now >= 2.3
34+
spec.add_dependency 'parser', '>= 3.0' #'>= 2.3.3.1' # on rails-6 this is now >= 2.3
3535
spec.add_dependency 'rspec'
3636
spec.add_dependency 'selenium-webdriver'
3737
spec.add_dependency 'timecop', '~> 0.8.1'
@@ -56,7 +56,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
5656
spec.add_development_dependency 'rspec-its'
5757
spec.add_development_dependency 'rspec-mocks'
5858
spec.add_development_dependency 'rspec-steps', '~> 2.1.1'
59-
spec.add_development_dependency 'rubocop', '~> 0.51.0'
59+
spec.add_development_dependency 'rubocop' #, '~> 0.51.0'
6060
spec.add_development_dependency 'shoulda'
6161
spec.add_development_dependency 'shoulda-matchers'
6262
spec.add_development_dependency 'spring-commands-rspec'

ruby/hyper-spec/lib/hyper-spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@
3737
nil
3838
end
3939

40-
Parser::Builders::Default.emit_procarg0 = true
40+
# opt-in to most recent AST format:
41+
Parser::Builders::Default.emit_lambda = true
42+
Parser::Builders::Default.emit_procarg0 = true
43+
Parser::Builders::Default.emit_encoding = true
44+
Parser::Builders::Default.emit_index = true
45+
Parser::Builders::Default.emit_arg_inside_procarg0 = true
46+
Parser::Builders::Default.emit_forward_arg = true
47+
Parser::Builders::Default.emit_kwargs = true
48+
Parser::Builders::Default.emit_match_pattern = true
4149

4250
# not available in parser 2.3
4351
if Parser::Builders::Default.respond_to? :emit_arg_inside_procarg0

ruby/hyper-spec/spec/hyper_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ class << self
462462
it 'allows local variables on the client to be set using the with method' do
463463
expect { with_var * 2 }.with(with_var: 4).on_client_to eq(8)
464464
end
465+
466+
it "works with complex expressions" do
467+
expect do
468+
hash = { 'foo' => 1}
469+
hash['foo'] += 1
470+
hash['foo']
471+
end.on_client_to eq(2)
472+
end
465473
end
466474

467475
it "will use the arity_check option" do

0 commit comments

Comments
 (0)