Elunit tests on Rinari, failing

9 views
Skip to first unread message

Aleksandar Simic

unread,
Aug 8, 2010, 3:49:31 AM8/8/10
to emacs-o...@googlegroups.com
Hello,

I've been using Rinari for a while and I quite like it. But I found
that I wanted to add some extra features to it.

So I had a look at the test suite in:

rinari/test/init.el

When I eval that buffer, the tests fail.

Have the tests been abandoned or am I running them wrong?

I have all the submodules loaded and Rinari works as expected, its
just these tests that fail. The code is eschulte/rinari master branch.

This is the error:

Loaded suite: rinari-suite

FEEEE

5 tests with 5 failures in 0 seconds.

1) Error: rinari-hooks [/home/alex/dev/emacs/rinari/test/init.el:87]

Message: (error "No buffer named units_controller.rb")

Form: (lambda nil
(save-excursion
(unwind-protect
(progn
(let
((default-directory
(format "%s"
(concat
(file-name-directory
(or load-file-name buffer-file-name))
"rails-app/"))))
(find-file "app/controllers/units_controller.rb")
(assert-that hooks-ran)))
(kill-buffer "units_controller.rb")
(setq hooks-ran nil))))


2) Error: rinari-test-test [/home/alex/dev/emacs/rinari/test/init.el:70]

Message: (wrong-type-argument stringp nil)

Form: (lambda nil
(save-excursion
(let
((default-directory
(format "%s"
(concat
(file-name-directory
(or load-file-name buffer-file-name))
"rails-app/"))))
(find-file "app/controllers/units_controller.rb")
(rinari-test)
(assert-equal
(buffer-name)
"*units_controller_test.rb*")
(assert-equal major-mode 'comint-mode)
(kill-buffer "*units_controller_test.rb*")
(kill-buffer "units_controller_test.rb")
(kill-buffer "units_controller.rb"))))


3) Error: rinari-server-test [/home/alex/dev/emacs/rinari/test/init.el:59]

Message: (wrong-type-argument stringp nil)

Form: (lambda nil
(save-excursion
(let
((default-directory
(format "%s"
(concat
(file-name-directory
(or load-file-name buffer-file-name))
"rails-app/"))))
(rinari-web-server)
(assert-equal
(buffer-name)
"*server*")
(assert-that
(get-buffer-process
(current-buffer)))
(kill-buffer
(current-buffer)))))


4) Error: rinari-console-test [/home/alex/dev/emacs/rinari/test/init.el:48]

Message: (wrong-type-argument stringp nil)

Form: (lambda nil
(save-excursion
(let
((default-directory
(format "%s"
(concat
(file-name-directory
(or load-file-name buffer-file-name))
"rails-app/"))))
(rinari-console)
(assert-equal
(buffer-name)
"*ruby*")
(assert-that
(get-buffer-process
(current-buffer)))
(kill-buffer
(current-buffer)))))


5) Failure: rinari-move-test [/home/alex/dev/emacs/rinari/test/init.el:16]

Message: (elunit-test-failed "1 expected to be 37")

Form: (lambda nil
(save-excursion
(let
((max-lisp-eval-depth 2000)
(rails-root
(format "%s"
(concat
(file-name-directory
(or load-file-name buffer-file-name))
"rails-app/"))))
(flet
((here-to-here
(start func end)
(let
((default-directory rails-root))
(find-file
(car start))
(goto-char
(cdr start))
(rinari-launch)
(eval
(list func))
(assert-equal
(file-name-nondirectory
(car end))
(file-name-nondirectory
(buffer-file-name)))
(assert-equal
(cdr end)
(point))
(kill-buffer
(file-name-nondirectory
(car end)))
(kill-buffer
(file-name-nondirectory
(car start))))))
(here-to-here
'("test/unit/example_test.rb" . 153)
'rinari-find-model
'("app/models/example.rb" . 37))
(here-to-here
'("app/controllers/units_controller.rb" . 52)
'rinari-find-test
'("test/functional/units_controller_test.rb" . 150))
(here-to-here
'("app/controllers/units_controller.rb" . 61)
'rinari-find-view
'("app/views/units/fall.html.erb" . 1))))))


Thanks

Steve Purcell

unread,
Aug 8, 2010, 4:10:33 AM8/8/10
to emacs-o...@googlegroups.com
On 8 Aug 2010, at 08:49, Aleksandar Simic wrote:
> Have the tests been abandoned or am I running them wrong?
>
> I have all the submodules loaded and Rinari works as expected, its
> just these tests that fail. The code is eschulte/rinari master branch.
>
> This is the error:
>
> Loaded suite: rinari-suite
>
> FEEEE


I believe the tests are in a state of disrepair. Johan Andersson ("rejeep" on this list & github) has a branch in his fork dedicated to updating Rinari's tests: http://github.com/rejeep/rinari/tree/testing

-Steve

Aleksandar Simic

unread,
Aug 8, 2010, 4:22:44 AM8/8/10
to Rails On Emacs
I saw that branch but wasn't sure if that is the way to go since
rejeep's branch hasn't been merged into the esculte's master branch.

Steve Purcell

unread,
Aug 8, 2010, 8:51:31 AM8/8/10
to emacs-o...@googlegroups.com
On 8 Aug 2010, at 09:22, Aleksandar Simic wrote:

> On Aug 8, 9:10 am, Steve Purcell <st...@sanityinc.com> wrote:
>> On 8 Aug 2010, at 08:49, Aleksandar Simic wrote:
>>
>>> Have the tests been abandoned or am I running them wrong?
>>

>> I believe the tests are in a state of disrepair. Johan Andersson ("rejeep" on this list & github) has a branch in his fork dedicated to updating Rinari's tests:http://github.com/rejeep/rinari/tree/testing
>>
>
> I saw that branch but wasn't sure if that is the way to go since
> rejeep's branch hasn't been merged into the esculte's master branch.
>

If Johan is happy with his branch, I can merge it into eschulte/master. Otherwise, if your hope is to get your new feature(s) merged into the master repo, then I can only suggest you work around the currently-failing tests. :-/

-Steve

Johan Andersson

unread,
Aug 8, 2010, 1:28:49 PM8/8/10
to emacs-o...@googlegroups.com
Hey,

My branch has some tests but unfortunately I have had little or no time lately to work on it. I do think Rinari needs some testing and when time comes I will implement them.

I haven't asked any of the Rinari maintainers to merge any work I've done so far since I'm not finished. If you think it's better I can do some quick work now to make it possible for a merge with upstream. What do you Rinari maintainers think about that? Maybe it's good to merge since people may be adding other features (with tests) to Rinari and that would then clash with my work. It would be better if the tests would work like they do in my branch.

Steve Purcell

unread,
Aug 8, 2010, 3:22:32 PM8/8/10
to emacs-o...@googlegroups.com
On 8 Aug 2010, at 18:28, Johan Andersson wrote:

Hey,

My branch has some tests but unfortunately I have had little or no time lately to work on it. I do think Rinari needs some testing and when time comes I will implement them.

I haven't asked any of the Rinari maintainers to merge any work I've done so far since I'm not finished. If you think it's better I can do some quick work now to make it possible for a merge with upstream. What do you Rinari maintainers think about that? Maybe it's good to merge since people may be adding other features (with tests) to Rinari and that would then clash with my work. It would be better if the tests would work like they do in my branch.



If the tests in the master repo are really broken, and if it's trivial to set up and run your new tests, then there's nothing to lose by merging your branch. How does the ecukes dependency etc. work?

-Steve

Johan Andersson

unread,
Aug 8, 2010, 3:44:30 PM8/8/10
to emacs-o...@googlegroups.com
The tests in the master repo are very much broken. My tests should work just fine, but they do not cover everything, yet... I have done some refactoring of code when implementing the tests, which I have to make sure does not break anything. When done with that I'll send you a pull request.

Ecukes does not have any dependencies. Everything is written from scratch in Elisp. I do however use Espuds (http://github.com/rejeep/espuds) for step definitions, so that's kind of a dependency.

The plan is that you should only be have to fetch the submodules to run the tests.

Johan Andersson

unread,
Aug 8, 2010, 3:45:58 PM8/8/10
to emacs-o...@googlegroups.com
I also want to update some docs regarding the tests before merging with upstream so that it's easy for people to start developing.

Who's in charge of the Rinari website?

Steve Purcell

unread,
Aug 8, 2010, 4:08:03 PM8/8/10
to emacs-o...@googlegroups.com
Eric, I presume.

Eric Schulte

unread,
Aug 9, 2010, 12:29:29 PM8/9/10
to emacs-o...@googlegroups.com
The docs are defined in the doc/rinari.texi file and are used through
the "doc" commands defined in the Rakefile.

As the documentation is hosted on rubyforge, if you send me your
rubyforge username I can add you as an administrator of the rubyforge
Rinari project -- which will give you permission to update the
documentation among other things.

Best -- Eric

Johan Andersson

unread,
Aug 9, 2010, 1:38:50 PM8/9/10
to emacs-o...@googlegroups.com
My rubyforge username is re-jeep. I'm also going to update some other stuff in the docs, since some are outdated and some missing.

Eric Schulte

unread,
Aug 9, 2010, 1:53:38 PM8/9/10
to emacs-o...@googlegroups.com
Johan Andersson <johan....@gmail.com> writes:

> My rubyforge username is re-jeep.

Excellent, you should now have administrative permissions for the Rinari
project.

> I'm also going to update some other stuff in the docs, since some are
> outdated and some missing.
>

That sounds great, thanks for taking this on.

I've also added you as a project collaborator on github.

Cheers -- Eric

Aleksandar Simic

unread,
Aug 9, 2010, 4:50:23 PM8/9/10
to emacs-o...@googlegroups.com
Hello,

great to see more action on this list.

I've started the thread in order to add some more "jumps" to Rinari,
that I found lacking, but I wanted to have the accompanying tests to
go with the additions.

Played with elunit tests and saw what Johan has done with ecukes, so I
wanted to go with that to re-write the tests.

But going through the archive I saw mentions of what versions of Rails
should Rinari support, so instead of having the sample app under
test/, the test suite could generate a sample rails app in the Before
step and the test suite would then take it from there. Sort of what
you Johan had in your testing branch, but doing it based on the Rails
version installed on the user's machine, as opposed to sticking with a
particular version by default.

Something like this:

(progn (shell-command "rails -v" "*rails-version*")
(switch-to-buffer "*rails-version*")
(goto-char (point-min))
(if (search-forward "Rails 2" (point-max) t)
(progn (kill-buffer "*rails-version*")
(bs-cycle-previous)
(message "yes, found Rails 2"))
(progn (goto-char (point-min))
(if (search-forward "Rails 3" (point-max) t)
(progn (kill-buffer "*rails-version*")
(bs-cycle-previous)
(message "yes, found Rails 3"))
(message "version unknown")))))

Instead of the messages, another shell-command could be run, creating
the app, then setting the rinari-root based on that and then diving
into tests. (Theres some duplication in the above snippet that could
be trimmed down, but you get the idea)

Now, Johan, I see you've deleted your testing branch where you had
some features already. Are you preparing for a re-write of the tests
or ...?

I want to start on the tests, can't promise how far I'll get, but I
don't want to start on it if you are already doing it.


Back to my "jumps", I see that current Rinari has no jumps set up for
rspec factories. So I've added my own (no tests for them) here:

http://github.com/dotemacs/rinari/commit/ab6ec07bd5b27c9a7718829435a6efb30c25fb19

I want to add jumps for cucumber features too, but I thought it would
be good to do it properly with tests and all, which brings me back to
discussion above.

Thanks,
Aleksandar

Johan Andersson

unread,
Aug 10, 2010, 2:14:32 AM8/10/10
to emacs-o...@googlegroups.com
In my Ecukes tests I wanted to generate a new Rails site like you said
with something like this:
  Given I have a rails application

The best would probably be if the user could specify what Rails version to use.

> Now, Johan, I see you've deleted your testing branch where you had
> some features already. Are you preparing for a re-write of the tests
> or ...?
I merged that branch with my master since the plan was to merge with eschulte's master.
  
> I want to start on the tests, can't promise how far I'll get, but I
> don't want to start on it if you are already doing it.
Right now there are only a few unit tests, no features.


== This is how it looks right now:
All the old tests are removed. There's a folder in the Rinari root
called test, were are all unit tests are stored. Testing framework for
those is Ert (http://github.com/ohler/ert), which should also be used
for assertions in the Ecukes features. I'm planning to unit test some
more stuff and there's also a few TODO's in there. It would be great
if you looked at that stuff to.

To run the tests you first have to fetch all the submodules:
  $ git submodule init
  $ git submodule update

Then you simply run the rinari-test script file.
  $ ./test/rinari-test


The Ecukes features are in the features folder. I previosly had some
features, just to try it out, but those are gone now. So now there's
nothing.

Aleksandar, you are talking about testing jumps. My plan was that
Ecukes would do that job. For example:
  Scenario: Jump from controller to model
    Given I am in the "users" controller
    When I press "C-c ; f m"
    Then I should be in the "user" model

For this to work it's required some more stuff, like setting up a Rails
project and creating a scaffold etc... But you get the idea.


As I said my testing branch merged with my master. What do you
guys say about merging with eschulte's, so that other people can
start writing tests? Maybe we should create a testing branch on
eschulte repo since writing tests often leads to some
refactoring, which could affect the functionality.

Aleksandar Simic

unread,
Aug 10, 2010, 3:08:51 AM8/10/10
to emacs-o...@googlegroups.com
On 10 August 2010 07:14, Johan Andersson <johan....@gmail.com> wrote:

---8<-- snip --8<---

> == This is how it looks right now:
> All the old tests are removed. There's a folder in the Rinari root
> called test, were are all unit tests are stored. Testing framework for
> those is Ert (http://github.com/ohler/ert), which should also be used
> for assertions in the Ecukes features. I'm planning to unit test some
> more stuff and there's also a few TODO's in there. It would be great
> if you looked at that stuff to.
> To run the tests you first have to fetch all the submodules:
>   $ git submodule init
>   $ git submodule update
> Then you simply run the rinari-test script file.
>   $ ./test/rinari-test

I will look at your stuff in more detail later today, but I just
wanted to drop this quick note:

running the above script ./test/rinari-test fails on both FreeBSD and Ubuntu.

On FreeBSD the binaries are kept under: /usr/local.

Ubuntu fails too despite having the binary under /usr/bin.

If the first line of the script doesn't call via env, but you specify
the full path to emacs then it runs.

I know that calling scripts via /usr/bin/env is supposed to resolve
this, but by the looks of it it doesn't.

On both OSs emacs 23.x, with bash 4.0.33. The emacs binary is
definitely in the PATH.

Thanks

Reply all
Reply to author
Forward
0 new messages