Giter Site home page Giter Site logo

cucumber.el's People

Contributors

antifuchs avatar avsej avatar bedfordwest avatar bitdeli-chef avatar csw avatar david avatar deets avatar dependabot[bot] avatar dgtized avatar dustin avatar gimbo avatar hardbap avatar hron avatar jcarlos avatar jesg avatar joahking avatar kaofelix avatar kelsin avatar lazyatom avatar ldeck avatar mar-kolya avatar michael-sharewayz avatar michaelklishin avatar oggy avatar sishen avatar skumagai avatar sub avatar terotil avatar timcharper avatar toctan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cucumber.el's Issues

Can't run cucumber in an existing container

Hello
I'm working with a dockerized ruby on rails application.
is there a way to run a cucumber scenario through the command C-c ,s in the existing docker container?
The docker-compose command use for the mode is run, when actually I need exec.

I set the variable feature-docker-compose-command to "docker-compose exec -it".
But the command triggered for the feature-mode is: docker-compose exec -it run [CONTAINER_NAME]
it should be docker-compose exec -it [CONTAINER_NAME].

Thanks in advance.

Ruby Parser requirement requires Ruby outside of EOL

tl;dr Let's update the find_step.rb script instead of requiring very old ruby versions. It's easy to fix up!

Hello, I use cucumber within Spacemacs

In GNU Emacs 29.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
 Version 10.14.6 (Build 18G9323)) of 2023-08-17 built on
 builder10-14.lan
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.3.1

And would like to use the feature-goto-step-definition function. But it requires

gem 'ruby_parser', "~> 3.14.2"
gem 'cucumber-gherkin', "14.0.1"

And when I try to install that version of the ruby parser I get

~/Code/theapp (main)$ gem install ruby_parser -v 3.14.2
ERROR:  Error installing ruby_parser:
	ruby_parser-3.14.2 requires Ruby version ~> 2.2. The current ruby version is 3.1.4.

I didn't want to install such an old version of Ruby, but I tried anyway, but the build failed (I tried a few minor versions too)

WARNING: ruby-2.2.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew

BUILD FAILED (macOS 13.3.1 using ruby-build 20230428)

Inspect or clean up the working tree at /var/folders/3y/6_str63x5y951rxczj0939pr0000gn/T/ruby-build.20231026114030.41789.DjdOo0
Results logged to /var/folders/3y/6_str63x5y951rxczj0939pr0000gn/T/ruby-build.20231026114030.41789.log

Anyway, after that I failed I decided to just fix up the find_step script in my emacs packages directory and it was pretty easy.

After removing the version requirements for gherkin and ruby parser, simply change @ast[:feature] to @ast.feature and change node.try(:examples) to node.respond_to?(:examples) && node&.examples and the package works again for me!

e.g.

  def step_at(line)
    @ast.feature.children.each do |element|
      node = element.scenario || element.background
      next unless node

      node.steps.each do |step|
        next unless step.location.line == line

        return step_result(step, node)
      end
    end
    nil
  end

  # Return hash of step info
  def step_result(step, node)
    result = { 'name' => step.text }
    return result unless node.respond_to?(:examples) && node&.examples

    return result if node.examples[0].nil?

    add_example_info(node, result)
  end

I hope that helps someone who might be coming here trying to get this package to work without ruby 2.2

"the" snippet is very annoying

I have yasnippet set to trigger on space, which makes the "the" snippet extremely annoying. I can't find anyway to prevent feature-mode snippets from being loaded. I think it would be best to at least allow me to opt out of using the snippets since I might have my own.

Incidentally, since the directory is not added to yas/root-directory, doing a yas/reload-all will mean they are not loaded which is how I work around this.

Keybindings to add/navigate steps

It would be really good if there was a way to add the various gherkin keywords in the feature file and also navigate between features (a la org-mode's navigation between headings).

I added some keybindings to my local emacs for the main keywords, but would it be a good idea to have it as a part of the mode itself?

(defun feature-add-keyword (keyword)
  (indent-new-comment-line)
  (insert keyword)
  (indent-according-to-mode)
  )

(defun feature-add-given ()
  (interactive)
  (feature-add-keyword "Given")
  )


(defun feature-add-when ()
  (interactive)
  (feature-add-keyword "When")
  )

(defun feature-add-and ()
  (interactive)
  (feature-add-keyword "And")
  )

(defun feature-add-but ()
  (interactive)
  (feature-add-keyword "But")
  )

(defun feature-add-then ()
  (interactive)
  (feature-add-keyword "Then")
  )

(defun feature-add-scenario ()
  (interactive)
  (indent-new-comment-line)
  (feature-add-keyword "Scenario:")
  )

(defun feature-add-feature ()
  (interactive)
  (feature-add-keyword "Feature:")
  )

(defun feature-add-scenario-outline ()
  (interactive)
  (indent-new-comment-line)
  (feature-add-keyword "Scenario Outline:")
  )

(defun feature-add-examples ()
  (interactive)
  (indent-new-comment-line)
  (feature-add-keyword "Examples:")
  (indent-new-comment-line)
  (insert "||")
  (backward-char)
  )

(add-hook 'feature-mode-hook
          (lambda ()
            (local-set-key (kbd "C-c i g") 'feature-add-given)
            (local-set-key (kbd "C-c i w") 'feature-add-when)
            (local-set-key (kbd "C-c i a") 'feature-add-and)
            (local-set-key (kbd "C-c i b") 'feature-add-but)
            (local-set-key (kbd "C-c i t") 'feature-add-then)
            (local-set-key (kbd "C-c i s") 'feature-add-scenario)
            (local-set-key (kbd "C-c i f") 'feature-add-feature)
            (local-set-key (kbd "C-c i o") 'feature-add-scenario-outline)
            (local-set-key (kbd "C-c i e") 'feature-add-examples)
            )
          )

If path wansn't previously set for emacs, rvm won't get hooked up

Not sure if you should consider it as a bug.

If you're using rvm and multiple ruby versions at a time, AFAIK, inferior shell doesn't hook up all the environment variables.

Solution would be to call
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" &&
(but of course that'd be extremely rvm-specific one) or to use regular shell execution rather than compile command, since it'll hook up all the stuff rvm requires.
I assume that compile was used there for a reason, even though it's not crystal clear for me.

Thanks!

Why does `feature-indent-initial-offset` default to 10?

Using the following example from Cucumber's wiki:

Feature: Search courses
  Courses should be searchable by topic
  Search results should provide the course code

  Scenario: Search by topic
    Given there are 240 courses which do not have the topic "biology"
    And there are 2 courses, A001 and B205, that each have "biology" as one of the topics
    When I search for "biology"
    Then I should see the following courses:
      | Course code |
      | A001        |
      | B205        |

With the default settings, and calling indent-region against the whole file, it ends up looking like this:

          Feature: Search courses
  Courses should be searchable by topic
  Search results should provide the course code

            Scenario: Search by topic
    Given there are 240 courses which do not have the topic "biology"
    And there are 2 courses, A001 and B205, that each have "biology" as one of the topics
    When I search for "biology"
    Then I should see the following courses:
      | Course code |
      | A001        |
      | B205        |

Cucumber table spaces

Hey!

I don't know if it's an upgrade of Cucumber or Emacs, but Cucumber don't accept my tables. It believes that the spaces are underscores. So I get errors such as this:
undefined method `email___________=' for #User:0xb5e0d8e0 (NoMethodError)

For a table like this:
And the following user exist:
| email | password |
| [email protected] | password |

If I remove all the spaces it works fine.

Anyone else with this problem?

Inconsistent alignment in tables

I can't quite figure out how it happens, but sometimes columns get left aligned automatically, and other times they get right aligned. It definitely right aligns when doing C-m to move to a new row. Sometimes it left aligns when tabbing from column to column.

I can't explain why it doesn't always left align, however.

For instance, I currently have these steps in the same scenario:

And there is a "Photo" with the following:
| image | zurich_pichur2.jpg |
| album_id | 1 |
| user_id | 1 |
| description | This is a super awesome pichur 2 |
And there is a "Photo" with the following:
| image | zurich_pichur.jpg |
| album_id | 1 |
| user_id | 1 |
| description | This is a super awesome pichur |

Note how the first is left aligned, and the second is right aligned.

installing comments may be wrong

Shouldn't the installation comment say this...
(autoload 'feature-mode "cucumber-mode" "Mode for editing cucumber files" t)

rather than this
(autoload 'cucumber-mode "cucumber-mode" "Mode for editing cucumber files" t)

The prior works for me the latter gives an error

Default cucumber command assumes project has a Rakefile

The default command doesn't work if you don't have rake setup for a project:

(defcustom feature-cucumber-command "rake cucumber CUCUMBER_OPTS=\"{options}\" FEATURE=\"{feature}\""

This is related to issue #26.

As a point of reference, I have the cucumber command customized to the following for myself:

 '(feature-cucumber-command "bundle exec cucumber {options} \"{feature}\"")

A project that uses cucumber doesn't have to use Rake as its build system. It's perfectly valid to use other build systems to run cucumber. What this feature mode is giving preference to in its design is cucumber ruby (as opposed to other cucumber implementations). And I think that's ok, although over time it would be nice to add support for cucumber-jvm and others.

But for now, I have some suggestions:

  1. Detect if a Rakefile is in the project root: if so, run a new feature-rake-command, else run feature-cucumber-command
  2. Change feature-cucumber-command to have a default value of cucumber {options} \"{feature}\"
  3. Detect if a Gemfile is in the project root: if so, prepend the run command with bundle exec

How does that sound? If good, I can make the changes.

find_step crash with ruby_parser 2.0

Processing a utf-8 file I got the error message

/home/enrique/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/racc/parser.rb:349:in `on_error': (Racc::ParseError)
parse error on value "ble" (tIDENTIFIER)

So, I install the last ruby_parser version (2.3.1) and all works fine.

Indentation of "nested" steps

This is the actual result of letting feature-mode indent a feature:

Feature: Indentation

  Scenario: Editing a feature file
Given we are in feature-mode
When I press tab
Then code is indented correctly

I'd expect the Given ... When .. Then to be indented on step more than the Scenario.

feature-goto-step-definition in features/ sub-dirs

My Cucumber project has its feature files present in sub-directories within the features/ directory. The goto functionality does not seem to work in this case.

But, if I put a .feature file in feature/foo.feature any implemented step that foo.feature has will be found by the function.

Am I missing a configuration parameter to point to the absolute path of my directory?

Can you help me?

Thanks.

Keyword arguments

I could be wrong but I think instead of this:

(defun feature-run-cucumber (cuke-opts &optional &key feature-file)

you should have written this:

 (defun* feature-run-cucumber (cuke-opts &optional &key feature-file)

Undesired indentation when writing feature

Hello, thanks for the package it's been great so far except for this. I'm having an annoyance with indentation in .feature files, I don't know if this is a feature rather than a bug (see what I did there? 😆). As I write the feature and type RET to get a new line, the feature gets indented like this:

          Feature: manage lessons.

            Scenario: mentor with no lessons attempt to create a lesson.
              Given a new mentor which have no lessons created
              When he submits data to create a new lesson
              Then the lesson is saved and linked to his account.

Note the extra spaces (10 spaces), I would like to get this instead:

Feature: manage lessons.

  Scenario: mentor with no lessons attempt to create a lesson.
    Given a new mentor which have no lessons created
    When he submits data to create a new lesson
    Then the lesson is saved and linked to his account.

What setting could be affecting here?

I hope someone could help. Thanks!

feature-goto-step-definition: An error occured:

Hi, when I invoke feature-goto-step-definition in a folder in my home directory, I get the following error:

An error occurred:
zsh:cd:1: no such file or directory: ~/foofo/calabash/

I narrowed it down to the root argument in your invocation of
shell-command-to-string...
around line 480 or so

(defun feature-goto-step-definition ()
  "Goto the step-definition under (point).  Requires ruby."
  (interactive)
  (let* ((root (feature-project-root))
         (input (thing-at-point 'line))
         (_ (set-text-properties 0 (length input) nil input))
         (result (shell-command-to-string (format "cd %S && ruby %S/find_step.rb %s %s %S"
                                                  root
                                                  feature-support-directory
                                                  (feature-detect-language)
                                                  feature-default-i18n-file
                                                  input)))
         (file-and-line (car (split-string result "\n")))
         (matched? (string-match "^\\(.+\\):\\([0-9]+\\)$" file-and-line)))
    (if matched?
        (let ((file    (format "%s/%s" root (match-string 1 file-and-line)))
              (line-no (string-to-number (match-string 2 file-and-line))))
          (find-file file)
      (goto-char (point-min))
          (forward-line (1- line-no)))
      (if (equal "" result)
          (message "No matching steps found for:\n%s" input)
        (message "An error occurred:\n%s" result)))))

I don't know why but shell-command-to-string takes a "~" in an call like this "literally", instead of substituting it with my home path.

(shell-command-to-string "cd \"~/blah/calabash/\" && ruby \"/home/me/.emacs.d/elpa/feature-mode-20130714.1319/support\"/find_step.rb en /home/me/.emacs.d/elpa/feature-mode-20130714.1319/i18n.yml \"  When I navigate to a category: \\\"zomg\\\"\n\"")

Intersting though, it works when I substitute "~" with "$HOME".
I wrote a temporary ugly fix for this:

(defun root_quirk ()
  (replace-regexp-in-string "~" "$HOME" (feature-project-root))
  )
(defun feature-goto-step-definition ()
  "Goto the step-definition under (point).  Requires ruby."
  (interactive)
  (let* ((root (feature-project-root))
         (input (thing-at-point 'line))
         (_ (set-text-properties 0 (length input) nil input))
         (result (shell-command-to-string (format "cd %S && ruby %S/find_step.rb %s %s %S"
                                                  (root_quirk)
                                                  feature-support-directory
 .....

With this it works as expected, although its a bit ugly, but I don't know enough about elisp to do this properly, not to mention I don't have the time for it. Took me 2 ours to figure this out.
If you think this fix is acceptable I can send you a pull request.

Problem installing on Emacs 23

Hi, first of all I'm pretty aware I might be doing something wrong.

I'm having an error when loading this mode in Emacs 23. This are the steps I've followed:

cd ~/dev/tools/
git clone git://github.com/michaelklishin/cucumber.el.git
cd ~/.emacs.d/
ln -s ~/dev/tools/cucumber.el

Then I've the following to ~/.emacs.d/init.el

(add-to-list 'load-path "~/.emacs.d/cucumber.el/feature-mode")
(require 'feature-mode)
(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode))

When I run Emacs I'm getting an error:

File error: Cannot open load file, feature-mode

Running with the --debug-init flag does not display anything more useful than this.

Any help would be appreciated. Thanks for your time.

Indentation does not work

I wonder whether it is only for me, but automatic indentation does not work.
Nothing happens when TAB key is pressed at the beginning of line.

It works if I revert the commit ac87ba6

Please consider updating the copyright notices to reflect the new mailing address of the Free Software Foundation

The Free Software Foundation is no longer at 675 Mass Ave, Cambridge, MA.

Our new address is 51 Franklin Street, Suite 500, Boston, MA 02110.

You can confirm this for yourself here: http://www.fsf.org/about/contact/

Please update all references to our old address in your code so people can continue to contact us (we haven't been at the old address for more than a decade at this point)

Kind regards,

matt

Matt Lee
Campaigns Manager
Free Software Foundation

Requirements for usage not fully documented

I found out that the mode uses feature-cucumber-command and thus calls 'rake cucumber' to verify tests by default, but I did'nt find anything in the documentation what the expected task should look like for this.

I know I can customize that variable, but I like to always use the default as much has possible, because commonly you get less trouble with it (it's better testet) and the default are normally well thought through.

For example, my rakefile currently uses the following for feature testing:
require "rake"
require 'cucumber'
require 'cucumber/rake/task'
CUKE_RESULTS = 'results.html'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
t.fork = false
end

BTW, the documentation for feature-cucumber-command does not specify how the command should be build. What is {options}, what {feature}, are they required? Does the order matter? I can guess, read lisp code (what I did :-) ) or do a trial-and-error to find out...

Byte compilation warnings

feature-mode.el:101:2: Warning: custom-declare-variable
    `feature-enable-back-denting' docstring wider than 80 characters

In given-when-then-wordlength:
feature-mode.el:372:14: Warning: ‘some’ is an obsolete function (as of 27.1);
    use ‘cl-some’ instead.

In compute-given-when-then-offset:
feature-mode.el:380:15: Warning: assignment to free variable
    ‘current-word-length’
feature-mode.el:384:17: Warning: reference to free variable
    ‘current-word-length’
feature-mode.el:391:35: Warning: assignment to free variable
    ‘search-word-length’
feature-mode.el:393:37: Warning: reference to free variable
    ‘search-word-length’
feature-mode.el:394:67: Warning: reference to free variable ‘search’
feature-mode.el:395:21: Warning: assignment to free variable
    ‘previous-lengths’
feature-mode.el:397:30: Warning: reference to free variable ‘previous-lengths’
feature-mode.el:619:4: Warning: ‘yas/load-directory’ is an obsolete function
    (as of yasnippet 0.8); use ‘yas-load-directory’ instead.

In feature-verify-scenario-at-pos:
feature-mode.el:629:2: Warning: docstring wider than 80 characters
feature-mode.el:683:2: Warning: ‘defun*’ is an obsolete alias (as of 27.1);
    use ‘cl-defun’ instead.

In feature-project-root:
feature-mode.el:710:2: Warning: docstring wider than 80 characters

In end of data:
feature-mode.el:703:12: Warning: the function ‘chruby-use-corresponding’ is
    not known to be defined.
feature-mode.el:701:12: Warning: the function
    ‘rvm-activate-corresponding-ruby’ is not known to be defined.
feature-mode.el:576:4: Warning: the function ‘turn-on-orgtbl’ is not known to
    be defined.

Make package available via MELPA stable

Hi friends,

MELPA Stable is the new younger sibling of MELPA for users who'd rather run only stable versions of packages (MELPA can be a bit rocky since every commit comprises a new release), and it would be super cool if cucumber.el could be installed via Stable.

Fortunately it's also really easy to support—all you have to do is define a tag in the v... format and you're done. I'd submit a PR if I could, but since tags are global to a project, that's not something possible via PR.

If you're cool with this idea, this should be all you have to do to make it happen:

$ git tag v0.4 4bd8f19da816115094beb4b0e085822eb298ac37
$ git push origin v0.4

(Of course, confirm that 4bd8f19 is the appropriate commit for the release, but it's the one where the version number was bumped to 0.4 so I suspect it is.)

Thanks for your time and consideration!

Java support

Hi, thanks for the package. Do you plan to add support for Java?

Gherkin 8 updates

With the release of Gherkin 8 and Cucumbers using it, i18n.yml will need to be updated to support the new keywords.

Bug at highlighting when a keyword is a prefix of another keyword

When a keyword is a prefix to another keyword, the longer keyword does not get fully highlighted.

Example: in Portuguese the keyword 'E' (And) is a prefix of the keyword 'Então' (Then). Also, 'And' happens before 'Then' on the keyword name list, so when using feature-mode in Portuguese, only the letter 'E' gets highlighted when I insert 'Então'.

I think that sorting the keywords making the longer first is a proper way to fix. I would submit a PR, but my lisp is very poor, so I'm going to paste how I got it to work.

feature-mode.el
439c439,442
<     result-keywords))

---
>     (sort result-keywords 'longer-first)))
> 
> (defun longer-first (a b)
>   (> (length (car a)) (length (car b))))

rspec-parent-directory

when I run C-c ,v in an features buffer I get :

equal: Symbol's function definition is void: rspec-parent-directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.