petitest-spec 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 210c0267a02289a8dd80c5434a7b36feadf51a53
4
- data.tar.gz: 1ad349a656a28c77b628258d3349a034a392f71c
3
+ metadata.gz: 9b426ff3ae56ec13f4486f96394c9ddf950987a4
4
+ data.tar.gz: b0c9c77ca031cfe98783912833887de717a8e73c
5
5
  SHA512:
6
- metadata.gz: 4b3bd8a6212666b29dbafea8579b1807d881227d7f6347bc8934a763182b2efcb46dd87b00bd93a0e7ce6cc5c9cb60c4283e13a0cab8bc6609082541d4a0f4e2
7
- data.tar.gz: 74325d5cc88f08940103b7c8bed0a70e02eadaccd4bdad601040f9a62c6c4c0e77e450cbd4f5644b4ec24d5387ecf7a8bf2a310b0d387b58c90cd83c5eeaf795
6
+ metadata.gz: 124cfc4f4f4acb27b7c23218c26c136c70f6fcc2d7dc872d8ffdb6f2278424b182570375d7528801bef5fef94697ca983fcf3d2106be4b919d9d0e564583dc06
7
+ data.tar.gz: c6f477d43ea77eed0cf577aea75b7eeb1ec7d80e041b79af3cc5dd4fee624e56d640096694c4cab08ceee28457c2bf8349893eb3067f157ed44927f8b0eddc5f
@@ -1,3 +1,7 @@
1
+ ## v0.3.2
2
+
3
+ - Support `let` DSL
4
+
1
5
  ## v0.3.1
2
6
 
3
7
  - 1st Release :tada:
data/README.md CHANGED
@@ -31,7 +31,7 @@ Require `"petitest/spec"` and extend `Petitest::Spec` into your test class.
31
31
 
32
32
  ```ruby
33
33
  require "petitest/autorun"
34
- require "petitest/dsl"
34
+ require "petitest/spec"
35
35
 
36
36
  class ExampleTest < Petitest::Test
37
37
  include ::Petitest::Spec
@@ -45,7 +45,7 @@ end
45
45
  Nest a test group with description. `.context` is an alias.
46
46
 
47
47
  ```ruby
48
- describe do "GET /me"
48
+ describe "GET /me" do
49
49
  context "without logged-in" do
50
50
  it "returns 401" do
51
51
  assert { response.status == 200 }
@@ -67,3 +67,17 @@ specify "x is foo" do
67
67
  assert { x == "foo" }
68
68
  end
69
69
  ```
70
+
71
+ ### .let
72
+
73
+ Define a memozied method.
74
+
75
+ ```ruby
76
+ let(:result) do
77
+ 1 + 1
78
+ end
79
+
80
+ it "returns 2" do
81
+ assert { result == 2 }
82
+ end
83
+ ```
data/Rakefile CHANGED
@@ -1,8 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
- Rake::TestTask.new do |task|
5
- task.pattern = "test/**/*_test.rb"
6
- end
4
+ Rake::TestTask.new
7
5
 
8
6
  task default: :test
@@ -16,5 +16,15 @@ module Petitest
16
16
  end
17
17
  end
18
18
  end
19
+
20
+ # @param method_name [Symbol]
21
+ def let(method_name, &block)
22
+ define_method(method_name) do
23
+ @memoized_table ||= {}
24
+ @memoized_table.fetch(method_name) do |key|
25
+ @memoized_table[key] = instance_eval(&block)
26
+ end
27
+ end
28
+ end
19
29
  end
20
30
  end
@@ -1,5 +1,5 @@
1
1
  module Petitest
2
2
  module Spec
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petitest-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: petitest