summary refs log tree commit diff
path: root/pkgs/development/ruby-modules/bundler-env/test.nix
blob: 28e5dbe318a2e881e6fab17d858ad45fea7162e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Run with:
nix-build -E 'with import <nixpkgs> { }; callPackage ./test.nix {}' --show-trace; and cat result

Confusingly, the ideal result ends with something like:
error: build of ‘/nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv’ failed
*/
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage }@defs:
let
  test = import ./testing.nix;
  tap = import ./tap-support.nix;
  stubs = import ./stubs.nix defs;
  should = import ./assertions.nix { inherit test lib; };

  basicEnv = callPackage ./basic.nix stubs;
  bundlerEnv = callPackage ./default.nix stubs // {
    inherit basicEnv;
  };

  testConfigs = {
    groups = ["default"];
    gemConfig =  defaultGemConfig;
    confFiles = "./testConfs";
  };
  functions = (import ./functions.nix ({ inherit lib; ruby = stubs.ruby; } // testConfigs));

  justName = bundlerEnv {
    name = "test";
    gemset = ./test/gemset.nix;
  };

  pnamed = basicEnv {
    pname = "test";
    gemdir = ./test;
    gemset = ./test/gemset.nix;
    gemfile = ./test/Gemfile;
    lockfile = ./test/Gemfile.lock;
  };

  results = builtins.concatLists [
    (test.run "Filter empty gemset" {} (set: functions.filterGemset set == {}))
    (test.run "bundlerEnv { name }" justName {
      name = should.equal "test";
    })
    (test.run "bundlerEnv { pname }" pnamed
    [
      (should.haveKeys [ "name" "env" "postBuild" ])
      {
        name = should.equal "test";
        env = should.beASet;
        postBuild = should.havePrefix "/nix/store";
      }
    ])
  ];
in
  writeText "test-results.tap" (tap.output results)