diff options
author | Louise Crow <louise.crow@gmail.com> | 2011-02-24 15:10:14 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2011-02-24 15:10:14 +0000 |
commit | 08a64f9e3139851fd65c7ba6969ee590b4afea6a (patch) | |
tree | 20c77e796002dfa95b2af3ba00ebd2f691c02fc7 /vendor/gems/rspec-1.3.1/features/step_definitions | |
parent | 3757bb52c0aa86b779b00428d7ebe35b30cea1ee (diff) |
Adding rspec gem.
Diffstat (limited to 'vendor/gems/rspec-1.3.1/features/step_definitions')
-rw-r--r-- | vendor/gems/rspec-1.3.1/features/step_definitions/running_rspec_steps.rb | 52 | ||||
-rw-r--r-- | vendor/gems/rspec-1.3.1/features/step_definitions/stubbing_steps.rb | 16 |
2 files changed, 68 insertions, 0 deletions
diff --git a/vendor/gems/rspec-1.3.1/features/step_definitions/running_rspec_steps.rb b/vendor/gems/rspec-1.3.1/features/step_definitions/running_rspec_steps.rb new file mode 100644 index 000000000..746e8793b --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/step_definitions/running_rspec_steps.rb @@ -0,0 +1,52 @@ +Given %r{^a file named "([^"]+)" with:$} do |file_name, code| + create_file(file_name, code) +end + +Given /^a directory named "([^\"]*)"$/ do |dirname| + create_directory(dirname) +end + +When %r{^I run "spec ([^"]+)"$} do |file_and_args| + spec(file_and_args) +end + +When %r{^I run "ruby ([^"]+)"$} do |file_and_args| + ruby(file_and_args) +end + +When %r{^I run "cmdline.rb ([^"]+)"$} do |file_and_args| + cmdline(file_and_args) +end + +Then /^the (.*) should include (.*)$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then last_stdout + when 'stderr' then last_stderr + else raise "Unknown stream: #{stream}" + end + written.should smart_match(string_or_regex) +end + +Then /^the (.*) should include$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then last_stdout + when 'stderr' then last_stderr + else raise "Unknown stream: #{stream}" + end + written.should smart_match(string_or_regex) +end + +Then /^the (.*) should not match (.*)$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then last_stdout + when 'stderr' then last_stderr + else raise "Unknown stream: #{stream}" + end + written.should_not smart_match(string_or_regex) +end + +Then /^the exit code should be (\d+)$/ do |exit_code| + if last_exit_code != exit_code.to_i + raise "Did not exit with #{exit_code}, but with #{last_exit_code}. Standard error:\n#{last_stderr}" + end +end diff --git a/vendor/gems/rspec-1.3.1/features/step_definitions/stubbing_steps.rb b/vendor/gems/rspec-1.3.1/features/step_definitions/stubbing_steps.rb new file mode 100644 index 000000000..cc194f31c --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/step_definitions/stubbing_steps.rb @@ -0,0 +1,16 @@ +When /^I stub "([^\"]*)" on "([^\"]*)" to "([^\"]*)"$/ do |method_name, const_name, value| + const = Object.const_get(const_name) + const.stub!(method_name.to_sym).and_return(value) +end + +Then /^calling "([^\"]*)" on "([^\"]*)" should return "([^\"]*)"$/ do |method_name, const_name, value| + const = Object.const_get(const_name) + const.send(method_name.to_sym).should == value +end + +Then /^"([^\"]*)" should not be defined on "([^\"]*)"$/ do |method_name, const_name| + const = Object.const_get(const_name) + lambda { + const.send(method_name.to_sym) + }.should raise_error(NameError, /#{method_name}/) +end |