always_execute 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,16 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- always_execute (0.1.2)
4
+ always_execute (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
+ activesupport (3.2.8)
10
+ i18n (~> 0.6)
11
+ multi_json (~> 1.0)
9
12
  diff-lcs (1.1.3)
13
+ i18n (0.6.1)
14
+ metaclass (0.0.1)
10
15
  minitest (2.12.1)
11
- mocha (0.9.8)
12
- rake
13
- rake (0.9.2.2)
16
+ mocha (0.12.6)
17
+ metaclass (~> 0.0.1)
18
+ multi_json (1.3.6)
14
19
  rspec (2.9.0)
15
20
  rspec-core (~> 2.9.0)
16
21
  rspec-expectations (~> 2.9.0)
@@ -19,9 +24,14 @@ GEM
19
24
  rspec-expectations (2.9.1)
20
25
  diff-lcs (~> 1.1.3)
21
26
  rspec-mocks (2.9.0)
22
- shared_should (0.8.3)
27
+ shared_should (0.9.0)
23
28
  shoulda
24
- shoulda (2.11.3)
29
+ shoulda (3.1.1)
30
+ shoulda-context (~> 1.0)
31
+ shoulda-matchers (~> 1.2)
32
+ shoulda-context (1.0.0)
33
+ shoulda-matchers (1.3.0)
34
+ activesupport (>= 3.0.0)
25
35
 
26
36
  PLATFORMS
27
37
  ruby
@@ -31,5 +41,5 @@ DEPENDENCIES
31
41
  minitest (~> 2.12.1)
32
42
  mocha (~> 0)
33
43
  rspec (~> 2.9.0)
34
- shared_should (~> 0.8.3)
35
- shoulda (~> 2.11.3)
44
+ shared_should (~> 0.9.0)
45
+ shoulda (= 3.1.1)
data/Rakefile CHANGED
@@ -12,5 +12,13 @@ require 'rspec/core/rake_task'
12
12
  desc "Run Rspecs"
13
13
  RSpec::Core::RakeTask.new(:spec)
14
14
 
15
- task :default => [:test, :spec]
15
+ task 'testversions' do
16
+ ENV['SHOULDA_VERSION'] = '2.11.3'
17
+ fail unless system "bundle update"
18
+ fail unless system "rake test"
19
+ ENV['SHOULDA_VERSION'] = '3.1.1'
20
+ fail unless system "bundle update"
21
+ fail unless system "rake test"
22
+ end
16
23
 
24
+ task :default => [:testversions, :spec]
@@ -19,9 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency 'rspec', '~> 2.9.0'
22
- s.add_development_dependency 'shoulda', '~> 2.11.3'
22
+ s.add_development_dependency('shoulda', ENV['SHOULDA_VERSION'] || "= 3.1.1") # Use SHOULDA_VERSION when testing different
23
23
  s.add_development_dependency 'mocha', '~> 0'
24
24
  s.add_development_dependency 'minitest', '~> 2.12.1'
25
- s.add_development_dependency 'shared_should', '~> 0.8.3'
25
+ s.add_development_dependency 'shared_should', '~> 0.9.0'
26
26
  end
27
27
 
@@ -6,84 +6,84 @@
6
6
  Notice in the test below there is **_setup_**, **_execute_**, and **_assert_** code all in the `it` blocks. Different test cases are not separated by contexts, instead they're all just strewn together; it may not be immediately obvious, but we're really testing 3 different cases below (not 4 - the first 2 `it`s describe the default behavior of the dvd\_player). It's easy to see how these problems could be much worse given a less trivial example and how these tests would not serve as the best documentation of how dvd_player#play works.
7
7
 
8
8
  ```ruby
9
- describe "dvd player" do
9
+ describe DvdPlayer do
10
+ before do
11
+ @dvd_player = DvdPlayer.new
12
+ @dvd = Dvd.new
13
+ end
14
+
15
+ it "should play movie" do
16
+ @dvd_player.play(@dvd)
17
+ @dvd_player.movie_playing?.should be_true
18
+ end
19
+
20
+ it "should not allow another disc to be inserted" do
21
+ @dvd_player.play(@dvd)
22
+ @dvd_player.allows_disc_insert?.should be_false
23
+ end
24
+
25
+ it "should not play movie with invalid region code" do
26
+ @dvd.region_code = 'invalid'
27
+ @dvd_player.play(@dvd)
28
+ @dvd_player.movie_playing?.should be_false
29
+ end
30
+
31
+ it "should resume from last played postiion with previously played dvd" do
32
+ @dvd.last_played_position = 123
33
+ @dvd_player.play(@dvd)
34
+ @dvd_player.movie_playing?.should be_true
35
+ @dvd_player.current_position.should == 123
36
+ end
37
+ end
38
+ ```
39
+
40
+ ## With Always Execute
41
+
42
+ When using always execute, you'll notice it's a lot DRYer, but more importantly all the **_setup_**, **_execute_**, and **_assert_** code is cleanly separated. Furthermore, test cases are cleanly separated by contexts. This makes it much easier to see that the first two should blocks apply to the default case, whereas the following contexts apply to exception cases. It's also much easier to see what makes the exception cases different, since their **_setup_** code is cleanly spelled out, rather than lumped in with other code.
43
+
44
+ ```ruby
45
+ describe DvdPlayer do
46
+ describe "#play" do
10
47
  before do
11
48
  @dvd_player = DvdPlayer.new
12
49
  @dvd = Dvd.new
13
50
  end
14
51
 
15
- it "should play movie" do
52
+ execute do
16
53
  @dvd_player.play(@dvd)
54
+ end
55
+
56
+
57
+ it "should play movie" do
17
58
  @dvd_player.movie_playing?.should be_true
18
59
  end
19
60
 
20
61
  it "should not allow another disc to be inserted" do
21
- @dvd_player.play(@dvd)
22
62
  @dvd_player.allows_disc_insert?.should be_false
23
63
  end
24
64
 
25
- it "should not play movie with invalid region code" do
26
- @dvd.region_code = 'invalid'
27
- @dvd_player.play(@dvd)
28
- @dvd_player.movie_playing?.should be_false
29
- end
30
-
31
- it "should resume from last played postiion with previously played dvd" do
32
- @dvd.last_played_position = 123
33
- @dvd_player.play(@dvd)
34
- @dvd_player.movie_playing?.should be_true
35
- @dvd_player.current_position.should == 123
36
- end
37
- end
38
- ```
39
-
40
- ## With Always Execute
41
-
42
- When using always execute, you'll notice it's a lot DRYer, but more importantly all the **_setup_**, **_execute_**, and **_assert_** code is cleanly separated. Furthermore, test cases are cleanly separated by contexts. This makes it much easier to see that the first two should blocks apply to the default case, whereas the following contexts apply to exception cases. It's also much easier to see what makes the exception cases different, since their **_setup_** code is cleanly spelled out, rather than lumped in with other code.
43
-
44
- ```ruby
45
- describe "dvd player" do
46
- context "#play" do
65
+ context "with invalid region code" do
47
66
  before do
48
- @dvd_player = DvdPlayer.new
49
- @dvd = Dvd.new
67
+ @dvd.region_code = 'invalid'
50
68
  end
51
69
 
52
- execute do
53
- @dvd_player.play(@dvd)
70
+ it "should not play movie" do
71
+ @dvd_player.movie_playing?.should be_false
54
72
  end
73
+ end
55
74
 
56
-
57
- it "should play movie" do
58
- @dvd_player.movie_playing?.should be_true
59
- end
60
-
61
- it "should not allow another disc to be inserted" do
62
- @dvd_player.allows_disc_insert?.should be_false
75
+ context "with previously played dvd" do
76
+ before do
77
+ @dvd.last_played_position = 123
63
78
  end
64
79
 
65
- context "with invalid region code" do
66
- before do
67
- @dvd.region_code = 'invalid'
68
- end
69
-
70
- it "should not play movie" do
71
- @dvd_player.movie_playing?.should be_false
72
- end
80
+ it "should resume from last played position" do
81
+ @dvd_player.movie_playing?.should be_true
82
+ @dvd_player.current_position.should == 123
73
83
  end
74
-
75
- context "with previously played dvd" do
76
- before do
77
- @dvd.last_played_position = 123
78
- end
79
-
80
- it "should resume from last played position" do
81
- @dvd_player.movie_playing?.should be_true
82
- @dvd_player.current_position.should == 123
83
- end
84
- end
85
- end
84
+ end
86
85
  end
86
+ end
87
87
  ```
88
88
 
89
89
  # Other Features
@@ -93,33 +93,33 @@ When using always execute, you'll notice it's a lot DRYer, but more importantly
93
93
  Often in specs, you are testing the returned value of a single function. For connivence, the returned value of an execute block is stored in a variable called `@execute_result`.
94
94
 
95
95
  ```ruby
96
- describe "dvd player" do
97
- context "#current_dvd" do
98
- before do
99
- @dvd_player = DvdPlayer.new
100
- end
96
+ describe DvdPlayer do
97
+ describe "#current_dvd" do
98
+ before do
99
+ @dvd_player = DvdPlayer.new
100
+ end
101
101
 
102
- execute do
103
- @dvd_player.current_dvd
104
- end
102
+ execute do
103
+ @dvd_player.current_dvd
104
+ end
105
105
 
106
- context "without any dvd in the player" do
107
- it "should return no dvd" do
108
- @execute_result.should be_nil
109
- end
106
+ context "without any dvd in the player" do
107
+ it "should return no dvd" do
108
+ @execute_result.should be_nil
110
109
  end
110
+ end
111
111
 
112
- context "with a dvd in the player" do
113
- before do
114
- @dvd = Dvd.new
115
- @dvd_player.insert(@dvd)
116
- end
112
+ context "with a dvd in the player" do
113
+ before do
114
+ @dvd = Dvd.new
115
+ @dvd_player.insert(@dvd)
116
+ end
117
117
 
118
- it "should return the dvd in the player" do
119
- @execute_result.should == @dvd
120
- end
118
+ it "should return the dvd in the player" do
119
+ @execute_result.should == @dvd
121
120
  end
122
121
  end
123
122
  end
123
+ end
124
124
  ```
125
125
 
@@ -6,37 +6,37 @@
6
6
  Notice in the test below there is **_setup_**, **_execute_**, and **_assert_** code all in the `should` blocks. Different test cases are not separated by contexts, instead they're all just strewn together; it may not be immediately obvious, but we're really testing 3 different cases below (not 4 - the first 2 shoulds describe the default behavior of the dvd\_player). It's easy to see how these problems could be much worse given a less trivial example and how these tests would not serve as the best documentation of how dvd_player#play works.
7
7
 
8
8
  ```ruby
9
- class DvdPlayerTest
10
- context "dvd player" do
11
- setup do
12
- @dvd_player = DvdPlayer.new
13
- @dvd = Dvd.new
14
- end
9
+ class DvdPlayerTest
10
+ context "dvd player" do
11
+ setup do
12
+ @dvd_player = DvdPlayer.new
13
+ @dvd = Dvd.new
14
+ end
15
15
 
16
- should "play movie" do
17
- @dvd_player.play(@dvd)
18
- assert @dvd_player.movie_playing?
19
- end
20
-
21
- should "not allow another disc to be inserted" do
22
- @dvd_player.play(@dvd)
23
- assert_equal false, @dvd_player.allows_disc_insert?
24
- end
16
+ should "play movie" do
17
+ @dvd_player.play(@dvd)
18
+ assert @dvd_player.movie_playing?
19
+ end
20
+
21
+ should "not allow another disc to be inserted" do
22
+ @dvd_player.play(@dvd)
23
+ assert_equal false, @dvd_player.allows_disc_insert?
24
+ end
25
25
 
26
- should "not play movie with invalid region code" do
27
- @dvd.region_code = 'invalid'
28
- @dvd_player.play(@dvd)
29
- assert_equal false, @dvd_player.movie_playing?
30
- end
26
+ should "not play movie with invalid region code" do
27
+ @dvd.region_code = 'invalid'
28
+ @dvd_player.play(@dvd)
29
+ assert_equal false, @dvd_player.movie_playing?
30
+ end
31
31
 
32
- should "resume from last played postiion with previously played dvd" do
33
- @dvd.last_played_position = 123
34
- @dvd_player.play(@dvd)
35
- assert @dvd_player.movie_playing?
36
- assert_equal 123, @dvd_player.current_position
37
- end
32
+ should "resume from last played postiion with previously played dvd" do
33
+ @dvd.last_played_position = 123
34
+ @dvd_player.play(@dvd)
35
+ assert @dvd_player.movie_playing?
36
+ assert_equal 123, @dvd_player.current_position
38
37
  end
39
38
  end
39
+ end
40
40
  ```
41
41
 
42
42
  ## With Always Execute
@@ -44,48 +44,47 @@ Notice in the test below there is **_setup_**, **_execute_**, and **_assert_** c
44
44
  When using always execute, you'll notice it's a lot DRYer, but more importantly all the **_setup_**, **_execute_**, and **_assert_** code is cleanly separated. Furthermore, test cases are cleanly separated by contexts. This makes it much easier to see that the first two should blocks apply to the default case, whereas the following contexts apply to exception cases. It's also much easier to see what makes the exception cases different, since their **_setup_** code is cleanly spelled out, rather than lumped in with other code.
45
45
 
46
46
  ```ruby
47
- class DvdPlayerTest
48
- context "#play" do
49
- setup do
50
- @dvd_player = DvdPlayer.new
51
- @dvd = Dvd.new
52
- end
47
+ class DvdPlayerTest
48
+ context "#play" do
49
+ setup do
50
+ @dvd_player = DvdPlayer.new
51
+ @dvd = Dvd.new
52
+ end
53
53
 
54
- execute do
55
- @dvd_player.play(@dvd)
56
- end
54
+ execute do
55
+ @dvd_player.play(@dvd)
56
+ end
57
57
 
58
+ should "play movie" do
59
+ assert @dvd_player.movie_playing?
60
+ end
61
+
62
+ should "not allow another disc to be inserted" do
63
+ assert_equal false, @dvd_player.allows_disc_insert?
64
+ end
58
65
 
59
- should "play movie" do
60
- assert @dvd_player.movie_playing?
66
+ context "with invalid region code" do
67
+ setup do
68
+ @dvd.region_code = 'invalid'
61
69
  end
62
-
63
- should "not allow another disc to be inserted" do
64
- assert_equal false, @dvd_player.allows_disc_insert?
70
+
71
+ should "not play movie" do
72
+ assert_equal false, @dvd_player.movie_playing?
65
73
  end
74
+ end
66
75
 
67
- context "with invalid region code" do
68
- setup do
69
- @dvd.region_code = 'invalid'
70
- end
71
-
72
- should "not play movie" do
73
- assert_equal false, @dvd_player.movie_playing?
74
- end
76
+ context "with previously played dvd" do
77
+ setup do
78
+ @dvd.last_played_position = 123
75
79
  end
76
80
 
77
- context "with previously played dvd" do
78
- setup do
79
- @dvd.last_played_position = 123
80
- end
81
-
82
- should "resume from last played position" do
83
- assert @dvd_player.movie_playing?
84
- assert_equal 123, @dvd_player.current_position
85
- end
86
- end
87
- end
81
+ should "resume from last played position" do
82
+ assert @dvd_player.movie_playing?
83
+ assert_equal 123, @dvd_player.current_position
84
+ end
85
+ end
88
86
  end
87
+ end
89
88
  ```
90
89
 
91
90
  # Other Features
@@ -95,34 +94,34 @@ When using always execute, you'll notice it's a lot DRYer, but more importantly
95
94
  Often in unit tests, you are testing the returned value of a single function. For connivence, the returned value of an execute block is stored in a variable called `@execute_result`.
96
95
 
97
96
  ```ruby
98
- class DvdPlayerTest
99
- context "#current_dvd" do
100
- setup do
101
- @dvd_player = DvdPlayer.new
102
- end
97
+ class DvdPlayerTest
98
+ context "#current_dvd" do
99
+ setup do
100
+ @dvd_player = DvdPlayer.new
101
+ end
103
102
 
104
- execute do
105
- @dvd_player.current_dvd
106
- end
103
+ execute do
104
+ @dvd_player.current_dvd
105
+ end
107
106
 
108
- context "without any dvd in the player" do
109
- should "return no dvd" do
110
- assert_nil @execute_result
111
- end
107
+ context "without any dvd in the player" do
108
+ should "return no dvd" do
109
+ assert_nil @execute_result
112
110
  end
111
+ end
113
112
 
114
- context "with a dvd in the player" do
115
- setup do
116
- @dvd = Dvd.new
117
- @dvd_player.insert(@dvd)
118
- end
113
+ context "with a dvd in the player" do
114
+ setup do
115
+ @dvd = Dvd.new
116
+ @dvd_player.insert(@dvd)
117
+ end
119
118
 
120
- should "return the dvd in the player" do
121
- assert_equal @dvd, @execute_result
122
- end
119
+ should "return the dvd in the player" do
120
+ assert_equal @dvd, @execute_result
123
121
  end
124
122
  end
125
123
  end
124
+ end
126
125
  ```
127
126
 
128
127
  ## expects
@@ -130,20 +129,20 @@ Often in unit tests, you are testing the returned value of a single function. F
130
129
  Expectations belong in the **_assert_** step of testing, but because of the nature of mocha expectations they need to be called in your `setup` block. The `expects` block allows you to set your expectations without needing to create a new context.
131
130
 
132
131
  ```ruby
133
- class DvdPlayerTest
134
- context "#menu" do
135
- setup do
136
- @dvd_player = DvdPlayer.new
137
- end
138
-
139
- execute do
140
- @dvd_player.menu
141
- end
132
+ class DvdPlayerTest
133
+ context "#menu" do
134
+ setup do
135
+ @dvd_player = DvdPlayer.new
136
+ end
142
137
 
143
- expects do
144
- @dvd_player.expects(:display_menu_options)
145
- end
138
+ execute do
139
+ @dvd_player.menu
146
140
  end
141
+
142
+ expects do
143
+ @dvd_player.expects(:display_menu_options)
144
+ end
147
145
  end
146
+ end
148
147
  ```
149
148
 
@@ -1,11 +1,24 @@
1
- if defined?(Shoulda) && defined?(Shoulda::Context) && Shoulda::Context.instance_methods.include?(:should)
2
- require 'shoulda_execute'
3
- require 'shoulda_expects'
1
+ require 'always_execute/version'
2
+
3
+ if defined?(Shoulda::Context::Context)
4
+ require 'always_execute/shoulda_execute'
5
+ require 'always_execute/shoulda_expects'
6
+
7
+ class Shoulda::Context::Context
8
+ include AlwaysExecute::ShouldaExecute
9
+ include AlwaysExecute::ShouldaExpects
10
+ end
11
+ elsif defined?(Shoulda::Context) && Shoulda::Context.instance_methods.include?(:should)
12
+ require 'always_execute/shoulda_execute'
13
+ require 'always_execute/shoulda_expects'
14
+
15
+ class Shoulda::Context
16
+ include AlwaysExecute::ShouldaExecute
17
+ include AlwaysExecute::ShouldaExpects
18
+ end
4
19
  end
5
20
 
6
21
  if defined?(RSpec)
7
- require 'rspec_execute'
8
- require 'rspec_expects'
22
+ require 'always_execute/rspec_execute'
23
+ require 'always_execute/rspec_expects'
9
24
  end
10
-
11
- require 'always_execute/version'
@@ -0,0 +1,46 @@
1
+ module AlwaysExecute
2
+ module ShouldaExecute
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+ @@shoulda_execute_class = klass
6
+
7
+ def execute(&execute_block)
8
+ setup do
9
+ @execute_block = execute_block
10
+ end
11
+ end
12
+
13
+ alias :should_without_execute :should
14
+
15
+ def should(name = nil, options = {}, &block)
16
+ if block.nil?
17
+ should_without_execute(name, options)
18
+ else
19
+ should_without_execute(name, options) do
20
+ if @execute_block
21
+ self.instance_variable_set('@execute_result', @@shoulda_execute_class.shoulda_execute_call_block(self, @execute_block))
22
+ end
23
+ @@shoulda_execute_class.shoulda_execute_call_block(self, block)
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.shoulda_execute_class
29
+ @@shoulda_execute_class
30
+ end
31
+
32
+ def self.shoulda_execute_call_block(test, block)
33
+ if should_execute_shared_should_available?
34
+ test.call_block_with_shared_value(block)
35
+ else
36
+ block.bind(test).call
37
+ end
38
+ end
39
+
40
+ def self.should_execute_shared_should_available?
41
+ Test::Unit::TestCase.respond_to? :share_context
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ module AlwaysExecute
2
+ module ShouldaExpects
3
+ def self.included(klass)
4
+ klass.class_eval do
5
+ def expects(name = nil, &expects_block)
6
+ context nil do
7
+ setup do
8
+ expects_block.bind(self).call
9
+ end
10
+
11
+ should "meet expectation #{name}" do
12
+ # empty body
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -1,3 +1,3 @@
1
1
  module AlwaysExecute
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -19,7 +19,8 @@ class ShouldaExecuteTest < Test::Unit::TestCase
19
19
 
20
20
  context "without shared_should library" do
21
21
  setup do
22
- Shoulda::Context.expects(:should_execute_shared_should_available?).at_least_once.returns(false)
22
+ klass = defined?(Shoulda::Context::Context) ? Shoulda::Context::Context : Shoulda::Context
23
+ klass.shoulda_execute_class.expects(:should_execute_shared_should_available?).at_least_once.returns(false)
23
24
  end
24
25
 
25
26
  should "set execute_result to execute block return value" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: always_execute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - '='
36
36
  - !ruby/object:Gem::Version
37
- version: 2.11.3
37
+ version: 3.1.1
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - '='
44
44
  - !ruby/object:Gem::Version
45
- version: 2.11.3
45
+ version: 3.1.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: mocha
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 0.8.3
85
+ version: 0.9.0
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 0.8.3
93
+ version: 0.9.0
94
94
  description: Adds execute and expect test blocks for added BDD test clarity.
95
95
  email:
96
96
  - michaelgpearce@yahoo.com
@@ -109,11 +109,11 @@ files:
109
109
  - docs/rspec_examples.md
110
110
  - docs/shoulda_examples.md
111
111
  - lib/always_execute.rb
112
+ - lib/always_execute/rspec_execute.rb
113
+ - lib/always_execute/rspec_expects.rb
114
+ - lib/always_execute/shoulda_execute.rb
115
+ - lib/always_execute/shoulda_expects.rb
112
116
  - lib/always_execute/version.rb
113
- - lib/rspec_execute.rb
114
- - lib/rspec_expects.rb
115
- - lib/shoulda_execute.rb
116
- - lib/shoulda_expects.rb
117
117
  - spec/execute_spec.rb
118
118
  - spec/expects_spec.rb
119
119
  - spec/spec_helper.rb
@@ -1,35 +0,0 @@
1
- class Shoulda::Context
2
- def execute(&execute_block)
3
- setup do
4
- @execute_block = execute_block
5
- end
6
- end
7
-
8
- alias :should_without_execute :should
9
-
10
- def should(name = nil, options = {}, &block)
11
- if block.nil?
12
- should_without_execute(name, options)
13
- else
14
- should_without_execute(name, options) do
15
- if @execute_block
16
- self.instance_variable_set('@execute_result', Shoulda::Context.shoulda_execute_call_block(self, @execute_block))
17
- end
18
- Shoulda::Context.shoulda_execute_call_block(self, block)
19
- end
20
- end
21
- end
22
-
23
- def self.shoulda_execute_call_block(test, block)
24
- if should_execute_shared_should_available?
25
- test.call_block_with_shared_value(block)
26
- else
27
- block.bind(test).call
28
- end
29
- end
30
-
31
- def self.should_execute_shared_should_available?
32
- Test::Unit::TestCase.respond_to? :share_context
33
- end
34
- end
35
-
@@ -1,14 +0,0 @@
1
- class Shoulda::Context
2
- def expects(name = nil, &expects_block)
3
- context nil do
4
- setup do
5
- expects_block.bind(self).call
6
- end
7
-
8
- should "meet expectation #{name}" do
9
- # empty body
10
- end
11
- end
12
- end
13
- end
14
-