rspec-its-1.3.0/0000755000004100000410000000000013455462614013466 5ustar www-datawww-datarspec-its-1.3.0/.travis.yml0000644000004100000410000000076513455462614015607 0ustar www-datawww-datalanguage: ruby script: "script/test_all" email: false before_install: - script/update_rubygems_and_install_bundler bundler_args: "--standalone --binstubs --without documentation" rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - 2.1 - 2.2.10 - 2.3.8 - 2.4.5 - 2.5.3 - 2.6.0 - ruby-head - ree - jruby-9.2.5.0 - jruby-head - jruby-1.7.27 - rbx-3 env: - JRUBY_OPTS='--dev' matrix: allow_failures: - rvm: jruby-head - rvm: ruby-head - rvm: rbx-3 fast_finish: true rspec-its-1.3.0/.rspec0000644000004100000410000000004013455462614014575 0ustar www-datawww-data--color --order rand --warnings rspec-its-1.3.0/README.md0000644000004100000410000000464113455462614014752 0ustar www-datawww-data# RSpec::Its [![Build Status](https://travis-ci.org/rspec/rspec-its.svg)](https://travis-ci.org/rspec/rspec-its) RSpec::Its provides the `its` method as a short-hand to specify the expected value of an attribute. ## Installation Add this line to your application's Gemfile: ```ruby gem 'rspec-its' ``` And then execute: $ bundle Or install it yourself as: $ gem install rspec-its And require it as: ```ruby require 'rspec/its' ``` ## Usage Use the `its` method to generate a nested example group with a single example that specifies the expected value of an attribute of the subject using `should`, `should_not` or `is_expected`. The `its` method can also specify the block expectations of an attribute of the subject using `will` or `will_not`. `its` accepts a symbol or a string, and a block representing the example. ```ruby its(:size) { should eq(1) } its("length") { should eq(1) } ``` You can use a string with dots to specify a nested attribute (i.e. an attribute of the attribute of the subject). ```ruby its("phone_numbers.size") { should_not eq(0) } ``` The following expect-style method is also available: ```ruby its(:size) { is_expected.to eq(1) } ``` as is this alias for pluralized use: ```ruby its(:keys) { are_expected.to eq([:key1, :key2]) } ``` The following block expect-style method is also available: ```ruby its(:size) { will_not raise_error } ``` as is this alias for pluralized use: ```ruby its(:keys) { will raise_error(NoMethodError) } ``` When the subject implements the `[]` operator, you can pass in an array with a single key to refer to the value returned by that operator when passed that key as an argument. ```ruby its([:key]) { is_expected.to eq(value) } ``` For hashes, multiple keys within the array will result in successive accesses into the hash. For example: ```ruby subject { {key1: {key2: 3} } } its([:key1, :key2]) { is_expected.to eq(3) } ``` For other objects, multiple keys within the array will be passed as separate arguments in a single method call to [], as in: ```ruby subject { Matrix[ [:a, :b], [:c, :d] ] } its([1,1]) { should eq(:d) } ``` Metadata arguments are supported. ```ruby its(:size, focus: true) { should eq(1) } ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request rspec-its-1.3.0/spec/0000755000004100000410000000000013455462614014420 5ustar www-datawww-datarspec-its-1.3.0/spec/rspec/0000755000004100000410000000000013455462614015534 5ustar www-datawww-datarspec-its-1.3.0/spec/rspec/its_spec.rb0000644000004100000410000002565513455462614017707 0ustar www-datawww-datarequire 'spec_helper' module RSpec describe Its do describe "#its" do context "with implicit subject" do context "preserves described_class" do its(:symbol) { expect(described_class).to be Its } its([]) { expect(described_class).to be Its } end end context "with explicit subject" do subject do Class.new do def initialize @call_count = 0 end def call_count @call_count += 1 end end.new end before(:each, :meta) do subject.call_count end context "with some metadata" do its(:call_count, :meta) { should eq(2) } end context "with a call counter" do its(:call_count) { should eq(1) } end context "with nil value" do subject do Class.new do def nil_value nil end end.new end its(:nil_value) { should be_nil } end context "with nested attributes" do subject do Class.new do def name "John" end end.new end its("name") { should eq("John") } its("name.size") { should eq(4) } if RUBY_VERSION >= "2.4.0" its("name.size.class") { should eq(Integer) } else its("name.size.class") { should eq(Fixnum) } end context "using should_not" do its("name") { should_not eq("Paul") } end context "using is_expected" do its("name") { is_expected.to eq("John") } end context "using will_not" do its("name") { will_not raise_error } end context "using are_expected" do its("name.chars.to_a") { are_expected.to eq(%w[J o h n]) } end end context "when it responds to #[]" do subject do Class.new do def [](*objects) objects.map do |object| "#{object.class}: #{object.to_s}" end.join("; ") end def name "George" end end.new end its([:a]) { should eq("Symbol: a") } its(['a']) { should eq("String: a") } if RUBY_VERSION >= "2.4.0" its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Integer: 4") } else its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") } end its(:name) { should eq("George") } context "when referring to an attribute that doesn't exist" do context "it raises an error" do its(:age) do expect do should eq(64) end.to raise_error(NoMethodError) end context "using will" do its(:age) { will raise_error(NoMethodError) } end end end context "when it's a hash" do subject { {:a => {:deep => {:key => "value"}}} } its([:a]) { should eq({:deep => {:key => "value"}}) } its([:a, :deep]) { should eq({:key => "value"}) } its([:a, :deep, :key]) { should eq("value") } context "when referring to a key that doesn't exist" do its([:not_here]) { should be_nil } its([:a, :ghost]) { should be_nil } its([:deep, :ghost]) { expect { should eq("missing") }.to raise_error(NoMethodError) } context "using will" do its([:deep, :ghost]) { will raise_error(NoMethodError) } end end end end context "when it does not respond to #[]" do subject { Object.new } context "it raises an error" do its([:a]) do expect do should eq("Symbol: a") end.to raise_error(NoMethodError) end context "using will" do its([:a]) { will raise_error(NoMethodError) } end end end context "calling and overriding super" do it "calls to the subject defined in the parent group" do group = RSpec::Core::ExampleGroup.describe(Array) do subject { [1, 'a'] } its(:last) { should eq("a") } describe '.first' do def subject; super().first; end its(:next) { should eq(2) } end end expect(group.run(NullFormatter.new)).to be_truthy end end context "with nil subject" do subject do Class.new do def initialize @counter = -1 end def nil_if_first_time @counter += 1 @counter == 0 ? nil : true end end.new end its(:nil_if_first_time) { should be(nil) } end context "with false subject" do subject do Class.new do def initialize @counter = -1 end def false_if_first_time @counter += 1 @counter > 0 end end.new end its(:false_if_first_time) { should be(false) } end describe 'accessing `subject` in `before` and `let`' do subject { 'my subject' } before { @subject_in_before = subject } let(:subject_in_let) { subject } let!(:eager_loaded_subject_in_let) { subject } # These examples read weird, because we're actually # specifying the behaviour of `its` itself its(nil) { expect(subject).to eq('my subject') } its(nil) { expect(@subject_in_before).to eq('my subject') } its(nil) { expect(subject_in_let).to eq('my subject') } its(nil) { expect(eager_loaded_subject_in_let).to eq('my subject') } end describe "in shared_context" do shared_context "shared stuff" do subject { Array } its(:name) { should eq "Array" } end include_context "shared stuff" end describe "when extending SharedContext" do it 'works with an implicit subject' do shared = Module.new do extend RSpec::SharedContext its(:size) { should eq 0 } end group = RSpec::Core::ExampleGroup.describe(Array) do include shared end group.run(NullFormatter.new) result = group.children.first.examples.first.execution_result # Following conditional needed to work across mix of RSpec and ruby versions without warning status = result.respond_to?(:status) ? result.status : result[:status].to_sym expect(status).to eq(:passed) end end end context "with metadata" do context "preserves access to metadata that doesn't end in hash" do its([], :foo) do |example| expect(example.metadata[:foo]).to be(true) end end context "preserves access to metadata that ends in hash" do its([], :foo, :bar => 17) do |example| expect(example.metadata[:foo]).to be(true) expect(example.metadata[:bar]).to be(17) end end end context "when expecting errors" do subject do Class.new do def good; end def bad raise ArgumentError, "message" end end.new end its(:good) { will_not raise_error } its(:bad) { will raise_error } its(:bad) { will raise_error(ArgumentError) } its(:bad) { will raise_error("message") } its(:bad) { will raise_error(ArgumentError, "message") } end context "when expecting throws" do subject do Class.new do def good; end def bad throw :abort, "message" end end.new end its(:good) { will_not throw_symbol } its(:bad) { will throw_symbol } its(:bad) { will throw_symbol(:abort) } its(:bad) { will throw_symbol(:abort, "message") } end context "with change observation" do subject do Class.new do attr_reader :count def initialize @count = 0 end def increment @count += 1 end def noop; end end.new end its(:increment) { will change { subject.count }.by(1) } its(:increment) { will change { subject.count }.from(0) } its(:increment) { will change { subject.count }.from(0).to(1) } its(:increment) { will change { subject.count }.by_at_least(1) } its(:increment) { will change { subject.count }.by_at_most(1) } its(:noop) { will_not change { subject.count } } its(:noop) { will_not change { subject.count }.from(0) } its(:increment) do expect { will_not change { subject.count }.by(0) }.to \ raise_error(NotImplementedError, '`expect { }.not_to change { }.by()` is not supported') end its(:increment) do expect { will_not change { subject.count }.by_at_least(2) }.to \ raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_least()` is not supported') end its(:increment) do expect { will_not change { subject.count }.by_at_most(3) }.to \ raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_most()` is not supported') end end context "with output capture" do subject do Class.new do def stdout print "some output" end def stderr $stderr.print "some error" end def noop; end end.new end its(:stdout) { will output("some output").to_stdout } its(:stderr) { will output("some error").to_stderr } its(:noop) { will_not output("some error").to_stderr } its(:noop) { will_not output("some output").to_stdout } end context "#will with non block expectations" do subject do Class.new do def terminator "back" end end.new end its(:terminator) do expect { will be("back") }.to \ raise_error(ArgumentError, '`will` only supports block expectations') end its(:terminator) do expect { will_not be("back") }.to \ raise_error(ArgumentError, '`will_not` only supports block expectations') end end end end end rspec-its-1.3.0/spec/spec_helper.rb0000644000004100000410000000042313455462614017235 0ustar www-datawww-datarequire 'rspec/its' Dir['./spec/support/**/*'].each {|f| require f} class NullFormatter private def method_missing(method, *args, &block) # ignore end end RSpec.configure do |config| config.run_all_when_everything_filtered = true config.order = 'random' end rspec-its-1.3.0/rspec-its.gemspec0000644000004100000410000000312713455462614016747 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rspec/its/version' Gem::Specification.new do |spec| spec.name = "rspec-its" spec.version = RSpec::Its::VERSION spec.authors = ["Peter Alfvin"] spec.email = ["palfvin@gmail.com"] spec.description = %q{RSpec extension gem for attribute matching} spec.summary = %q{Provides "its" method formerly part of rspec-core} spec.homepage = "https://github.com/rspec/rspec-its" spec.license = "MIT" spec.metadata = { 'bug_tracker_uri' => 'https://github.com/rspec/rspec-its/issues', 'changelog_uri' => "https://github.com/rspec/rspec-its/blob/v#{spec.version}/Changelog.md", 'documentation_uri' => "https://www.rubydoc.info/gems/rspec-its/#{spec.version}", 'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/rspec', 'source_code_uri' => 'https://github.com/rspec/rspec-its', } spec.files = `git ls-files`.split($/) - %w[cucumber.yml] spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_runtime_dependency 'rspec-core', '>= 3.0.0' spec.add_runtime_dependency 'rspec-expectations', '>= 3.0.0' spec.add_development_dependency 'bundler', '> 1.3.0' spec.add_development_dependency 'rake', '~> 10.1.0' spec.add_development_dependency 'cucumber', '~> 1.3.8' spec.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7 end rspec-its-1.3.0/.gitignore0000644000004100000410000000026513455462614015461 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc .ruby-version .ruby-gemset Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp rspec-its-1.3.0/script/0000755000004100000410000000000013455462614014772 5ustar www-datawww-datarspec-its-1.3.0/script/test_all0000755000004100000410000000137513455462614016535 0ustar www-datawww-data#!/bin/bash set -e -x # idea taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html export JRUBY_OPTS='-X-C' # disable JIT since these processes are so short lived # force jRuby to use client mode JVM or a compilation mode thats as close as possible, # idea taken from https://github.com/jruby/jruby/wiki/Improving-startup-time export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' echo "Running rspec specs" bin/rspec spec --format progress --profile echo "Running cucumber specs" if ruby -e "exit(defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java')"; then # This is JRUBY which requires this one weird path trick... PATH="${PWD}/bin:$PATH" \ bundle exec cucumber --strict else bundle exec cucumber --strict fi; rspec-its-1.3.0/script/update_rubygems_and_install_bundler0000755000004100000410000000100313455462614024174 0ustar www-datawww-data#!/bin/bash # This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e function is_ruby_23_plus { if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then return 0 else return 1 fi } if is_ruby_23_plus; then gem update --system gem install bundler else echo "Warning installing older versions of Rubygems / Bundler" gem update --system '2.7.8' gem install bundler -v '1.17.3' fi rspec-its-1.3.0/Rakefile0000644000004100000410000000046313455462614015136 0ustar www-datawww-datarequire "bundler" Bundler.setup Bundler::GemHelper.install_tasks require "rake" require "rspec/core/rake_task" require "cucumber/rake/task" Cucumber::Rake::Task.new(:cucumber) desc "Run all examples" RSpec::Core::RakeTask.new(:spec) do |t| t.ruby_opts = %w[-w] end task :default => [:spec, :cucumber] rspec-its-1.3.0/lib/0000755000004100000410000000000013455462614014234 5ustar www-datawww-datarspec-its-1.3.0/lib/rspec/0000755000004100000410000000000013455462614015350 5ustar www-datawww-datarspec-its-1.3.0/lib/rspec/its/0000755000004100000410000000000013455462614016147 5ustar www-datawww-datarspec-its-1.3.0/lib/rspec/its/version.rb0000644000004100000410000000007213455462614020160 0ustar www-datawww-datamodule RSpec module Its VERSION = "1.3.0" end end rspec-its-1.3.0/lib/rspec/its.rb0000644000004100000410000001241413455462614016476 0ustar www-datawww-datarequire 'rspec/its/version' require 'rspec/core' module RSpec module Its # Creates a nested example group named by the submitted `attribute`, # and then generates an example using the submitted block. # # @example # # # This ... # describe Array do # its(:size) { should eq(0) } # end # # # ... generates the same runtime structure as this: # describe Array do # describe "size" do # it "should eq(0)" do # subject.size.should eq(0) # end # end # end # # The attribute can be a `Symbol` or a `String`. Given a `String` # with dots, the result is as though you concatenated that `String` # onto the subject in an expression. # # @example # # describe Person do # subject do # Person.new.tap do |person| # person.phone_numbers << "555-1212" # end # end # # its("phone_numbers.first") { should eq("555-1212") } # end # # When the subject is a `Hash`, you can refer to the Hash keys by # specifying a `Symbol` or `String` in an array. # # @example # # describe "a configuration Hash" do # subject do # { :max_users => 3, # 'admin' => :all_permissions. # 'john_doe' => {:permissions => [:read, :write]}} # end # # its([:max_users]) { should eq(3) } # its(['admin']) { should eq(:all_permissions) } # its(['john_doe', :permissions]) { should eq([:read, :write]) } # # # You can still access its regular methods this way: # its(:keys) { should include(:max_users) } # its(:count) { should eq(2) } # end # # With an implicit subject, `is_expected` can be used as an alternative # to `should` (e.g. for one-liner use). An `are_expected` alias is also # supplied. # # @example # # describe Array do # its(:size) { is_expected.to eq(0) } # end # # With an implicit subject, `will` can be used as an alternative # to `expect { subject.attribute }.to matcher` (e.g. for one-liner use). # # @example # # describe Array do # its(:foo) { will raise_error(NoMethodError) } # end # # With an implicit subject, `will_not` can be used as an alternative # to `expect { subject.attribute }.to_not matcher` (e.g. for one-liner use). # # @example # # describe Array do # its(:size) { will_not raise_error } # end # # You can pass more than one argument on the `its` block to add # some metadata to the generated example # # @example # # # This ... # describe Array do # its(:size, :focus) { should eq(0) } # end # # # ... generates the same runtime structure as this: # describe Array do # describe "size" do # it "should eq(0)", :focus do # subject.size.should eq(0) # end # end # end # # Note that this method does not modify `subject` in any way, so if you # refer to `subject` in `let` or `before` blocks, you're still # referring to the outer subject. # # @example # # describe Person do # subject { Person.new } # before { subject.age = 25 } # its(:age) { should eq(25) } # end def its(attribute, *options, &block) its_caller = caller.select {|file_line| file_line !~ %r(/lib/rspec/its) } describe(attribute.to_s, :caller => its_caller) do let(:__its_subject) do if Array === attribute if Hash === subject attribute.inject(subject) {|inner, attr| inner[attr] } else subject[*attribute] end else attribute_chain = attribute.to_s.split('.') attribute_chain.inject(subject) do |inner_subject, attr| inner_subject.send(attr) end end end def is_expected expect(__its_subject) end alias_method :are_expected, :is_expected def will(matcher=nil, message=nil) unless matcher.supports_block_expectations? raise ArgumentError, "`will` only supports block expectations" end expect { __its_subject }.to matcher, message end def will_not(matcher=nil, message=nil) unless matcher.supports_block_expectations? raise ArgumentError, "`will_not` only supports block expectations" end expect { __its_subject }.to_not matcher, message end def should(matcher=nil, message=nil) RSpec::Expectations::PositiveExpectationHandler.handle_matcher(__its_subject, matcher, message) end def should_not(matcher=nil, message=nil) RSpec::Expectations::NegativeExpectationHandler.handle_matcher(__its_subject, matcher, message) end options << {} unless options.last.kind_of?(Hash) options.last.merge!(:caller => its_caller) example(nil, *options, &block) end end end end RSpec.configure do |rspec| rspec.extend RSpec::Its rspec.backtrace_exclusion_patterns << %r(/lib/rspec/its) end RSpec::SharedContext.send(:include, RSpec::Its) rspec-its-1.3.0/Gemfile0000644000004100000410000000175513455462614014771 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in rspec-its.gemspec gemspec %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| branch = ENV.fetch('BRANCH','3-1-maintenance') library_path = File.expand_path("../../#{lib}", __FILE__) if File.exist?(library_path) && !ENV['USE_GIT_REPOS'] gem lib, :path => library_path else gem lib, :git => "git://github.com/rspec/#{lib}.git", :branch => branch end end if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/) gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows elsif RUBY_VERSION < '1.9' gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19 else gem 'ffi', '~> 1.9.25' end # test coverage # gem 'simplecov', :require => false gem 'coveralls', :require => false, :platform => :mri_20 eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom') platform :rbx do gem 'rubysl' end rspec-its-1.3.0/features/0000755000004100000410000000000013455462614015304 5ustar www-datawww-datarspec-its-1.3.0/features/step_definitions/0000755000004100000410000000000013455462614020652 5ustar www-datawww-datarspec-its-1.3.0/features/step_definitions/additional_cli_steps.rb0000644000004100000410000000247113455462614025360 0ustar www-datawww-dataWhen /^I run rspec( with the documentation option)?$/ do |documentation| rspec_its_gem_location = File.expand_path('../../../lib/rspec/its', __FILE__) require_option = "--require #{rspec_its_gem_location}" format_option = documentation ? "--format documentation" : "" rspec_command = ['rspec', require_option, format_option, 'example_spec.rb'].join(' ') step "I run `#{rspec_command}`" end When /^I run rspec specifying line number (\d+)$/ do |line_number| rspec_its_gem_location = File.expand_path('../../../lib/rspec/its', __FILE__) require_option = "--require #{rspec_its_gem_location}" file_specification = "example_spec.rb:#{line_number}" rspec_command = ['rspec', require_option, file_specification].join(' ') step "I run `#{rspec_command}`" end Then /^the example(?:s)? should(?: all)? pass$/ do step %q{the output should contain "0 failures"} step %q{the output should not contain "0 examples"} step %q{the exit status should be 0} end Then(/^the example should fail$/) do step %q{the output should contain "1 failure"} step %q{the exit status should not be 0} end Then(/^the output should contain "(.*?)" and "(.*?)"$/) do |string1, string2| unless [string1, string2].all? { |s| all_output.include?(s) } fail %Q{Both "#{string1}" and "#{string2}" were found in:\n#{all_output}} end end rspec-its-1.3.0/features/its.feature0000644000004100000410000001115013455462614017456 0ustar www-datawww-dataFeature: attribute of subject Scenario: specify value of a nested attribute Given a file named "example_spec.rb" with: """ruby class Person attr_reader :phone_numbers def initialize @phone_numbers = [] end end describe Person do context "with one phone number (555-1212)"do subject do person = Person.new person.phone_numbers << "555-1212" person end its("phone_numbers.first") { should eq("555-1212") } end end """ When I run rspec with the documentation option Then the output should contain: """ Person with one phone number (555-1212) phone_numbers.first should eq "555-1212" """ Scenario: specify value of an attribute of a hash Given a file named "example_spec.rb" with: """ruby describe Hash do context "with two items" do subject do {:one => 'one', :two => 'two'} end its(:size) { should eq(2) } end end """ When I run rspec Then the examples should all pass Scenario: specify value for key in a hash Given a file named "example_spec.rb" with: """ruby describe Hash do context "with keys :one and 'two'" do subject do {:one => 1, "two" => 2} end its([:one]) { should eq(1) } its(["two"]) { should eq(2) } end end """ When I run rspec Then the examples should all pass Scenario: specify value for key in a hash-like object Given a file named "example_spec.rb" with: """ruby require 'matrix' describe Matrix do context "with values [[1, 2], [3, 4]]" do subject do Matrix[[1, 2], [3, 4]] end its([0, 1]) { should eq(2) } its([1, 0]) { should eq(3) } its([1, 2]) { should be_nil } end end """ When I run rspec Then the examples should all pass Scenario: failures are correctly reported as coming from the `its` line Given a file named "example_spec.rb" with: """ruby describe Array do context "when first created" do its(:size) { should_not eq(0) } end end """ When I run rspec Then the output should contain "Failure/Error: its(:size) { should_not eq(0) }" And the output should not match /#[^\n]*rspec[\x2f]its/ Scenario: examples can be specified by exact line number Given a file named "example_spec.rb" with: """ruby describe Array do context "when first created" do its(:size) { should eq(0) } end end """ When I run rspec specifying line number 3 Then the examples should all pass Scenario: examples can be specified by line number within containing block Given a file named "example_spec.rb" with: """ruby describe Array do context "when first created" do its(:size) { should eq(0) } end it "should never execute this" do expect(true).to be(false) end end """ When I run rspec specifying line number 2 Then the examples should all pass Scenario: specify a method throws an expection Given a file named "example_spec.rb" with: """ruby class Klass def foo true end end describe Klass do subject { Klass.new } its(:foo) { will_not raise_error } its(:bar) { will raise_error(NoMethodError) } end """ When I run rspec Then the examples should all pass Scenario: specify a method does not throw an expection Given a file named "example_spec.rb" with: """ruby class Klass; end describe Klass do subject { Klass.new } its(:foo) { will_not raise_error } end """ When I run rspec Then the example should fail And the output should contain "Failure/Error: its(:foo) { will_not raise_error }" And the output should contain "expected no Exception, got #