rspec 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{CHANGES → History.txt} +116 -64
- data/Manifest.txt +403 -0
- data/{MIT-LICENSE → README.txt} +43 -0
- data/Rakefile +39 -212
- data/{TODO → TODO.txt} +0 -0
- data/bin/autospec +4 -0
- data/bin/spec +1 -1
- data/examples/pure/yielding_example.rb +33 -0
- data/examples/stories/game-of-life/.loadpath +5 -0
- data/examples/stories/game-of-life/behaviour/everything.rb +1 -1
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +17 -17
- data/init.rb +9 -0
- data/lib/autotest/discover.rb +1 -1
- data/lib/autotest/rspec.rb +3 -29
- data/lib/spec.rb +10 -12
- data/lib/spec/adapters.rb +1 -0
- data/lib/spec/adapters/ruby_engine.rb +26 -0
- data/lib/spec/adapters/ruby_engine/mri.rb +8 -0
- data/lib/spec/adapters/ruby_engine/rubinius.rb +8 -0
- data/lib/spec/example/errors.rb +6 -0
- data/lib/spec/example/example_group_methods.rb +17 -14
- data/lib/spec/example/example_matcher.rb +2 -0
- data/lib/spec/example/example_methods.rb +4 -9
- data/lib/spec/example/module_inclusion_warnings.rb +2 -1
- data/lib/spec/expectations/extensions/object.rb +2 -2
- data/lib/spec/expectations/handler.rb +8 -16
- data/lib/spec/extensions/main.rb +2 -17
- data/lib/spec/matchers.rb +8 -2
- data/lib/spec/matchers/be.rb +0 -3
- data/lib/spec/matchers/change.rb +44 -40
- data/lib/spec/matchers/has.rb +1 -1
- data/lib/spec/matchers/have.rb +17 -12
- data/lib/spec/matchers/operator_matcher.rb +10 -4
- data/lib/spec/matchers/simple_matcher.rb +113 -10
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraints.rb +185 -0
- data/lib/spec/mocks/argument_expectation.rb +35 -173
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +30 -5
- data/lib/spec/mocks/methods.rb +14 -2
- data/lib/spec/mocks/mock.rb +4 -0
- data/lib/spec/mocks/proxy.rb +46 -5
- data/lib/spec/mocks/spec_methods.rb +9 -1
- data/lib/spec/rake/spectask.rb +14 -22
- data/lib/spec/rake/verify_rcov.rb +3 -3
- data/lib/spec/runner.rb +18 -6
- data/lib/spec/runner/backtrace_tweaker.rb +6 -7
- data/lib/spec/runner/command_line.rb +6 -17
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +3 -1
- data/lib/spec/runner/formatter/base_text_formatter.rb +5 -9
- data/lib/spec/runner/formatter/html_formatter.rb +1 -1
- data/lib/spec/runner/formatter/nested_text_formatter.rb +1 -1
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +2 -2
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/html_formatter.rb +62 -16
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +68 -16
- data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +42 -0
- data/lib/spec/runner/heckle_runner.rb +2 -2
- data/lib/spec/runner/option_parser.rb +2 -1
- data/lib/spec/runner/options.rb +18 -9
- data/lib/spec/runner/reporter.rb +24 -4
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/story/runner.rb +1 -2
- data/lib/spec/story/runner/story_mediator.rb +14 -0
- data/lib/spec/story/runner/story_parser.rb +20 -0
- data/lib/spec/story/step.rb +40 -28
- data/lib/spec/story/step_mother.rb +2 -1
- data/lib/spec/story/world.rb +6 -2
- data/lib/spec/version.rb +13 -22
- data/rake_tasks/failing_examples_with_html.rake +1 -1
- data/rake_tasks/verify_rcov.rake +2 -2
- data/rspec.gemspec +33 -0
- data/spec/autotest/rspec_spec.rb +90 -141
- data/spec/spec/adapters/ruby_engine_spec.rb +16 -0
- data/spec/spec/example/base_formatter_spec.rb +112 -0
- data/spec/spec/example/example_group_factory_spec.rb +2 -2
- data/spec/spec/example/example_group_methods_spec.rb +55 -4
- data/spec/spec/example/example_group_spec.rb +4 -3
- data/spec/spec/example/example_methods_spec.rb +18 -14
- data/spec/spec/example/pending_module_spec.rb +38 -0
- data/spec/spec/example/shared_example_group_spec.rb +1 -1
- data/spec/spec/expectations/extensions/object_spec.rb +0 -12
- data/spec/spec/extensions/main_spec.rb +3 -8
- data/spec/spec/matchers/change_spec.rb +16 -6
- data/spec/spec/matchers/handler_spec.rb +58 -37
- data/spec/spec/matchers/has_spec.rb +10 -0
- data/spec/spec/matchers/have_spec.rb +105 -2
- data/spec/spec/matchers/operator_matcher_spec.rb +35 -2
- data/spec/spec/matchers/simple_matcher_spec.rb +64 -2
- data/spec/spec/mocks/any_number_of_times_spec.rb +7 -0
- data/spec/spec/mocks/bug_report_496.rb +17 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +7 -1
- data/spec/spec/mocks/hash_including_matcher_spec.rb +45 -24
- data/spec/spec/mocks/mock_spec.rb +55 -10
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +54 -0
- data/spec/spec/mocks/null_object_mock_spec.rb +14 -0
- data/spec/spec/mocks/options_hash_spec.rb +18 -28
- data/spec/spec/mocks/partial_mock_spec.rb +2 -0
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +20 -6
- data/spec/spec/mocks/stub_spec.rb +7 -0
- data/spec/spec/runner/command_line_spec.rb +5 -12
- data/spec/spec/runner/drb_command_line_spec.rb +13 -6
- data/spec/spec/runner/formatter/html_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +20 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/story/html_formatter_spec.rb +76 -2
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +161 -0
- data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +82 -0
- data/spec/spec/runner/heckle_runner_spec.rb +8 -8
- data/spec/spec/runner/option_parser_spec.rb +21 -6
- data/spec/spec/runner/output_one_time_fixture_runner.rb +1 -1
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +6 -0
- data/spec/spec/runner/reporter_spec.rb +51 -5
- data/spec/spec/runner/spec_parser_spec.rb +4 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +2 -5
- data/spec/spec/story/runner/story_mediator_spec.rb +10 -0
- data/spec/spec/story/runner/story_parser_spec.rb +23 -6
- data/spec/spec/story/scenario_spec.rb +1 -3
- data/spec/spec/story/step_mother_spec.rb +12 -0
- data/spec/spec/story/step_spec.rb +57 -4
- data/spec/spec/story/story_spec.rb +1 -3
- data/spec/spec/story/world_spec.rb +1 -1
- data/spec/spec_helper.rb +21 -68
- data/stories/all.rb +1 -1
- data/stories/configuration/before_blocks.story +21 -0
- data/stories/configuration/stories.rb +7 -0
- data/stories/example_groups/stories.rb +3 -4
- data/stories/resources/spec/before_blocks_example.rb +32 -0
- data/stories/stories/multiline_steps.story +23 -0
- data/stories/stories/steps/multiline_steps.rb +13 -0
- data/stories/stories/stories.rb +6 -0
- data/story_server/prototype/javascripts/builder.js +136 -0
- data/story_server/prototype/javascripts/controls.js +972 -0
- data/story_server/prototype/javascripts/dragdrop.js +976 -0
- data/story_server/prototype/javascripts/effects.js +1117 -0
- data/story_server/prototype/javascripts/prototype.js +4140 -0
- data/story_server/prototype/javascripts/rspec.js +149 -0
- data/story_server/prototype/javascripts/scriptaculous.js +58 -0
- data/story_server/prototype/javascripts/slider.js +276 -0
- data/story_server/prototype/javascripts/sound.js +55 -0
- data/story_server/prototype/javascripts/unittest.js +568 -0
- data/story_server/prototype/lib/server.rb +24 -0
- data/story_server/prototype/stories.html +176 -0
- data/story_server/prototype/stylesheets/rspec.css +136 -0
- data/story_server/prototype/stylesheets/test.css +90 -0
- metadata +166 -166
- data/README +0 -36
- data/UPGRADE +0 -7
- data/bin/spec_translator +0 -8
- data/lib/spec/mocks/argument_constraint_matchers.rb +0 -31
- data/lib/spec/translator.rb +0 -114
- data/spec/spec/example/example_spec.rb +0 -53
- data/spec/spec/runner/execution_context_spec.rb +0 -37
- data/spec/spec/translator_spec.rb +0 -265
data/README
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
== RSpec
|
|
2
|
-
|
|
3
|
-
RSpec is a Behaviour Driven Development framework with tools to express User Stories
|
|
4
|
-
with Executable Scenarios and Executable Examples at the code level.
|
|
5
|
-
|
|
6
|
-
RSpec ships with several modules:
|
|
7
|
-
|
|
8
|
-
Spec::Story provides a framework for expressing User Stories and Scenarios
|
|
9
|
-
|
|
10
|
-
Spec::Example provides a framework for expressing Isolated Examples
|
|
11
|
-
|
|
12
|
-
Spec::Matchers provides Expression Matchers for use with Spec::Expectations
|
|
13
|
-
and Spec::Mocks.
|
|
14
|
-
|
|
15
|
-
Spec::Expectations supports setting expectations on your objects so you
|
|
16
|
-
can do things like:
|
|
17
|
-
|
|
18
|
-
result.should equal(expected_result)
|
|
19
|
-
|
|
20
|
-
Spec::Mocks supports creating Mock Objects, Stubs, and adding Mock/Stub
|
|
21
|
-
behaviour to your existing objects.
|
|
22
|
-
|
|
23
|
-
== Installation
|
|
24
|
-
|
|
25
|
-
The simplest approach is to install the gem (as root in some environments):
|
|
26
|
-
|
|
27
|
-
gem install -r rspec
|
|
28
|
-
|
|
29
|
-
== Building the RSpec gem
|
|
30
|
-
|
|
31
|
-
If you prefer to build the gem locally:
|
|
32
|
-
|
|
33
|
-
git clone git://github.com/dchelimsky/rspec.git
|
|
34
|
-
cd rspec
|
|
35
|
-
rake gem
|
|
36
|
-
gem install pkg/rspec-0.x.x.gem #as root
|
data/UPGRADE
DELETED
data/bin/spec_translator
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
raise "\n\nUsage: spec_translator from_dir to_dir\n\n" if ARGV.size != 2
|
|
3
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
|
4
|
-
require 'spec/translator'
|
|
5
|
-
t = ::Spec::Translator.new
|
|
6
|
-
from = ARGV[0]
|
|
7
|
-
to = ARGV[1]
|
|
8
|
-
t.translate(from, to)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
module Spec
|
|
2
|
-
module Mocks
|
|
3
|
-
module ArgumentConstraintMatchers
|
|
4
|
-
|
|
5
|
-
# Shortcut for creating an instance of Spec::Mocks::DuckTypeArgConstraint
|
|
6
|
-
def duck_type(*args)
|
|
7
|
-
DuckTypeArgConstraint.new(*args)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def any_args
|
|
11
|
-
AnyArgsConstraint.new
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def anything
|
|
15
|
-
AnyArgConstraint.new(nil)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def boolean
|
|
19
|
-
BooleanArgConstraint.new(nil)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def hash_including(expected={})
|
|
23
|
-
HashIncludingConstraint.new(expected)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def no_args
|
|
27
|
-
NoArgsConstraint.new
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
data/lib/spec/translator.rb
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
class Translator
|
|
5
|
-
def translate(from, to)
|
|
6
|
-
from = File.expand_path(from)
|
|
7
|
-
to = File.expand_path(to)
|
|
8
|
-
if File.directory?(from)
|
|
9
|
-
translate_dir(from, to)
|
|
10
|
-
elsif(from =~ /\.rb$/)
|
|
11
|
-
translate_file(from, to)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def translate_dir(from, to)
|
|
16
|
-
FileUtils.mkdir_p(to) unless File.directory?(to)
|
|
17
|
-
Dir["#{from}/*"].each do |sub_from|
|
|
18
|
-
path = sub_from[from.length+1..-1]
|
|
19
|
-
sub_to = File.join(to, path)
|
|
20
|
-
translate(sub_from, sub_to)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def translate_file(from, to)
|
|
25
|
-
translation = ""
|
|
26
|
-
File.open(from) do |io|
|
|
27
|
-
io.each_line do |line|
|
|
28
|
-
translation << translate_line(line)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
File.open(to, "w") do |io|
|
|
32
|
-
io.write(translation)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def translate_line(line)
|
|
37
|
-
# Translate deprecated mock constraints
|
|
38
|
-
line.gsub!(/:any_args/, 'any_args')
|
|
39
|
-
line.gsub!(/:anything/, 'anything')
|
|
40
|
-
line.gsub!(/:boolean/, 'boolean')
|
|
41
|
-
line.gsub!(/:no_args/, 'no_args')
|
|
42
|
-
line.gsub!(/:numeric/, 'an_instance_of(Numeric)')
|
|
43
|
-
line.gsub!(/:string/, 'an_instance_of(String)')
|
|
44
|
-
|
|
45
|
-
return line if line =~ /(should_not|should)_receive/
|
|
46
|
-
|
|
47
|
-
line.gsub!(/(^\s*)context([\s*|\(]['|"|A-Z])/, '\1describe\2')
|
|
48
|
-
line.gsub!(/(^\s*)specify([\s*|\(]['|"|A-Z])/, '\1it\2')
|
|
49
|
-
line.gsub!(/(^\s*)context_setup(\s*[do|\{])/, '\1before(:all)\2')
|
|
50
|
-
line.gsub!(/(^\s*)context_teardown(\s*[do|\{])/, '\1after(:all)\2')
|
|
51
|
-
line.gsub!(/(^\s*)setup(\s*[do|\{])/, '\1before(:each)\2')
|
|
52
|
-
line.gsub!(/(^\s*)teardown(\s*[do|\{])/, '\1after(:each)\2')
|
|
53
|
-
|
|
54
|
-
if line =~ /(.*\.)(should_not|should)(?:_be)(?!_)(.*)/m
|
|
55
|
-
pre = $1
|
|
56
|
-
should = $2
|
|
57
|
-
post = $3
|
|
58
|
-
be_or_equal = post =~ /(<|>)/ ? "be" : "equal"
|
|
59
|
-
|
|
60
|
-
return "#{pre}#{should} #{be_or_equal}#{post}"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
if line =~ /(.*\.)(should_not|should)_(?!not)\s*(.*)/m
|
|
64
|
-
pre = $1
|
|
65
|
-
should = $2
|
|
66
|
-
post = $3
|
|
67
|
-
|
|
68
|
-
post.gsub!(/^raise/, 'raise_error')
|
|
69
|
-
post.gsub!(/^throw/, 'throw_symbol')
|
|
70
|
-
|
|
71
|
-
unless standard_matcher?(post)
|
|
72
|
-
post = "be_#{post}"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Add parenthesis
|
|
76
|
-
post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\'|\"|\:|@| ]+)(\})/, '\1(\2)\3') # inside a block
|
|
77
|
-
post.gsub!(/^(redirect_to)\s+(.*)/, '\1(\2)') # redirect_to, which often has http:
|
|
78
|
-
post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\{.*\}|\'|\"|\:|@| ]+)/, '\1(\2)')
|
|
79
|
-
post.gsub!(/(\s+\))/, ')')
|
|
80
|
-
post.gsub!(/\)\}/, ') }')
|
|
81
|
-
post.gsub!(/^(\w+)\s+(\/.*\/)/, '\1(\2)') #regexps
|
|
82
|
-
line = "#{pre}#{should} #{post}"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
line
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def standard_matcher?(matcher)
|
|
89
|
-
patterns = [
|
|
90
|
-
/^be/,
|
|
91
|
-
/^be_close/,
|
|
92
|
-
/^eql/,
|
|
93
|
-
/^equal/,
|
|
94
|
-
/^has/,
|
|
95
|
-
/^have/,
|
|
96
|
-
/^change/,
|
|
97
|
-
/^include/,
|
|
98
|
-
/^match/,
|
|
99
|
-
/^raise_error/,
|
|
100
|
-
/^respond_to/,
|
|
101
|
-
/^redirect_to/,
|
|
102
|
-
/^satisfy/,
|
|
103
|
-
/^throw_symbol/,
|
|
104
|
-
# Extra ones that we use in spec_helper
|
|
105
|
-
/^pass/,
|
|
106
|
-
/^fail/,
|
|
107
|
-
/^fail_with/,
|
|
108
|
-
]
|
|
109
|
-
matched = patterns.detect{ |p| matcher =~ p }
|
|
110
|
-
!matched.nil?
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
-
|
|
3
|
-
module Spec
|
|
4
|
-
module Example
|
|
5
|
-
# describe Example do
|
|
6
|
-
# before(:each) do
|
|
7
|
-
# @example = Example.new "example" do
|
|
8
|
-
# foo
|
|
9
|
-
# end
|
|
10
|
-
# end
|
|
11
|
-
#
|
|
12
|
-
# it "should tell you its docstring" do
|
|
13
|
-
# @example.description.should == "example"
|
|
14
|
-
# end
|
|
15
|
-
#
|
|
16
|
-
# it "should execute its block in the context provided" do
|
|
17
|
-
# context = Class.new do
|
|
18
|
-
# def foo
|
|
19
|
-
# "foo"
|
|
20
|
-
# end
|
|
21
|
-
# end.new
|
|
22
|
-
# @example.run_in(context).should == "foo"
|
|
23
|
-
# end
|
|
24
|
-
# end
|
|
25
|
-
#
|
|
26
|
-
# describe Example, "#description" do
|
|
27
|
-
# it "should default to NO NAME when not passed anything when there are no matchers" do
|
|
28
|
-
# example = Example.new {}
|
|
29
|
-
# example.run_in(Object.new)
|
|
30
|
-
# example.description.should == "NO NAME"
|
|
31
|
-
# end
|
|
32
|
-
#
|
|
33
|
-
# it "should default to NO NAME description (Because of --dry-run) when passed nil and there are no matchers" do
|
|
34
|
-
# example = Example.new(nil) {}
|
|
35
|
-
# example.run_in(Object.new)
|
|
36
|
-
# example.description.should == "NO NAME"
|
|
37
|
-
# end
|
|
38
|
-
#
|
|
39
|
-
# it "should allow description to be overridden" do
|
|
40
|
-
# example = Example.new("Test description")
|
|
41
|
-
# example.description.should == "Test description"
|
|
42
|
-
# end
|
|
43
|
-
#
|
|
44
|
-
# it "should use description generated from matcher when there is no passed in description" do
|
|
45
|
-
# example = Example.new(nil) do
|
|
46
|
-
# 1.should == 1
|
|
47
|
-
# end
|
|
48
|
-
# example.run_in(Object.new)
|
|
49
|
-
# example.description.should == "should == 1"
|
|
50
|
-
# end
|
|
51
|
-
# end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
|
-
|
|
3
|
-
describe "ExecutionContext" do
|
|
4
|
-
|
|
5
|
-
it "should provide duck_type()" do
|
|
6
|
-
dt = duck_type(:length)
|
|
7
|
-
dt.should be_an_instance_of(Spec::Mocks::DuckTypeArgConstraint)
|
|
8
|
-
dt.matches?([]).should be_true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should provide hash_including" do
|
|
12
|
-
hi = hash_including(:a => 1)
|
|
13
|
-
hi.should be_an_instance_of(Spec::Mocks::HashIncludingConstraint)
|
|
14
|
-
hi.matches?(:a => 1).should be_true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should violate when violated()" do
|
|
18
|
-
lambda do
|
|
19
|
-
violated
|
|
20
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should provide mock()" do
|
|
24
|
-
mock("thing").should be_an_instance_of(Spec::Mocks::Mock)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should provide stub()" do
|
|
28
|
-
thing_stub = stub("thing").should be_an_instance_of(Spec::Mocks::Mock)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should add method stubs to stub()" do
|
|
32
|
-
thing_stub = stub("thing", :a => "A", :b => "B")
|
|
33
|
-
thing_stub.a.should == "A"
|
|
34
|
-
thing_stub.b.should == "B"
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
-
require 'spec/translator'
|
|
3
|
-
|
|
4
|
-
describe "Translator" do
|
|
5
|
-
before do
|
|
6
|
-
@t = Spec::Translator.new
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "should translate files" do
|
|
10
|
-
from = File.dirname(__FILE__) + '/..'
|
|
11
|
-
to = "#{Dir.tmpdir}/translated_specs"
|
|
12
|
-
@t.translate_dir(from, to)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should translate context_setup do" do
|
|
16
|
-
@t.translate_line(
|
|
17
|
-
"context_setup do\n"
|
|
18
|
-
).should eql(
|
|
19
|
-
"before(:all) do\n"
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should translate context_setup {foo}" do
|
|
24
|
-
@t.translate_line(
|
|
25
|
-
"context_setup {foo}\n"
|
|
26
|
-
).should eql(
|
|
27
|
-
"before(:all) {foo}\n"
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should translate context ' to describe '" do
|
|
32
|
-
@t.translate_line(
|
|
33
|
-
"context 'Translator' do\n"
|
|
34
|
-
).should eql(
|
|
35
|
-
"describe 'Translator' do\n"
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'should translate context " to describe "' do
|
|
40
|
-
@t.translate_line(
|
|
41
|
-
'context "Translator"'
|
|
42
|
-
).should eql(
|
|
43
|
-
'describe "Translator"'
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'should translate spaces then context " to describe "' do
|
|
48
|
-
@t.translate_line(
|
|
49
|
-
' context "Translator"'
|
|
50
|
-
).should eql(
|
|
51
|
-
' describe "Translator"'
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should not translate context=foo" do
|
|
56
|
-
@t.translate_line(' context=foo').should eql(' context=foo')
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should not translate context = foo" do
|
|
60
|
-
@t.translate_line(' context = foo').should eql(' context = foo')
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should not translate context = foo" do
|
|
64
|
-
@t.translate_line(' context = foo').should eql(' context = foo')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should translate should_be_close" do
|
|
68
|
-
@t.translate_line('5.0.should_be_close(5.0, 0.5)').should eql('5.0.should be_close(5.0, 0.5)')
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should translate should_not_raise" do
|
|
72
|
-
@t.translate_line('lambda { self.call }.should_not_raise').should eql('lambda { self.call }.should_not raise_error')
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should translate should_throw" do
|
|
76
|
-
@t.translate_line('lambda { self.call }.should_throw').should eql('lambda { self.call }.should throw_symbol')
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "should not translate 0.9 should_not" do
|
|
80
|
-
@t.translate_line('@target.should_not @matcher').should eql('@target.should_not @matcher')
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should leave should_not_receive" do
|
|
84
|
-
@t.translate_line('@mock.should_not_receive(:not_expected).with("unexpected text")').should eql('@mock.should_not_receive(:not_expected).with("unexpected text")')
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "should leave should_receive" do
|
|
88
|
-
@t.translate_line('@mock.should_receive(:not_expected).with("unexpected text")').should eql('@mock.should_receive(:not_expected).with("unexpected text")')
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should translate multi word predicates" do
|
|
92
|
-
@t.translate_line('foo.should_multi_word_predicate').should eql('foo.should be_multi_word_predicate')
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "should translate multi word predicates prefixed with be" do
|
|
96
|
-
@t.translate_line('foo.should_be_multi_word_predicate').should eql('foo.should be_multi_word_predicate')
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "should translate be(expected) to equal(expected)" do
|
|
100
|
-
@t.translate_line('foo.should_be :cool').should eql('foo.should equal :cool')
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "should translate instance_of" do
|
|
104
|
-
@t.translate_line('5.should_be_an_instance_of(Integer)').should eql('5.should be_an_instance_of(Integer)')
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "should translate should_be <" do
|
|
108
|
-
@t.translate_line('3.should_be < 4').should eql('3.should be < 4')
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should translate should_be <=" do
|
|
112
|
-
@t.translate_line('3.should_be <= 4').should eql('3.should be <= 4')
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "should translate should_be >=" do
|
|
116
|
-
@t.translate_line('4.should_be >= 3').should eql('4.should be >= 3')
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should translate should_be >" do
|
|
120
|
-
@t.translate_line('4.should_be > 3').should eql('4.should be > 3')
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "should translate should_be_happy" do
|
|
124
|
-
@t.translate_line("4.should_be_happy").should eql("4.should be_happy")
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should translate custom method taking regexp with parenthesis" do
|
|
128
|
-
@t.translate_line("@browser.should_contain_text(/Sn.rrunger og annet rusk/)").should eql("@browser.should be_contain_text(/Sn.rrunger og annet rusk/)")
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "should translate custom method taking regexp without parenthesis" do
|
|
132
|
-
@t.translate_line("@browser.should_contain_text /Sn.rrunger og annet rusk/\n").should eql("@browser.should be_contain_text(/Sn.rrunger og annet rusk/)\n")
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "should translate should_not_be_nil" do
|
|
136
|
-
@t.translate_line("foo.should_not_be_nil\n").should eql("foo.should_not be_nil\n")
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "should translate kind of" do
|
|
140
|
-
@t.translate_line('@object.should_be_kind_of(MessageExpectation)').should(
|
|
141
|
-
eql('@object.should be_kind_of(MessageExpectation)'))
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "should translate should_be_true" do
|
|
145
|
-
@t.translate_line("foo.should_be_true\n").should eql("foo.should be_true\n")
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
# [#9674] spec_translate incorrectly handling shoud_match, when regexp in a var, in a block
|
|
149
|
-
# http://rubyforge.org/tracker/?func=detail&atid=3149&aid=9674&group_id=797
|
|
150
|
-
it "should translate should_match on a regexp, in a var, in a block" do
|
|
151
|
-
@t.translate_line("collection.each { |c| c.should_match a_regexp_in_a_var }\n").should eql("collection.each { |c| c.should match(a_regexp_in_a_var) }\n")
|
|
152
|
-
@t.translate_line("collection.each{|c| c.should_match a_regexp_in_a_var}\n").should eql("collection.each{|c| c.should match(a_regexp_in_a_var) }\n")
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
# From Rubinius specs
|
|
156
|
-
it "should translate close_to without parens" do
|
|
157
|
-
@t.translate_line("end.should_be_close 3.14159_26535_89793_23846, TOLERANCE\n").should eql("end.should be_close(3.14159_26535_89793_23846, TOLERANCE)\n")
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# [#9882] 0.9 Beta 1 - translator bugs
|
|
161
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149
|
|
162
|
-
it "should support symbol arguments" do
|
|
163
|
-
@t.translate_line(
|
|
164
|
-
"lambda { sequence.parse('bar') }.should_throw :ZeroWidthParseSuccess\n"
|
|
165
|
-
).should eql(
|
|
166
|
-
"lambda { sequence.parse('bar') }.should throw_symbol(:ZeroWidthParseSuccess)\n"
|
|
167
|
-
)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# [#9882] 0.9 Beta 1 - translator bugs
|
|
171
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149
|
|
172
|
-
it "should support instance var arguments" do
|
|
173
|
-
@t.translate_line(
|
|
174
|
-
"a.should_eql @local"
|
|
175
|
-
).should eql(
|
|
176
|
-
"a.should eql(@local)"
|
|
177
|
-
)
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# [#9882] 0.9 Beta 1 - translator bugs
|
|
181
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149
|
|
182
|
-
it "should support lambdas as expecteds" do
|
|
183
|
-
@t.translate_line(
|
|
184
|
-
"@parslet.should_not_eql lambda { nil }.to_parseable"
|
|
185
|
-
).should eql(
|
|
186
|
-
"@parslet.should_not eql(lambda { nil }.to_parseable)"
|
|
187
|
-
)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
# [#9882] 0.9 Beta 1 - translator bugs
|
|
191
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149
|
|
192
|
-
it "should support fully qualified names" do
|
|
193
|
-
@t.translate_line(
|
|
194
|
-
"results.should_be_kind_of SimpleASTLanguage::Identifier"
|
|
195
|
-
).should eql(
|
|
196
|
-
"results.should be_kind_of(SimpleASTLanguage::Identifier)"
|
|
197
|
-
)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
# [#9882] 0.9 Beta 1 - translator bugs
|
|
201
|
-
# http://rubyforge.org/tracker/index.php?func=detail&aid=9882&group_id=797&atid=3149
|
|
202
|
-
# it "should leave whitespace between expression and comments" do
|
|
203
|
-
# @t.translate_line(
|
|
204
|
-
# "lambda { @instance.foo = foo }.should_raise NoMethodError # no writer defined"
|
|
205
|
-
# ).should eql(
|
|
206
|
-
# "lambda { @instance.foo = foo }.should raise_error(NoMethodError) # no writer defined"
|
|
207
|
-
# )
|
|
208
|
-
# end
|
|
209
|
-
|
|
210
|
-
it "should translate redirects" do
|
|
211
|
-
@t.translate_line(
|
|
212
|
-
"controller.should_redirect_to 'http://not_existing_domain_for_novalis.test.host/404.html'"
|
|
213
|
-
).should eql(
|
|
214
|
-
"controller.should redirect_to('http://not_existing_domain_for_novalis.test.host/404.html')"
|
|
215
|
-
)
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it "should translate :any_args" do
|
|
219
|
-
@t.translate_line(
|
|
220
|
-
"mock.should_receive(:foo).with(:any_args)"
|
|
221
|
-
).should eql(
|
|
222
|
-
"mock.should_receive(:foo).with(any_args)"
|
|
223
|
-
)
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
it "should translate :anything" do
|
|
227
|
-
@t.translate_line(
|
|
228
|
-
"mock.should_receive(:foo).with(:anything)"
|
|
229
|
-
).should eql(
|
|
230
|
-
"mock.should_receive(:foo).with(anything)"
|
|
231
|
-
)
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
it "should translate :boolean" do
|
|
235
|
-
@t.translate_line(
|
|
236
|
-
"mock.should_receive(:foo).with(:boolean)"
|
|
237
|
-
).should eql(
|
|
238
|
-
"mock.should_receive(:foo).with(boolean)"
|
|
239
|
-
)
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it "should translate :no_args" do
|
|
243
|
-
@t.translate_line(
|
|
244
|
-
"mock.should_receive(:foo).with(:no_args)"
|
|
245
|
-
).should eql(
|
|
246
|
-
"mock.should_receive(:foo).with(no_args)"
|
|
247
|
-
)
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it "should translate :numeric" do
|
|
251
|
-
@t.translate_line(
|
|
252
|
-
"mock.should_receive(:foo).with(:numeric)"
|
|
253
|
-
).should eql(
|
|
254
|
-
"mock.should_receive(:foo).with(an_instance_of(Numeric))"
|
|
255
|
-
)
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
it "should translate :string" do
|
|
259
|
-
@t.translate_line(
|
|
260
|
-
"mock.should_receive(:foo).with(:string)"
|
|
261
|
-
).should eql(
|
|
262
|
-
"mock.should_receive(:foo).with(an_instance_of(String))"
|
|
263
|
-
)
|
|
264
|
-
end
|
|
265
|
-
end
|