Skip to content

Commit

Permalink
Merge branch 'upstream-master' into dev
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
  • Loading branch information
tatsuya6502 committed Oct 14, 2014
2 parents 877a16e + b1f313b commit 3b0c662
Show file tree
Hide file tree
Showing 33 changed files with 3,240 additions and 848 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ doc/*.png
doc/edoc-info
ebin
tags
.*.swp
.settings
.project
*.sublime-workspace
*.sublime-project
deps/*
.rebar
3 changes: 3 additions & 0 deletions .scripts/tag_with_changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ git add CHANGELOG
# Update version in .app file
sed -i "" -e "s/{vsn, .*}/{vsn, \"$1\"}/g" src/meck.app.src
sed -i "" -e "s/@version .*/@version $1/g" doc/overview.edoc
sed -i "" -e "s/version: \".*\"/version: \"$1\"/g" package.exs
git add src/meck.app.src
git add doc/overview.edoc

Expand All @@ -39,3 +40,5 @@ git tag -s $1 -m "Version $
$CHANGELOG"
git push && git push --tags
MIX_EXS mix hex.publish

13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
language: erlang
notifications:
disabled: true
email:
- hello@alind.io
otp_release:
- R15B
- R14B04
- R14B03
- R14B02
- 17.0
- R16B03-1
- R16B
- R15B03
before_script: "make get-deps"
script: "make all"
63 changes: 56 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
REBAR=`which rebar || ./rebar`
PLTFILE=$(CURDIR)/.deps.plt
APP_DEPS=kernel stdlib eunit tools compiler
ERLFLAGS= -pa $(CURDIR)/.eunit -pa $(CURDIR)/ebin -pa $(CURDIR)/deps/*/ebin

all: compile
REBAR="./rebar"
ifeq ($(REBAR),)
$(error "Rebar not available on this system")
endif

ERL = $(shell which erl)
ifeq ($(ERL),)
$(error "Erlang must be available on this system")
endif

BUILD_PLT_INC=$(shell test -d deps && echo '-r deps')
DIALYZER_INC=$(shell test -d include && echo '-I include') $(shell test -d deps && echo '-I deps')

.PHONY: all rebuild compile doc clean test dialyzer typer get-deps clean-deps \
shell clean-plt clean-doc distclean

all: get-deps compile

rebuild: distclean get-deps all

get-deps:
@$(REBAR) -C test.config get-deps

compile:
@$(REBAR) compile
@$(REBAR) -C rebar.config skip_deps=true compile

test: force
@$(REBAR) eunit
doc:
@$(REBAR) -C test.config skip_deps=true doc

clean:
@$(REBAR) clean
@$(REBAR) -C test.config skip_deps=true clean

test: get-deps compile
@$(REBAR) -C test.config compile
@$(REBAR) -C test.config skip_deps=true eunit

$(PLTFILE):
- dialyzer --build_plt --apps $(APP_DEPS) $(BUILD_PLT_INC) --output_plt $(PLTFILE)

dialyzer: compile $(PLTFILE)
@dialyzer --fullpath --plt $(PLTFILE) $(DIALYZER_INC) -pa $(CURDIR)/ebin -c src --src | \
fgrep -v -f ./dialyzer.ignore-warnings

typer:
typer --plt $(PLTFILE) $(DIALYZER_INC) -r src

shell:
@$(ERL) $(ERLFLAGS)

clean-plt:
@rm -rf $(PLTFILE)

clean-doc:
@cd doc; ls * | grep -v overview.edoc | xargs rm -f

clean-deps:
@rm -rvf $(CURDIR)/deps/*

force: ;
distclean: clean clean-plt clean-doc clean-deps
142 changes: 79 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,43 @@
[![Build Status](https://secure.travis-ci.org/eproxus/meck.png)](http://travis-ci.org/eproxus/meck)
[![Release](http://img.shields.io/github/release/eproxus/meck.svg?style=flat-square)](https://github.com/eproxus/meck/releases/latest)
[![Build Status](http://img.shields.io/travis/eproxus/meck.svg?style=flat-square)](http://travis-ci.org/eproxus/meck)
[![Code Climate](http://img.shields.io/badge/code_climate-17.0-brightgreen.svg?style=flat-square)](https://travis-ci.org/eproxus/meck)

* [Introduction](#introduction)
* [Features](#features)
* [Examples](#examples)
* [Build](#build)
* [Install](#install)
* [Contribute](#contribute) - Read if you're planning to submit patches

meck
Meck
====
A mocking library for Erlang.


<a name='introduction'>

Introduction
------------

With meck you can easily mock modules in Erlang. You can also perform
some basic validations on the mocked modules, such as making sure no
unexpected exceptions occurred or looking at the call history.

A mocking library for Erlang.

<a name='features'>

Features
--------

* Automatic renaming and restoration of original modules
See what's new in [0.8 Release Notes][1].

* Dynamic return values using sequences and loops of static values
* Compact definition of mock arguments, clauses and return values
* Pass through: call functions in the original module
* Complete call history showing calls, return values and exceptions
* Mock validation, will invalidate mocks that were not called correctly
* Throwing of expected exceptions that keeps the module valid
* Throws an error when mocking a module that doesn't exist or has been
renamed (disable with option `non_strict`)
* Support for [Hamcrest][2] matchers
* Automatic backup and restore of cover data
* Changing return values using sequences and loops of static values
* Pass through: use functions from the original module
* Mock is linked to the creating process (disable with `no_link`)
* Complete call history showing calls, results and exceptions
* Mock is linked to the creating process and will unload automatically
when a crash occurs (disable with option `no_link`)
* Mocking of sticky modules (using the option `unstick`)
* Throwing of expected exceptions that keeps the module valid


<a name='examples'>

Examples
--------
Here's an example of using meck in the Erlang shell:
Here's an example of using Meck in the Erlang shell:

```erl
Eshell V5.8.4 (abort with ^G)
1> meck:new(dog).
1> meck:new(dog, [non_strict]). % non_strict is used to create modules that don't exist
ok
2> meck:expect(dog, bark, fun() -> "Woof!" end).
ok
Expand All @@ -59,7 +51,7 @@ ok
** exception error: undefined function dog:bark/0
```

Exceptions can be anticipated by meck (resulting in validation still
Exceptions can be anticipated by Meck (resulting in validation still
passing). This is intended to be used to test code that can and should
handle certain exceptions indeed does take care of them:

Expand Down Expand Up @@ -105,7 +97,7 @@ ok
false
```

Here's an example of using meck inside an EUnit test case:
Here's an example of using Meck inside an EUnit test case:

```erlang
my_test() ->
Expand Down Expand Up @@ -155,17 +147,17 @@ ok
Build
-----

meck requires [rebar][1] to build. To build meck, go to the meck
directory and simply type:
Meck requires `make` and [rebar][1] to build. To build Meck go to the Meck directory
and simply type:

```sh
rebar compile
make
```

To make sure meck works on your platform, run the tests:
In order to run all tests for Meck type the following command from the same directory:

```sh
rebar eunit
make test
```

Two things might seem alarming when running the tests:
Expand All @@ -177,20 +169,29 @@ Both are expected due to the way Erlang currently prints errors. The
important line you should look for is `All XX tests passed`, if that
appears all is correct.

Documentation can be generated through the use of the following command:

```sh
make doc
```

<a name='install'>

Install
-------

To install meck permanently, use of [Agner][2] is recommended:
Meck is best used via [rebar][3]. Add the following dependency t
your `rebar.config` in your project root:

```sh
agner install meck
```erlang
{deps, [
{meck, ".*",
{git, "https://github.com/eproxus/meck.git", {tag, "0.8"}}}
]}.
```

If you want to install your own built version of meck add the ebin
directory to your Erlang code path or move the meck folder into your
If you want to install your own built version of Meck add the ebin
directory to your Erlang code path or move the Meck folder into your
release folder and make sure that folder is in your `ERL_LIBS`
environment variable.

Expand All @@ -200,26 +201,41 @@ environment variable.
Contribute
----------

Patches are greatly appreciated!

meck uses the [git flow][3] model (tip: install and use the
[`git-flow`][4] command). Use the branch name `feature/...` for easier
integration when developing new features or fixes for meck.

For a much nicer history, please [write good commit messages][5].

Should you find yourself using meck and have issues, comments or
feedback please [create an issue here on GitHub.] [6]

[1]: https://github.com/basho/rebar
"Rebar - A build tool for Erlang"
[2]: http://erlagner.org/
"Agner - Erlang Package Index & Package Manager"
[3]: http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/
"Why Aren't You Using git-flow?"
[4]: https://github.com/nvie/gitflow
"git-flow on GitHub"
[5]: https://github.com/erlang/otp/wiki/Writing-good-commit-messages
"Erlang/OTP commit messages"
[6]: http://github.com/eproxus/meck/issues
"meck issues"
Patches are greatly appreciated! For a much nicer history, please
[write good commit messages][5]. Use a branch name prefixed by
`feature/` (e.g. `feature/my_example_branch`) for easier integration
when developing new features or fixes for meck.

Should you find yourself using Meck and have issues, comments or
feedback please [create an issue here on GitHub][4].

Contributors:

- Maxim Vladimirsky (@horkhe)
- Ryan Zezeski (@rzezeski)
- David Haglund (@daha)
- Magnus Henoch (@legoscia)
- Susan Potter (@mbbx6spp)
- Andreas Amsenius (@adbl)
- Anthony Molinaro (@djnym)
- Matt Campbell (@xenolinguist)
- Martynas Pumputis (@brb)
- Shunichi Shinohara (@shino)
- Miëtek Bak
- Henry Nystrom
- Ward Bekker (@wardbekker)
- Damon Richardson
- Christopher Meiklejohn
- Joseph Wayne Norton (@norton)
- Erkan Yilmaz (@Erkan-Yilmaz)
- Joe Williams (@joewilliams)
- Russell Brown
- Michael Klishin (@michaelklishin)
- Magnus Klaar


[1]: https://github.com/eproxus/meck/wiki/0.8-Release-Notes
"0.8 Release Notes"
[2]: https://github.com/hyperthunk/hamcrest-erlang "Hamcrest for Erlang"
[3]: https://github.com/basho/rebar "Rebar - A build tool for Erlang"
[4]: http://github.com/eproxus/meck/issues "Meck issues"
5 changes: 5 additions & 0 deletions dialyzer.ignore-warnings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### meck:code_cover.erl has to call this unexported functions to do its
### cover passthrough magic:
Call to missing or unexported function cover:compile_beam/2
Call to missing or unexported function cover:get_term/1
Call to missing or unexported function cover:write/2
2 changes: 1 addition & 1 deletion doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@author Adam Lindberg <eproxus@gmail.com>
@copyright 2011, Adam Lindberg & Erlang Solutions Ltd
@version "0.7.2"
@version 0.8.2
@title meck, a Mocking Library for Erlang

@doc
Expand Down
45 changes: 45 additions & 0 deletions package.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
defmodule Meck.Mixfile do
use Mix.Project

def project do
[
app: :meck,
version: "0.8.2",
description: description,
package: package,
deps: [],
]
end

defp description do
"""
A mocking framework for Erlang
"""
end

defp package do
[
files: [
"Makefile",
"rebar.config",
"test.config",
"src",
"test/*.erl",
"test/cover_test_module.dontcompile",
"test/include",
"README.md",
"LICENSE",
"CHANGELOG",
],
contributors: [
"Adam Lindberg",
],
licenses: [
"Apache 2.0",
],
links: %{
"GitHub" => "https://github.com/eproxus/meck",
},
]
end
end
Binary file added rebar
Binary file not shown.

0 comments on commit 3b0c662

Please sign in to comment.